diff options
| author | Dhravya <[email protected]> | 2024-06-16 19:00:24 -0500 |
|---|---|---|
| committer | Dhravya <[email protected]> | 2024-06-16 19:00:24 -0500 |
| commit | a4c835e58370641947a757cbcb5d3ff4d4c09c06 (patch) | |
| tree | e67299bbf0d855366edd8b34b3e978a43090ccdf | |
| parent | store full info (diff) | |
| download | supermemory-a4c835e58370641947a757cbcb5d3ff4d4c09c06.tar.xz supermemory-a4c835e58370641947a757cbcb5d3ff4d4c09c06.zip | |
added sources to the response
| -rw-r--r-- | apps/cf-ai-backend/src/helper.ts | 1 | ||||
| -rw-r--r-- | apps/web/app/(dash)/chat/chatWindow.tsx | 14 |
2 files changed, 13 insertions, 2 deletions
diff --git a/apps/cf-ai-backend/src/helper.ts b/apps/cf-ai-backend/src/helper.ts index 1540c9fd..32928250 100644 --- a/apps/cf-ai-backend/src/helper.ts +++ b/apps/cf-ai-backend/src/helper.ts @@ -124,6 +124,7 @@ export async function batchCreateChunksAndEmbeddings({ url: body.url, user: body.user, type: body.type ?? "page", + content: newPageContent, }, }, ], 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", |