From 25662abeafb2cb2605dcab74b8330865acec3840 Mon Sep 17 00:00:00 2001 From: sherifButt <90522472+sherifButt@users.noreply.github.com> Date: Fri, 8 Mar 2024 06:54:54 +0000 Subject: [PATCH] appeded metaData object to chatHisory array --- frontend/src/components/WorkspaceChat/index.jsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/WorkspaceChat/index.jsx b/frontend/src/components/WorkspaceChat/index.jsx index 990ac7f5a..d2d81c722 100644 --- a/frontend/src/components/WorkspaceChat/index.jsx +++ b/frontend/src/components/WorkspaceChat/index.jsx @@ -19,9 +19,20 @@ export default function WorkspaceChat({ loading, workspace }) { return false; } - const chatHistory = threadSlug + let chatHistory = threadSlug ? await Workspace.threads.chatHistory(workspace.slug, threadSlug) : await Workspace.chatHistory(workspace.slug); + + // TODO: add conditional if dynamic input is enabled in the workspace by default is false + // Append metadata to the chat history + chatHistory = chatHistory.map((message) => { + if (message.role === "assistant") { + const { remainingText, metaData } = extractMetaData(message.content); + return { ...message, content: remainingText, metaData }; + } + return message; + }); + setHistory(chatHistory); setLoadingHistory(false); }