neo4j / NaLLM

Repository for the NaLLM project
Apache License 2.0
1.24k stars 240 forks source link

OpenAI RateLimit ERROR || Ample Quota left #74

Open Ashutosh-Srivastav opened 10 months ago

Ashutosh-Srivastav commented 10 months ago

Hi,

I have deployed the code as suggested, but while trying to query Knowledge graph, I got the error on terminal/server:

api | [{'role': 'user', 'content': 'Hi'}, {'role': 'user', 'content': 'Which company has generated maximum revenue?'}, {'role': 'user', 'content': 'Question to be converted to Cypher: Which company has generated maximum revenue?'}] api | Retrying LLM call You exceeded your current quota, please check your plan and billing details. api | Retrying LLM call You exceeded your current quota, please check your plan and billing details. api | Retrying LLM call You exceeded your current quota, please check your plan and billing details.

Q. This shouldn't be the case since I have enough quota left in my free tier account for GPT 3.5, kindly review.

Also, there is an uncaught exception for RateLimitError for GPT 3.5 which is implemented for GPT 4:

GPT 4:

api | results {'output': [{'message': 'Error: The model gpt-4 does not exist or you do not have access to it. Learn more: https://help.openai.com/en/articles/7102672-how-can-i-access-gpt-4.'}], 'generated_cypher': None}

GPT 3.5:

api | INFO: 172.18.0.1:52382 - "POST /questionProposalsForCurrentDb HTTP/1.1" 500 Internal Server Error api | ERROR: Exception in ASGI application api | Traceback (most recent call last): api | File "/api/src/llm/openai.py", line 33, in generate api | completions = openai.ChatCompletion.create( api | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ api | File "/usr/local/lib/python3.11/site-packages/openai/api_resources/chat_completion.py", line 25, in create api | return super().create(*args, **kwargs) api | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ api | File "/usr/local/lib/python3.11/site-packages/openai/api_resources/abstract/engine_apiresource.py", line 153, in create api | response, , api_key = requestor.request( api | ^^^^^^^^^^^^^^^^^^ api | File "/usr/local/lib/python3.11/site-packages/openai/api_requestor.py", line 230, in request api | resp, got_stream = self._interpret_response(result, stream) api | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ api | File "/usr/local/lib/python3.11/site-packages/openai/api_requestor.py", line 624, in _interpret_response api | self._interpret_response_line( api | File "/usr/local/lib/python3.11/site-packages/openai/api_requestor.py", line 687, in _interpret_response_line api | raise self.handle_error_response( api | openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details.

This can be handled, in openai.py..

except openai.error.RateLimitError as e:
    return(f"Rate limit exceeded. Error: {e}")
AshutoshABB commented 10 months ago

Hi,

I am sorry, I just noticed my token grants have expired, I had no idea about 3 months availability of free tokens. Still, the exception handling is valid, since the limit error must propagated to client page.

image

Thanks and Regards, Ashutosh