mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-09-14 23:21:20 +00:00
added sources to the response
This commit is contained in:
parent
0f3d5c4fc6
commit
a4c835e583
2 changed files with 13 additions and 2 deletions
|
|
@ -124,6 +124,7 @@ export async function batchCreateChunksAndEmbeddings({
|
|||
url: body.url,
|
||||
user: body.user,
|
||||
type: body.type ?? "page",
|
||||
content: newPageContent,
|
||||
},
|
||||
},
|
||||
],
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue