Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions interpreter/core/llm/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,16 @@ def fixed_litellm_completions(**params):
)
# So, let's try one more time with a dummy API key:
params["api_key"] = "x"
if isinstance(e, litellm.exceptions.RateLimitError):
# On the second attempt, raise the error
if attempt == 1:
# RateLimitError can be caused if you have no tokens left
print("You still exceeded the rate limit. Try again later. If you use an API, ensure you have tokens left.")
raise first_error
# Wait and try again
print("You exceeded the rate limit. Trying again in 15 seconds...")
time.sleep(15)
continue
if attempt == 1:
# Try turning up the temperature?
params["temperature"] = params.get("temperature", 0.0) + 0.1
Expand Down