aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDhravya <[email protected]>2024-06-29 01:02:04 -0500
committerDhravya <[email protected]>2024-06-29 01:02:04 -0500
commit3754b2c2c8453344b14b1c8f4cc718a649f85950 (patch)
treef19e11c9e75c7219d8c35913ce6a306acf382996
parentdynamic island no longer needed (diff)
downloadsupermemory-3754b2c2c8453344b14b1c8f4cc718a649f85950.tar.xz
supermemory-3754b2c2c8453344b14b1c8f4cc718a649f85950.zip
fix: Spaces filter not working
-rw-r--r--apps/cf-ai-backend/src/index.ts9
-rw-r--r--apps/web/app/(dash)/chat/[chatid]/page.tsx2
-rw-r--r--apps/web/app/(dash)/chat/chatWindow.tsx4
-rw-r--r--apps/web/app/actions/doers.ts1
-rw-r--r--apps/web/lib/searchParams.ts27
5 files changed, 25 insertions, 18 deletions
diff --git a/apps/cf-ai-backend/src/index.ts b/apps/cf-ai-backend/src/index.ts
index 60188090..dbc0989b 100644
--- a/apps/cf-ai-backend/src/index.ts
+++ b/apps/cf-ai-backend/src/index.ts
@@ -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;
}
diff --git a/apps/web/app/(dash)/chat/[chatid]/page.tsx b/apps/web/app/(dash)/chat/[chatid]/page.tsx
index e37ae07e..96e96020 100644
--- a/apps/web/app/(dash)/chat/[chatid]/page.tsx
+++ b/apps/web/app/(dash)/chat/[chatid]/page.tsx
@@ -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}
/>
diff --git a/apps/web/app/(dash)/chat/chatWindow.tsx b/apps/web/app/(dash)/chat/chatWindow.tsx
index 9a18cfe7..99c997e4 100644
--- a/apps/web/app/(dash)/chat/chatWindow.tsx
+++ b/apps/web/app/(dash)/chat/chatWindow.tsx
@@ -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 {
diff --git a/apps/web/app/actions/doers.ts b/apps/web/app/actions/doers.ts
index a1de7b54..95b31392 100644
--- a/apps/web/app/actions/doers.ts
+++ b/apps/web/app/actions/doers.ts
@@ -181,6 +181,7 @@ export const createMemory = async (input: {
storeToSpaces = [];
}
+ console.log(storeToSpaces);
const vectorSaveResponse = await fetch(
`${process.env.BACKEND_BASE_URL}/api/add`,
{
diff --git a/apps/web/lib/searchParams.ts b/apps/web/lib/searchParams.ts
index 6db718c2..f3188a6f 100644
--- a/apps/web/lib/searchParams.ts
+++ b/apps/web/lib/searchParams.ts
@@ -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;
+ }),
});