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

Feature: Use API key not session token #42

Closed
benzntech opened this issue Jan 5, 2023 · 5 comments
Closed

Feature: Use API key not session token #42

benzntech opened this issue Jan 5, 2023 · 5 comments

Comments

@benzntech
Copy link

benzntech commented Jan 5, 2023

Allow us to use the API key which is consistent and how we are supposed to use the ChatGPT API.

Example of curl using the api

curl https://api.openai.com/v1/completions \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer [api-key]" \
  -d '{
  "model": "text-davinci-003",
  "prompt": "$query",
  "max_tokens": 4000,
  "temperature": 0.9 

REFERENCE: https://beta.openai.com/docs/api-reference/authentication

Use the official OpenAI API to generate code or natural language responses from OpenAI's GPT3/GPT3.5 to your questions, right within the editor

@gencay
Copy link
Owner

gencay commented Jan 5, 2023

Thanks for the suggestion! Yes, this is in the todo list for the extension

@benzntech
Copy link
Author

benzntech commented Jan 5, 2023

Use the official OpenAI API to generate code or natural language responses from OpenAI's GPT3/GPT3.5 to your questions, right within the editor

https://github.com/timkmecl/codegpt

@benzntech
Copy link
Author

benzntech commented Jan 6, 2023

Limitation on API :
OpenAI has some rate limits on their API access:

20 requests per minute for free access
60 rpm in pay as you go initially, then it ramps up to 3000 later
see https://help.openai.com/en/articles/5955598-is-api-usage-subject-to-any-rate-limits for details.

Describe the solution you'd like
I see 3 solutions:

get paid plan and wait a bit (3000 requests per minute should be fine for most cases)
hack a time.sleep(X) in here
haystack implements an optional rate limit in the eval methods

This request queries the Davinci model to complete the text starting with a prompt of "Say this is a test". The max_tokens parameter sets an upper bound on how many tokens the API will return. You should get a response back that resembles the following:

API usage subject to any rate limits
image

@gencay
Copy link
Owner

gencay commented Jan 6, 2023

@benzntech please check V3. OpenAI GPT3 integration is now available. And yes, there are rate-limits and I suspect the APIs will get more restrictive in the future. But I added it as a method for people to experiment with their personal or organizational API Keys.

@gencay gencay closed this as completed Jan 6, 2023
@benzntech
Copy link
Author

API is not working. Ask to reset the session not working as expected.

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

No branches or pull requests

2 participants