Skip to content

Commit

Permalink
Ensure metadata.debug is always a dict (#210)
Browse files Browse the repository at this point in the history
Before merging into debug_data
  • Loading branch information
markwaddle authored Nov 5, 2024
1 parent 6827e45 commit e34f2a7
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -671,9 +671,11 @@ async def create_conversation_message(
participant_id = str(principal.assistant_id)

# pop "debug" from metadata, if it exists, and merge with the debug field
message_debug = deepmerge.always_merger.merge(
(new_message.metadata or {}).pop("debug", None), new_message.debug_data or {}
)
message_debug = (new_message.metadata or {}).pop("debug", None)
# ensure that message_debug is a dictionary, in cases like {"debug": "some message"}, or {"debug": [1,2]}
if message_debug and not isinstance(message_debug, dict):
message_debug = {"debug": message_debug}
message_debug = deepmerge.always_merger.merge(message_debug or {}, new_message.debug_data or {})

message = db.ConversationMessage(
conversation_id=conversation.conversation_id,
Expand Down

0 comments on commit e34f2a7

Please sign in to comment.