Skip to content

Commit c0909ad

Browse files
committed
re: add markdown message for insufficient_quota error in openai
1 parent c044179 commit c0909ad

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

interpreter/core/respond.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True"
77
import litellm
8+
import openai
89

910
from ..terminal_interface.utils.display_markdown_message import display_markdown_message
1011
from .render_message import render_message
@@ -105,6 +106,20 @@ def respond(interpreter):
105106
raise Exception(
106107
f"{output}\n\nThere might be an issue with your API key(s).\n\nTo reset your API key (we'll use OPENAI_API_KEY for this example, but you may need to reset your ANTHROPIC_API_KEY, HUGGINGFACE_API_KEY, etc):\n Mac/Linux: 'export OPENAI_API_KEY=your-key-here'. Update your ~/.zshrc on MacOS or ~/.bashrc on Linux with the new key if it has already been persisted there.,\n Windows: 'setx OPENAI_API_KEY your-key-here' then restart terminal.\n\n"
107108
)
109+
elif (
110+
type(e) == litellm.exceptions.RateLimitError
111+
and "exceeded" in str(e).lower()
112+
or "insufficient_quota" in str(e).lower()
113+
):
114+
display_markdown_message(
115+
f""" > You ran out of current quota for OpenAI's API, please check your plan and billing details. You can either wait for the quota to reset or upgrade your plan.
116+
117+
To check your current usage and billing details, visit the [OpenAI billing page](https://platform.openai.com/settings/organization/billing/overview).
118+
119+
You can also use `interpreter --max_budget [higher USD amount]` to set a budget for your sessions.
120+
"""
121+
)
122+
108123
elif (
109124
interpreter.offline == False and "not have access" in str(e).lower()
110125
):

0 commit comments

Comments
 (0)