mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-09-08 22:21:07 +00:00
include metadata in response, add type to metadata
This commit is contained in:
parent
2ffb0542eb
commit
a9f5ebc9e4
4 changed files with 24 additions and 2 deletions
|
|
@ -124,6 +124,7 @@ export async function batchCreateChunksAndEmbeddings({
|
|||
space: body.space ?? "",
|
||||
url: body.url,
|
||||
user: body.user,
|
||||
type: body.type ?? "page",
|
||||
},
|
||||
},
|
||||
],
|
||||
|
|
|
|||
|
|
@ -180,7 +180,9 @@ app.post(
|
|||
idsAsStrings.map(async (id) => await c.env.KV.get(id)),
|
||||
);
|
||||
|
||||
return c.json({ ids: storedContent });
|
||||
const metadata = normalizedData.map((datapoint) => datapoint.metadata);
|
||||
|
||||
return c.json({ ids: storedContent, metadata });
|
||||
}
|
||||
|
||||
const preparedContext = normalizedData.map(
|
||||
|
|
|
|||
|
|
@ -46,4 +46,5 @@ export const vectorObj = z.object({
|
|||
space: z.string().optional(),
|
||||
url: z.string(),
|
||||
user: z.string(),
|
||||
type: z.string().optional(),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ import rehypeKatex from "rehype-katex";
|
|||
import rehypeHighlight from "rehype-highlight";
|
||||
import { code, p } from "./markdownRenderHelpers";
|
||||
import { codeLanguageSubset } from "@/lib/constants";
|
||||
import { z } from "zod";
|
||||
import { toast } from "sonner";
|
||||
|
||||
function ChatWindow({
|
||||
q,
|
||||
|
|
@ -56,7 +58,23 @@ function ChatWindow({
|
|||
|
||||
// TODO: handle this properly
|
||||
const sources = await sourcesFetch.json();
|
||||
console.log(sources);
|
||||
|
||||
const sourcesZod = z.object({
|
||||
ids: z.array(z.string()),
|
||||
metadata: z.array(z.any()),
|
||||
});
|
||||
|
||||
const sourcesParsed = sourcesZod.safeParse(sources);
|
||||
|
||||
if (!sourcesParsed.success) {
|
||||
console.log(sources);
|
||||
console.error(sourcesParsed.error);
|
||||
toast.error("Something went wrong while getting the sources");
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(sourcesParsed.data.ids);
|
||||
console.log(sourcesParsed.data.metadata);
|
||||
|
||||
const resp = await fetch(`/api/chat?q=${query}&spaces=${spaces}`, {
|
||||
method: "POST",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue