Skip to content

Commit

Permalink
New --groq profile + error message fix
Browse files Browse the repository at this point in the history
New `--groq` profile + error message fix
  • Loading branch information
KillianLucas authored Aug 1, 2024
2 parents 6c08d90 + 8e1e5b9 commit 33d6e55
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
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
16 changes: 16 additions & 0 deletions interpreter/terminal_interface/profiles/defaults/groq.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
This is an Open Interpreter profile. It configures Open Interpreter to run `Llama 3.1 70B` using Groq.
Make sure to set GROQ_API_KEY environment variable to your API key.
"""

from interpreter import interpreter

interpreter.llm.model = "groq/llama-3.1-70b-versatile"

interpreter.computer.import_computer_api = True

interpreter.llm.supports_functions = False
interpreter.llm.supports_vision = False
interpreter.llm.context_window = 110000
interpreter.llm.max_tokens = 4096
8 changes: 8 additions & 0 deletions interpreter/terminal_interface/start_terminal_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ def start_terminal_interface(interpreter):
"help_text": "shortcut for `interpreter --profile llama3`",
"type": bool,
},
{
"name": "groq",
"help_text": "shortcut for `interpreter --profile groq`",
"type": bool,
},
{
"name": "vision",
"nickname": "vi",
Expand Down Expand Up @@ -440,6 +445,9 @@ def print_help(self, *args, **kwargs):
if args.os:
args.profile = "llama3-os.py"

if args.groq:
args.profile = "groq.py"

interpreter = profile(
interpreter,
args.profile or get_argument_dictionary(arguments, "profile")["default"],
Expand Down

0 comments on commit 33d6e55

Please sign in to comment.