Skip to content

Commit 95f093d

Browse files
committed
Fixed function calling for local LLMs
1 parent 321d0a8 commit 95f093d

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
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)

0 commit comments

Comments
 (0)