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

[Bug]: Rate limit Timeout Sleep WAY too long #1121

Open
Kking112 opened this issue Oct 24, 2024 · 5 comments
Open

[Bug]: Rate limit Timeout Sleep WAY too long #1121

Kking112 opened this issue Oct 24, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@Kking112
Copy link

Version

Command-line (Python) version

Operating System

Ubuntu Linux

What happened?

When GPT Pilot runs into openai.RateLimitError, it will sleep for well over what is necessary based on the response of the API..

openai.RateLimitError: Error code: 429 - {'error': {'message': 'Rate limit reached for gpt-4o in {REMOVED FOR BUG REPORT} on tokens per min (TPM): Limit 30000, Used 29328, Requested 6310. Please try again in 11.276s. Visit https://platform.openai.com/account/rate-limits to learn more.', 'type': 'tokens', 'param': None, 'code': 'rate_limit_exceeded'}}

GPT Pilot should ideally sleep for the suggested time in the response of 11.276s (maybe add 1 second). Instead, it sleeps for either 7200 seconds or 9600 seconds.. sometimes it prints both. And I have let it sit for hours and it never seems to start up again.

I dug into the source code and I think I may be able to fix this, and if its necessary I will create a pull request to merge into the main repository, but I wanted to first make sure that I am not missing something and just need to change the config.json, or something similar.

Thank you in advance, and if you have had this issue too and there is no obvious fix, please let me know and I will start to fix it myself and create a pull request. I'd love to contribute to this awesome project!

@Kking112 Kking112 added the bug Something isn't working label Oct 24, 2024
@keshav2800
Copy link

hi, did you figured out how this will be solved?
i am facing the same issue

@losogudok
Copy link

I have same issue with Claude.
We've hit anthropic rate limit. Sleeping for 0 seconds...We've hit anthropic rate limit. Sleeping for 0 seconds...We've hit anthropic rate limit. Sleeping for 0 seconds...We've hit anthropic rate limit. Sleeping for 0 seconds...We've hit anthropic rate limit. Sleeping for 86399 seconds...
Is it possible to continue where you left off?

@mikerz
Copy link

mikerz commented Dec 25, 2024

Pretty significant issue, as soon as you hit rate limits gptpilot is bricked

@Bhalajee
Copy link

Bhalajee commented Jan 1, 2025

just replace this part of code :(find this in core.llm.base.py)

def rate_limit_sleep(self, err: Exception) -> Optional[datetime.timedelta]:
'''
Return how long we need to sleep because of rate limiting.
These are computed from the response headers that each LLM returns.
For details, check the implementation for the specific LLM. If there
are no rate limiting headers, we assume that the request should not
be retried and return None (this will be the case for insufficient
quota/funds in the account).
:param err: RateLimitError that was raised by the LLM client.
:return: optional timedelta to wait before trying again
'''
raise NotImplementedError()

with

import re
import datetime

def rate_limit_sleep(self, err: Exception) -> Optional[datetime.timedelta]:
# Extract the suggested wait time from the error message
match = re.search(r'Please try again in (\d+(.\d+)?)s', str(err))
if match:
wait_time = float(match.group(1))
# Return the wait time as a timedelta
return datetime.timedelta(seconds=wait_time + 1) # Add 1 second buffer
return None

@keshav2800
Copy link

@Bhalajee it didnot worked for me still its showing the same thing We've hit openai rate limit. Sleeping for 7200 seconds...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants