Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

fix: Fix summarizer bug with tool choice (#2845)

Matthew Zhou8a9c05b61159
diff --git a/letta/llm_api/openai_client.py b/letta/llm_api/openai_client.py
index 7f29da9ae..4629db321 100644
--- a/letta/llm_api/openai_client.py
+++ b/letta/llm_api/openai_client.py
@@ -198,14 +198,15 @@ class OpenAIClient(LLMClientBase):
# TODO(matt) move into LLMConfig
# TODO: This vllm checking is very brittle and is a patch at most
tool_choice = None
- if self.requires_auto_tool_choice(llm_config):
- tool_choice = "auto"
- elif tools:
- # only set if tools is non-Null
- tool_choice = "required"
-
- if force_tool_call is not None:
- tool_choice = ToolFunctionChoice(type="function", function=ToolFunctionChoiceFunctionCall(name=force_tool_call))
+ if tools: # only set tool_choice if tools exist
+ if self.requires_auto_tool_choice(llm_config):
+ tool_choice = "auto"
+ else:
+ # only set if tools is non-Null
+ tool_choice = "required"
+
+ if force_tool_call is not None:
+ tool_choice = ToolFunctionChoice(type="function", function=ToolFunctionChoiceFunctionCall(name=force_tool_call))
data = ChatCompletionRequest(
model=model,