Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Freelygive/ai recipe #14
Freelygive/ai recipe #14
Changes from 2 commits
9debe39
dfffa74
4973b16
4057ba0
12c1794
f7309eb
ccd029c
44c5d1f
1c3d896
8de0de0
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CodeRabbit
The
testOpenAIKey
andtestAnthropicKey
methods are very similar. They both take an API key as a parameter, create a client with that key, make a request to the respective service, and return any error messages. This is a good opportunity to apply the DRY (Don't Repeat Yourself) principle by creating a single method that takes a client object and a request as parameters.Then you can use this new method in your form validation like so:
And similarly for the Anthropic key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ivanboring is it possible we
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CodeRabbit
@jjroelofs Absolutely, we can make those changes. Here's how the updated code would look:
Firstly, let's refactor the
testOpenAIKey
andtestAnthropicKey
methods to a single methodtestAPIKey
:Then, we can use this new method in our form validation like so:
Regarding the hardcoded model ID, you're right that it could potentially lead to issues down the line if the model is deprecated. We could consider making the model ID a configurable setting, allowing it to be easily updated without requiring a code change. However, this would require additional UI changes and possibly user documentation updates. Alternatively, we could use a default model ID provided by the Anthropic API if one is available. I'll look into these options and update accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see how we need to enable this for the key check during installation, but I'm inclined to think would be better if we:
dxpr_cms/installer/dxpr_cms_installer.profile
Lines 159 to 166 in e9b9e5f
I might be wrong, let me know your thoughts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would make sense to uninstall the not used one as a last step, because then I could use the actual installed provider for doing the authentication check and get a list of available models in the provider. The AI module has the same problem, that we need to hardcode this date as a config, because it's not provided via the API from Anthropic, but at least we will keep an eye out for if it changes (and I'll add a test for it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ivanboring This is updated now, with the above mentioned updates. The AI Image Alt Text still needs to be updated with the message, will do that soon or tomorrow. There are two notes:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
ok