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: patch #1401 (#1406)

Charles Packer99758dc31919
diff --git a/memgpt/llm_api/llm_api_tools.py b/memgpt/llm_api/llm_api_tools.py
index fcea4ce24..1ab36e266 100644
--- a/memgpt/llm_api/llm_api_tools.py
+++ b/memgpt/llm_api/llm_api_tools.py
@@ -179,7 +179,6 @@ def create(
tools=[{"type": "function", "function": f} for f in functions] if functions else None,
tool_choice=function_call,
user=str(user_id),
- response_format={"type": "json_object"},
)
else:
data = ChatCompletionRequest(
@@ -188,8 +187,11 @@ def create(
functions=functions,
function_call=function_call,
user=str(user_id),
- response_format={"type": "json_object"},
)
+ # https://platform.openai.com/docs/guides/text-generation/json-mode
+ # only supported by gpt-4o, gpt-4-turbo, or gpt-3.5-turbo
+ if "gpt-4o" in llm_config.model or "gpt-4-turbo" in llm_config.model or "gpt-3.5-turbo" in llm_config.model:
+ data.response_format = {"type": "json_object"}
if stream:
data.stream = True