Skip to content

Commit

Permalink
Merge pull request #622 from mmikita95/chore-serialize-non-empty-content
Browse files Browse the repository at this point in the history
chore: serialize tool calls messages with non-empty content
  • Loading branch information
ramedina86 authored Nov 28, 2024
2 parents 8774f9b + 93a4f6e commit c789209
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/writer/ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -1821,14 +1821,16 @@ def _is_serialized(self, message: 'Conversation.Message') -> bool:
"""
Function to verify whether the message should be serializable.
:return: Boolean that indicates
:return: Boolean indicating if the message meets
the criteria for serialization.
"""
if message["role"] in ["system", "tool"]:
# Prevent serialization of messages
# not intended for user display
return False
elif message.get("tool_call_id") is not None:
return False
tool_calls = message.get("tool_calls")
if tool_calls is not None and tool_calls != []:
elif not message.get("content"):
# Prevent serialization for messages
# without meaningful content
return False

return True
Expand Down

0 comments on commit c789209

Please sign in to comment.