feat: have Message.to_pydantic(...) set tool_calls to None if empty (#1695)

This commit is contained in:
Sarah Wooders
2025-04-12 16:51:54 -07:00
committed by GitHub
parent 32f08883ca
commit d1b22e929b

View File

@@ -65,6 +65,9 @@ class Message(SqlalchemyBase, OrganizationMixin, AgentMixin):
model = self.__pydantic_model__.model_validate(self)
if self.text and not model.content:
model.content = [PydanticTextContent(text=self.text)]
# If there are no tool calls, set tool_calls to None
if len(self.tool_calls) == 0:
model.tool_calls = None
return model