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); }