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.

feat: translate `system` to `developer` or o-series models (#1692)

Sarah Wooders63395514cb59
diff --git a/letta/llm_api/openai_client.py b/letta/llm_api/openai_client.py
index 8df6c1cb4..426069ab4 100644
--- a/letta/llm_api/openai_client.py
+++ b/letta/llm_api/openai_client.py
@@ -66,8 +66,14 @@ class OpenAIClient(LLMClientBase):
put_inner_thoughts_first=True,
)
+ use_developer_message = llm_config.model.startswith("o1") or llm_config.model.startswith("o3") # o-series models
openai_message_list = [
- cast_message_to_subtype(m.to_openai_dict(put_inner_thoughts_in_kwargs=llm_config.put_inner_thoughts_in_kwargs))
+ cast_message_to_subtype(
+ m.to_openai_dict(
+ put_inner_thoughts_in_kwargs=llm_config.put_inner_thoughts_in_kwargs,
+ use_developer_message=use_developer_message,
+ )
+ )
for m in messages
]
diff --git a/letta/schemas/message.py b/letta/schemas/message.py
index b9966386c..0cb792380 100644
--- a/letta/schemas/message.py
+++ b/letta/schemas/message.py
@@ -598,6 +598,7 @@ class Message(BaseMessage):
self,
max_tool_id_length: int = TOOL_CALL_ID_MAX_LEN,
put_inner_thoughts_in_kwargs: bool = False,
+ use_developer_message: bool = False,
) -> dict:
"""Go from Message class to ChatCompletion message object"""
@@ -625,7 +626,7 @@ class Message(BaseMessage):
assert all([v is not None for v in [self.role]]), vars(self)
openai_message = {
"content": text_content,
- "role": self.role,
+ "role": "developer" if use_developer_message else self.role,
}
elif self.role == "user":