Skip to content

Commit 33d6e55

Browse files
authored
New --groq profile + error message fix
New `--groq` profile + error message fix
2 parents 6c08d90 + 8e1e5b9 commit 33d6e55

File tree

3 files changed

+41
-5
lines changed

3 files changed

+41
-5
lines changed

interpreter/core/respond.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,11 @@ def respond(interpreter):
101101
# Provide extra information on how to change API keys, if we encounter that error
102102
# (Many people writing GitHub issues were struggling with this)
103103
except Exception as e:
104+
error_message = str(e).lower()
104105
if (
105106
interpreter.offline == False
106-
and "auth" in str(e).lower()
107-
or "api key" in str(e).lower()
107+
and "auth" in error_message
108+
or "api key" in error_message
108109
):
109110
output = traceback.format_exc()
110111
raise Exception(
@@ -113,9 +114,20 @@ def respond(interpreter):
113114
elif (
114115
interpreter.offline == False and "not have access" in str(e).lower()
115116
):
116-
response = input(
117-
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 "
118-
)
117+
"""
118+
Check for invalid model in error message and then fallback to groq, then OpenAI.
119+
"""
120+
if (
121+
"invalid model" in error_message
122+
or "model does not exist" in error_message
123+
):
124+
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 "
125+
elif "groq" in error_message:
126+
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 "
127+
else:
128+
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 "
129+
130+
response = input(provider_message)
119131
print("") # <- Aesthetic choice
120132

121133
if response.strip().lower() == "y":
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
This is an Open Interpreter profile. It configures Open Interpreter to run `Llama 3.1 70B` using Groq.
3+
4+
Make sure to set GROQ_API_KEY environment variable to your API key.
5+
"""
6+
7+
from interpreter import interpreter
8+
9+
interpreter.llm.model = "groq/llama-3.1-70b-versatile"
10+
11+
interpreter.computer.import_computer_api = True
12+
13+
interpreter.llm.supports_functions = False
14+
interpreter.llm.supports_vision = False
15+
interpreter.llm.context_window = 110000
16+
interpreter.llm.max_tokens = 4096

interpreter/terminal_interface/start_terminal_interface.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ def start_terminal_interface(interpreter):
222222
"help_text": "shortcut for `interpreter --profile llama3`",
223223
"type": bool,
224224
},
225+
{
226+
"name": "groq",
227+
"help_text": "shortcut for `interpreter --profile groq`",
228+
"type": bool,
229+
},
225230
{
226231
"name": "vision",
227232
"nickname": "vi",
@@ -440,6 +445,9 @@ def print_help(self, *args, **kwargs):
440445
if args.os:
441446
args.profile = "llama3-os.py"
442447

448+
if args.groq:
449+
args.profile = "groq.py"
450+
443451
interpreter = profile(
444452
interpreter,
445453
args.profile or get_argument_dictionary(arguments, "profile")["default"],

0 commit comments

Comments
 (0)