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

Allow API key overrides to /chat and /converse endpoints #39

Closed
skks1212 opened this issue Apr 15, 2023 · 0 comments · Fixed by #41
Closed

Allow API key overrides to /chat and /converse endpoints #39

skks1212 opened this issue Apr 15, 2023 · 0 comments · Fixed by #41
Assignees
Labels

Comments

@skks1212
Copy link
Member

skks1212 commented Apr 15, 2023

As Ayushma will be open to all, it is not viable to have everyone be able to use our Open AI api keys. We should only allow a set number of users to use Ayushma's OpenAI key.

So, add a boolean field called allow_key (or any other name that you think would be more fit) with default false to the user model. Allow /chat and /converse endpoints to have an open_ai_key parameter to be sent in the request headers. Now check if open_ai_key is present in the request headers.

  • If it is, use that key.
  • If the key is not present in the request headers, and the allow_key value is True on the requesting user, use the default OPEN_AI_KEY.
  • If the key is not present in the headers, and the allow_key is False, respond with an error message asking for an open_ai_key
@rithviknishad rithviknishad self-assigned this Apr 15, 2023
rithviknishad added a commit that referenced this issue Apr 15, 2023
skks1212 added a commit that referenced this issue Apr 16, 2023
…points. (#41)

* fixes #39

* move `allow_key` to User model

* update ChatViewSet to use allow_key from user

* remove allow_key from chat serializer

* format

---------

Co-authored-by: Shivank Kacker <kacker.shivank@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants