aboutsummaryrefslogtreecommitdiff
path: root/apps/web
diff options
context:
space:
mode:
authorDhravya <[email protected]>2024-06-16 19:00:24 -0500
committerDhravya <[email protected]>2024-06-16 19:00:24 -0500
commita4c835e58370641947a757cbcb5d3ff4d4c09c06 (patch)
treee67299bbf0d855366edd8b34b3e978a43090ccdf /apps/web
parentstore full info (diff)
downloadarchived-supermemory-a4c835e58370641947a757cbcb5d3ff4d4c09c06.tar.xz
archived-supermemory-a4c835e58370641947a757cbcb5d3ff4d4c09c06.zip
added sources to the response
Diffstat (limited to 'apps/web')
-rw-r--r--apps/web/app/(dash)/chat/chatWindow.tsx14
1 files changed, 12 insertions, 2 deletions
diff --git a/apps/web/app/(dash)/chat/chatWindow.tsx b/apps/web/app/(dash)/chat/chatWindow.tsx
index 8956ba9b..3fd08657 100644
--- a/apps/web/app/(dash)/chat/chatWindow.tsx
+++ b/apps/web/app/(dash)/chat/chatWindow.tsx
@@ -73,8 +73,18 @@ function ChatWindow({
return;
}
- console.log(sourcesParsed.data.ids);
- console.log(sourcesParsed.data.metadata);
+ setChatHistory((prevChatHistory) => {
+ const newChatHistory = [...prevChatHistory];
+ const lastAnswer = newChatHistory[newChatHistory.length - 1];
+ if (!lastAnswer) return prevChatHistory;
+ lastAnswer.answer.sources = sourcesParsed.data.metadata.map((source) => ({
+ title: source.title ?? "Untitled",
+ type: source.type ?? "page",
+ source: source.url ?? "https://supermemory.ai",
+ content: source.content ?? "No content available",
+ }));
+ return newChatHistory;
+ });
const resp = await fetch(`/api/chat?q=${query}&spaces=${spaces}`, {
method: "POST",