Skip to content

Commit

Permalink
Handle typed message parts when reverting multimodal content for `Cha…
Browse files Browse the repository at this point in the history
…tObject`
  • Loading branch information
rhennigan committed Nov 29, 2023
1 parent 733dbb6 commit 4a6e0ae
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Source/Chatbook/Actions.wl
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,13 @@ revertMultimodalContent // beginDefinition;
revertMultimodalContent[ messages_List ] :=
revertMultimodalContent /@ messages;

revertMultimodalContent[ as: KeyValuePattern[ "Content" -> content_List ] ] :=
<| as, "Content" -> StringJoin @ Select[ content, StringQ ] |>;
revertMultimodalContent[ as: KeyValuePattern[ "Content" -> content_List ] ] := <|
as,
"Content" -> StringJoin @ Cases[
content,
s_String | KeyValuePattern @ { "Type" -> "Text", "Data" -> s_String } :> s
]
|>;

revertMultimodalContent[ as: KeyValuePattern[ "Content" -> _String ] ] :=
as;
Expand Down

0 comments on commit 4a6e0ae

Please sign in to comment.