From afd14a5dcdea26b98463dc8d643dabc9a4a16255 Mon Sep 17 00:00:00 2001 From: Dhravya Date: Mon, 8 Apr 2024 18:39:32 -0700 Subject: messages streaminug --- apps/web/src/app/api/chat/route.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'apps/web/src/app/api') diff --git a/apps/web/src/app/api/chat/route.ts b/apps/web/src/app/api/chat/route.ts index 2cb03186..ef59fd43 100644 --- a/apps/web/src/app/api/chat/route.ts +++ b/apps/web/src/app/api/chat/route.ts @@ -31,22 +31,25 @@ export async function POST(req: NextRequest) { chatHistory: ChatHistory[] }; + console.log("CHathistory", chatHistory) if (!query) { return new Response(JSON.stringify({ message: "Invalid query" }), { status: 400 }); } + const resp = await fetch(`https://cf-ai-backend.dhravya.workers.dev/chat?q=${query}&user=${session.user.email ?? session.user.name}&sourcesOnly=${sourcesOnly}`, { headers: { "X-Custom-Auth-Key": env.BACKEND_SECURITY_KEY, }, method: "POST", body: JSON.stringify({ - chatHistory + chatHistory: chatHistory.chatHistory ?? [] }) }) console.log(resp.status) + console.log(resp.statusText) if (resp.status !== 200 || !resp.ok) { const errorData = await resp.json(); -- cgit v1.2.3