Skip to content

Commit 00acbb4

Browse files
authored
Merge branch 'OpenInterpreter:main' into main
2 parents dbf6833 + c7ff254 commit 00acbb4

File tree

5 files changed

+386
-370
lines changed

5 files changed

+386
-370
lines changed

interpreter/core/llm/llm.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,14 @@ def run(self, messages):
5959
), "No message after the first can have the role 'system'"
6060

6161
# Detect function support
62-
if self.supports_functions != None:
63-
supports_functions = self.supports_functions
64-
elif litellm.supports_function_calling(self.model):
65-
supports_functions = True
66-
else:
67-
supports_functions = False
62+
if self.supports_functions == None:
63+
try:
64+
if litellm.supports_function_calling(self.model):
65+
self.supports_functions = True
66+
else:
67+
self.supports_functions = False
68+
except:
69+
self.supports_functions = False
6870

6971
# Trim image messages if they're there
7072
if self.supports_vision:
@@ -89,7 +91,7 @@ def run(self, messages):
8991
# Convert to OpenAI messages format
9092
messages = convert_to_openai_messages(
9193
messages,
92-
function_calling=supports_functions,
94+
function_calling=self.supports_functions,
9395
vision=self.supports_vision,
9496
shrink_images=self.interpreter.shrink_images,
9597
)
@@ -193,7 +195,7 @@ def run(self, messages):
193195
if self.interpreter.verbose:
194196
litellm.set_verbose = True
195197

196-
if supports_functions:
198+
if self.supports_functions:
197199
yield from run_function_calling_llm(self, params)
198200
else:
199201
yield from run_text_llm(self, params)

interpreter/terminal_interface/profiles/defaults/local.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def download_model(models_dir, models, interpreter):
214214
215215
"""
216216
)
217-
217+
interpreter.llm.supports_functions = False
218218
interpreter.llm.api_base = "http://localhost:1234/v1"
219219
interpreter.llm.api_key = "x"
220220

interpreter/terminal_interface/profiles/profiles.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def apply_profile(interpreter, profile, profile_path):
155155
"We have updated our profile file format. Would you like to migrate your profile file to the new format? No data will be lost."
156156
)
157157
print("")
158-
message = input("(y/n): ")
158+
message = input("(y/n) ")
159159
print("")
160160
if message.lower() == "y":
161161
migrate_user_app_directory()
@@ -164,7 +164,9 @@ def apply_profile(interpreter, profile, profile_path):
164164
if profile_path.endswith("default.yaml"):
165165
with open(profile_path, "r") as file:
166166
text = file.read()
167-
text = text.replace("version: " + str(profile["version"]), f"version: {OI_VERSION}")
167+
text = text.replace(
168+
"version: " + str(profile["version"]), f"version: {OI_VERSION}"
169+
)
168170

169171
try:
170172
if profile["llm"]["model"] == "gpt-4":
@@ -175,7 +177,7 @@ def apply_profile(interpreter, profile, profile_path):
175177
profile["llm"]["model"] = "gpt-4-turbo"
176178
except:
177179
raise
178-
pass # fine
180+
pass # fine
179181

180182
with open(profile_path, "w") as file:
181183
file.write(text)
@@ -566,7 +568,7 @@ def apply_profile_to_object(obj, profile):
566568

567569
def open_storage_dir(directory):
568570
dir = os.path.join(oi_dir, directory)
569-
571+
570572
print(f"Opening {directory} directory ({dir})...")
571573

572574
if platform.system() == "Windows":
@@ -580,6 +582,7 @@ def open_storage_dir(directory):
580582
subprocess.call(["open", dir])
581583
return
582584

585+
583586
def reset_profile(specific_default_profile=None):
584587
if (
585588
specific_default_profile
@@ -628,9 +631,7 @@ def reset_profile(specific_default_profile=None):
628631
with open(target_file, "r") as file:
629632
current_profile = file.read()
630633
if current_profile not in historical_profiles:
631-
user_input = input(
632-
f"Would you like to reset/update {filename}? (y/n): "
633-
)
634+
user_input = input(f"Would you like to reset/update {filename}? (y/n) ")
634635
if user_input.lower() == "y":
635636
send2trash.send2trash(
636637
target_file

0 commit comments

Comments
 (0)