From 778ddec27edcf313bfee6e5ad91312a752fb1b73 Mon Sep 17 00:00:00 2001 From: Dhravya Date: Wed, 12 Jun 2024 19:33:02 -0500 Subject: [PATCH] fix backend --- apps/cf-ai-backend/src/index.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/cf-ai-backend/src/index.ts b/apps/cf-ai-backend/src/index.ts index 1e128bbd..b79d86a6 100644 --- a/apps/cf-ai-backend/src/index.ts +++ b/apps/cf-ai-backend/src/index.ts @@ -88,8 +88,8 @@ app.post( "query", z.object({ query: z.string(), - topK: z.number().optional().default(10), user: z.string(), + topK: z.number().optional().default(10), spaces: z.string().optional(), sourcesOnly: z.string().optional().default("false"), model: z.string().optional().default("gpt-4o"), @@ -103,12 +103,18 @@ app.post( if (body.chatHistory) { body.chatHistory = body.chatHistory.map((i) => ({ ...i, - content: i.parts.length > 0 ? i.parts.join(" ") : i.content, + content: i.parts + ? i.parts.length > 0 + ? i.parts.join(" ") + : i.content + : i.content, })); } const sourcesOnly = query.sourcesOnly === "true"; - const spaces = query.spaces?.split(",") || [undefined]; + 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);