diff --git a/src/message.tsx b/src/message.tsx index 483e33d..f163b74 100644 --- a/src/message.tsx +++ b/src/message.tsx @@ -12,35 +12,97 @@ interface EditMessageProps { setChatStore: (cs: ChatStore) => void; } +export const isVailedJSON = (str: string): boolean => { + try { + JSON.parse(str); + } catch (e) { + return false; + } + return true; +}; + function EditMessage(props: EditMessageProps) { const { setShowEdit, chat, setChatStore, chatStore } = props; return (
setShowEdit(false)} > -
+
{ + event.stopPropagation(); + }} + > {typeof chat.content === "string" ? ( - +
+ {chat.tool_call_id && ( + + + { + chat.tool_call_id = event.target.value; + setChatStore({ ...chatStore }); + }} + /> + + )} + {chat.tool_calls && + chat.tool_calls.map((tool_call) => ( +
+ + + + + + + + + + + + Vailed JSON:{" "} + {isVailedJSON(tool_call.function.arguments) ? "🆗" : "❌"} + + + +
+
+ ))} + +
) : (
+ + Valied JSON:{" "} + {isVailedJSON(props.chatStore.toolsString) ? "🆗" : "❌"} +