-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
feat: add public brain creation #1218
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Risk Level 2 - /home/runner/work/quivr/quivr/frontend/lib/components/AddBrainModal/hooks/useAddBrainModal.ts The code is generally well written and follows the SOLID principles. However, there are a few areas that could be improved for better readability and maintainability:
Here is an example of how you could refactor the const handleSubmit = async () => {
const { name, description, setDefault } = getValues();
if (name.trim() === \"\" || isPending) {
publishError();
return;
}
try {
setIsPending(true);
const prompt_id = await getCreatingBrainPromptId();
const createdBrainId = await createBrain({ name, description, max_tokens: maxTokens, model, openai_api_key: openAiKey, temperature, prompt_id, status });
handleBrainCreation(createdBrainId, setDefault);
} catch (err) {
handleBrainCreationError(err);
} finally {
setIsPending(false);
}
}; Risk Level 2 - /home/runner/work/quivr/quivr/frontend/lib/config/defaultBrainConfig.ts The added line of code seems to be setting a export enum Status {
Private = 'private',
// other statuses...
}
// then in your object...
status: Status.Private, Risk Level 2 - /home/runner/work/quivr/quivr/frontend/lib/components/AddBrainModal/AddBrainModal.tsx The code seems to be well written and follows the SOLID principles. However, there are a few areas that could be improved for better readability and maintainability:
Here is an example of how you could refactor the const AddBrainModal = ({ isOpen, onClose, ...props }) => {
const { t } = useTranslation([\"translation\", \"brain\", \"config\"]);
const { handleSubmit, register, ...rest } = useAddBrainModal(props);
return (
<Modal isOpen={isOpen} onClose={onClose}>
<form onSubmit={handleSubmit} {...rest}>
{/* form fields */}
</form>
</Modal>
);
}; And the export const useAddBrainModal = ({ onConfirm, onCancel, ...props }) => {
// hook logic
const handleSubmit = (e) => {
e.preventDefault();
// form submission logic
onConfirm();
};
return { handleSubmit, register, ...rest };
}; 🔨🔧📚 Powered by Code Review GPT |
Screen.Recording.2023-09-20.at.09.30.24.mp4
#1206