appeded metaData object to chatHisory array

This commit is contained in:
sherifButt 2024-03-08 06:54:54 +00:00
parent 3cb8a80e8d
commit 25662abeaf

View File

@ -19,9 +19,20 @@ export default function WorkspaceChat({ loading, workspace }) {
return false; return false;
} }
const chatHistory = threadSlug let chatHistory = threadSlug
? await Workspace.threads.chatHistory(workspace.slug, threadSlug) ? await Workspace.threads.chatHistory(workspace.slug, threadSlug)
: await Workspace.chatHistory(workspace.slug); : 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); setHistory(chatHistory);
setLoadingHistory(false); setLoadingHistory(false);
} }