Skip to content
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 user level open ai key management #805

Merged
merged 6 commits into from
Aug 1, 2023
Merged

Conversation

mamadoudicko
Copy link
Contributor

@mamadoudicko mamadoudicko commented Jul 31, 2023

Description

  • Add user table
  • Update user route
  • Add user keys settings page
Screen.Recording.2023-07-31.at.13.34.46.mov

Related issue: #749

@vercel
Copy link

vercel bot commented Jul 31, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 31, 2023 3:28pm
quivrapp ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 31, 2023 3:28pm

@mamadoudicko mamadoudicko temporarily deployed to preview July 31, 2023 12:17 — with GitHub Actions Inactive
@mamadoudicko mamadoudicko changed the title Feat: add user level open ai key management feat: add user level open ai key management Jul 31, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jul 31, 2023

LOGAF Level 3 - /home/runner/work/quivr/quivr/backend/core/main.py

The code is generally well-written, but there are a few areas that could be improved for better readability and maintainability:

  1. Environment Variables: It's a good practice to centralize the access to environment variables. Consider creating a separate module or class to handle all environment variables. This way, if a variable is missing or misconfigured, the error can be caught early during the application startup.

  2. Error Handling: The error handling could be improved. Currently, the error messages are being logged and then a 422 error is returned to the client with the error message. It would be better to use custom exceptions to handle different types of errors and use middleware to catch these exceptions and return appropriate HTTP responses.

  3. Startup Event: The startup event is downloading pandoc if it doesn't exist. This could potentially slow down the startup time of the application. Consider checking for pandoc during the build process instead of at runtime.


LOGAF Level 3 - /home/runner/work/quivr/quivr/frontend/app/config/components/ApiKeyConfig/hooks/useApiKeyConfig.ts

The useApiKeyConfig hook is generally well-written, but there are a few areas that could be improved for better readability and maintainability:

  1. Error Handling: The handleCreateClick function is using a try-catch block to handle errors, but it's only logging the error to the console. Consider providing feedback to the user when an error occurs. This could be done by setting an error state in the hook and displaying an error message in the component.

  2. Copy to Clipboard: The copyToClipboard function is using the Clipboard API directly. Consider using a library like copy-to-clipboard to handle copying to the clipboard. This would make the code more readable and easier to test.


LOGAF Level 3 - /home/runner/work/quivr/quivr/backend/core/routes/upload_routes.py

The upload_file function is quite long and does a lot of things. Consider breaking it down into smaller functions. This would make the code easier to read and test. For example, you could have separate functions for validating the file size, getting the OpenAI API key, and filtering the file. Also, the upload_file function could be simplified by using FastAPI's dependency injection to get the openai_api_key and brain.


🌍🔧🚀


Powered by Code Review GPT

from fastapi.responses import JSONResponse
from h11 import Request
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change improt

):
exc_str = f"{exc}".replace("\n", " ").replace(" ", " ")
logger.error(request, exc_str)
content = {"status_code": 10422, "message": exc_str, "data": None}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is status code 10422 ?

if openai_api_key is None:
openai_api_key = brain.get_brain_details()["openai_api_key"]

if openai_api_key is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two 'if' check the same condition

Copy link
Contributor

@gozineb gozineb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add migration script and update the tables.sql last lines with the latest migration

@gozineb gozineb merged commit 7532b55 into main Aug 1, 2023
7 of 8 checks passed
StanGirard pushed a commit that referenced this pull request Sep 12, 2023
* feat: add user user identity table

* feat: add user openai api key input

* feat: add encryption missing message

* chore: log more details about 422 errors

* docs(API): update api creation path

* feat: use user openai key if defined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants