mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-09-09 22:31:10 +00:00
fix: Spaces filter not working
This commit is contained in:
parent
610360dffd
commit
3754b2c2c8
5 changed files with 25 additions and 18 deletions
|
|
@ -64,6 +64,7 @@ app.post("/api/add", zValidator("json", vectorObj), async (c) => {
|
|||
|
||||
const { store } = await initQuery(c);
|
||||
|
||||
console.log(body.spaces);
|
||||
await batchCreateChunksAndEmbeddings({
|
||||
store,
|
||||
body,
|
||||
|
|
@ -354,6 +355,7 @@ app.post(
|
|||
}
|
||||
|
||||
const spaces = query.spaces?.split(",") ?? [undefined];
|
||||
console.log(spaces);
|
||||
|
||||
// Get the AI model maker and vector store
|
||||
const { model, store } = await initQuery(c, query.model);
|
||||
|
|
@ -372,8 +374,11 @@ app.post(
|
|||
|
||||
// SLICED to 5 to avoid too many queries
|
||||
for (const space of spaces.slice(0, 5)) {
|
||||
console.log("space", space);
|
||||
if (!space && spaces.length > 1) {
|
||||
if (space && space.length >= 1) {
|
||||
console.log(
|
||||
"this is the key being used",
|
||||
`space-${query.user}-${space}`,
|
||||
);
|
||||
// it's possible for space list to be [undefined] so we only add space filter conditionally
|
||||
filter[`space-${query.user}-${space}`] = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ async function Page({
|
|||
return (
|
||||
<ChatWindow
|
||||
q={q}
|
||||
spaces={spaces}
|
||||
spaces={spaces ?? []}
|
||||
initialChat={chat.data.length > 0 ? chat.data : undefined}
|
||||
threadId={params.chatid}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ function ChatWindow({
|
|||
threadId,
|
||||
}: {
|
||||
q: string;
|
||||
spaces: { id: string; name: string }[];
|
||||
spaces: { id: number; name: string }[];
|
||||
initialChat?: ChatHistory[];
|
||||
threadId: string;
|
||||
}) {
|
||||
|
|
@ -179,7 +179,7 @@ function ChatWindow({
|
|||
if (startGenerating) {
|
||||
getAnswer(
|
||||
q,
|
||||
spaces.map((s) => `${s}`),
|
||||
spaces.map((s) => `${s.id}`),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -181,6 +181,7 @@ export const createMemory = async (input: {
|
|||
storeToSpaces = [];
|
||||
}
|
||||
|
||||
console.log(storeToSpaces);
|
||||
const vectorSaveResponse = await fetch(
|
||||
`${process.env.BACKEND_BASE_URL}/api/add`,
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,20 +15,21 @@ export const homeSearchParamsCache = createSearchParamsCache({
|
|||
export const chatSearchParamsCache = createSearchParamsCache({
|
||||
firstTime: parseAsBoolean.withDefault(false),
|
||||
q: parseAsString.withDefault(""),
|
||||
spaces: parseAsArrayOf(
|
||||
parseAsJson((c) => {
|
||||
const valid = z
|
||||
.object({
|
||||
id: z.string(),
|
||||
spaces: parseAsJson((c) => {
|
||||
const valid = z
|
||||
.array(
|
||||
z.object({
|
||||
id: z.number(),
|
||||
name: z.string(),
|
||||
})
|
||||
.safeParse(c);
|
||||
}),
|
||||
)
|
||||
.safeParse(c);
|
||||
|
||||
if (!valid.success) {
|
||||
return null;
|
||||
}
|
||||
if (!valid.success) {
|
||||
console.log("invalid spaces", valid.error);
|
||||
return null;
|
||||
}
|
||||
|
||||
return valid.data;
|
||||
}),
|
||||
).withDefault([]),
|
||||
return valid.data;
|
||||
}),
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue