Skip to content

Commit

Permalink
Use match case for FRC type
Browse files Browse the repository at this point in the history
  • Loading branch information
moonbox3 committed Dec 16, 2024
1 parent a2cddb4 commit 72b9fe7
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,15 @@ def get_message_contents(message: "ChatMessageContent") -> list[dict[str, Any]]:

case FunctionResultContent():
final_result = content.result
if isinstance(final_result, (list, tuple)):
final_result = " ".join(map(str, final_result))
elif not isinstance(final_result, str):
final_result = str(final_result)
contents.append({"type": "text", "text": final_result})
match final_result:
case str():
contents.append({"type": "text", "text": final_result})
case list() | tuple():
contents.append({"type": "text", "text": " ".join(map(str, final_result))})
case dict():
contents.append({"type": "text", "text": str(final_result)})
case _:
contents.append({"type": "text", "text": str(final_result)})

return contents

Expand Down

0 comments on commit 72b9fe7

Please sign in to comment.