diff options
| author | Dhravya Shah <[email protected]> | 2025-02-18 15:28:01 -0700 |
|---|---|---|
| committer | Dhravya Shah <[email protected]> | 2025-02-18 15:28:01 -0700 |
| commit | 52d89fd1a6036c00bdc79bf1e0ec0df87760890f (patch) | |
| tree | 0bfeb0af4db20ed2f00ff265770678d73868102f /apps/backend/src | |
| parent | added a batch delete feature (diff) | |
| download | supermemory-52d89fd1a6036c00bdc79bf1e0ec0df87760890f.tar.xz supermemory-52d89fd1a6036c00bdc79bf1e0ec0df87760890f.zip | |
better space selector
Diffstat (limited to 'apps/backend/src')
| -rw-r--r-- | apps/backend/src/routes/actions.ts | 18 |
1 files changed, 0 insertions, 18 deletions
diff --git a/apps/backend/src/routes/actions.ts b/apps/backend/src/routes/actions.ts index deba952b..c0801ada 100644 --- a/apps/backend/src/routes/actions.ts +++ b/apps/backend/src/routes/actions.ts @@ -50,9 +50,6 @@ const actions = new Hono<{ Variables: Variables; Bindings: Env }>() }) ), async (c) => { - const startTime = performance.now(); - console.log("[chat] Starting request"); - const user = c.get("user"); if (!user) { return c.json({ error: "Unauthorized" }, 401); @@ -60,7 +57,6 @@ const actions = new Hono<{ Variables: Variables; Bindings: Env }>() const { messages, threadId } = await c.req.valid("json"); - console.log("[chat] Converting messages"); const unfilteredCoreMessages = convertToCoreMessages( (messages as Message[]) .filter((m) => m.content.length > 0) @@ -83,7 +79,6 @@ const actions = new Hono<{ Variables: Variables; Bindings: Env }>() (message) => message.content.length > 0 ); - console.log("[chat] Setting up DB and logger"); const db = database(c.env.HYPERDRIVE.connectionString); const { initLogger, wrapAISDKModel } = await import("braintrust"); @@ -106,8 +101,6 @@ const actions = new Hono<{ Variables: Variables; Bindings: Env }>() return c.json({ error: "Empty query" }, 400); } - console.log("[chat] Generating embeddings and creating thread"); - const embedStart = performance.now(); // Run embedding generation and thread creation in parallel const [{ data: embedding }, thread] = await Promise.all([ c.env.AI.run("@cf/baai/bge-base-en-v1.5", { text: queryText }), @@ -123,7 +116,6 @@ const actions = new Hono<{ Variables: Variables; Bindings: Env }>() .returning() : null, ]); - console.log(`[chat] Embedding generation took ${performance.now() - embedStart}ms`); const threadUuid = threadId || thread?.[0].uuid; @@ -131,8 +123,6 @@ const actions = new Hono<{ Variables: Variables; Bindings: Env }>() return c.json({ error: "Failed to generate embedding" }, 500); } - console.log("[chat] Performing semantic search"); - const searchStart = performance.now(); // Perform semantic search const similarity = sql<number>`1 - (${cosineDistance(chunk.embeddings, embedding[0])})`; @@ -154,7 +144,6 @@ const actions = new Hono<{ Variables: Variables; Bindings: Env }>() .where(and(eq(documents.userId, user.id), sql`${similarity} > 0.4`)) .orderBy(desc(similarity)) .limit(5); - console.log(`[chat] Semantic search took ${performance.now() - searchStart}ms`); const cleanDocumentsForContext = finalResults.map((d) => ({ title: d.title, @@ -180,8 +169,6 @@ const actions = new Hono<{ Variables: Variables; Bindings: Env }>() } try { - console.log("[chat] Starting stream generation"); - const streamStart = performance.now(); const data = new StreamData(); // De-duplicate chunks by URL to avoid showing duplicate content const uniqueResults = finalResults.reduce((acc, current) => { @@ -237,8 +224,6 @@ const actions = new Hono<{ Variables: Variables; Bindings: Env }>() ], async onFinish(completion) { try { - console.log("[chat] Stream finished, updating thread"); - const updateStart = performance.now(); if (lastUserMessage) { lastUserMessage.content = typeof lastUserMessage.content === "string" @@ -272,15 +257,12 @@ const actions = new Hono<{ Variables: Variables; Bindings: Env }>() .set({ messages: newMessages }) .where(eq(chatThreads.uuid, threadUuid)); } - console.log(`[chat] Thread update took ${performance.now() - updateStart}ms`); } catch (error) { console.error("Failed to update thread:", error); } }, }); - console.log(`[chat] Stream generation took ${performance.now() - streamStart}ms`); - console.log(`[chat] Total request time: ${performance.now() - startTime}ms`); return result.toDataStreamResponse({ headers: { "Supermemory-Thread-Uuid": threadUuid ?? "", |