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

Fix error message on invalid model name and groq access to open inter… #1377

Merged
Merged
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
22 changes: 17 additions & 5 deletions interpreter/core/respond.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@ def respond(interpreter):
# Provide extra information on how to change API keys, if we encounter that error
# (Many people writing GitHub issues were struggling with this)
except Exception as e:
error_message = str(e).lower()
if (
interpreter.offline == False
and "auth" in str(e).lower()
or "api key" in str(e).lower()
and "auth" in error_message
or "api key" in error_message
):
output = traceback.format_exc()
raise Exception(
Expand All @@ -113,9 +114,20 @@ def respond(interpreter):
elif (
interpreter.offline == False and "not have access" in str(e).lower()
):
response = input(
f" You do not have access to {interpreter.llm.model}. You will need to add a payment method and purchase credits for the OpenAI API billing page (different from ChatGPT) to use `GPT-4`.\n\nhttps://platform.openai.com/account/billing/overview\n\nWould you like to try GPT-3.5-TURBO instead? (y/n)\n\n "
)
"""
Check for invalid model in error message and then fallback to groq, then OpenAI.
"""
if (
"invalid model" in error_message
or "model does not exist" in error_message
):
provider_message = f" The model '{interpreter.llm.model}' does not exist or is invalid. Please check the model name and try again.\n\nWould you like to try an alternative model instead? (y/n)\n\n "
elif "groq" in error_message:
provider_message = f" You do not have access to {interpreter.llm.model}. Please check with Groq for more details.\n\nWould you like to try an alternative model instead? (y/n)\n\n "
else:
provider_message = f" You do not have access to {interpreter.llm.model}. You will need to add a payment method and purchase credits for the OpenAI API billing page (different from ChatGPT) to use `GPT-4`.\n\nhttps://platform.openai.com/account/billing/overview\n\nWould you like to try GPT-3.5-TURBO instead? (y/n)\n\n "

response = input(provider_message)
print("") # <- Aesthetic choice

if response.strip().lower() == "y":
Expand Down