diff options
| author | Dhravya <[email protected]> | 2024-06-23 17:54:05 -0500 |
|---|---|---|
| committer | Dhravya <[email protected]> | 2024-06-23 17:54:05 -0500 |
| commit | 9f751ba89cc37516daa261bbae8723d5566a6602 (patch) | |
| tree | 3e7533aefbf7931c966c930349263ae248cc1135 /apps/web/app/(dash) | |
| parent | added indexes and stuff (diff) | |
| download | supermemory-9f751ba89cc37516daa261bbae8723d5566a6602.tar.xz supermemory-9f751ba89cc37516daa261bbae8723d5566a6602.zip | |
feat: vector lookup and chat is twice as fast now
Diffstat (limited to 'apps/web/app/(dash)')
| -rw-r--r-- | apps/web/app/(dash)/chat/chatWindow.tsx | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/apps/web/app/(dash)/chat/chatWindow.tsx b/apps/web/app/(dash)/chat/chatWindow.tsx index 8485d0b2..9a18cfe7 100644 --- a/apps/web/app/(dash)/chat/chatWindow.tsx +++ b/apps/web/app/(dash)/chat/chatWindow.tsx @@ -6,7 +6,7 @@ import QueryInput from "../home/queryinput"; import { cn } from "@repo/ui/lib/utils"; import { motion } from "framer-motion"; import { useRouter } from "next/navigation"; -import { ChatHistory } from "@repo/shared-types"; +import { ChatHistory, sourcesZod } from "@repo/shared-types"; import { Accordion, AccordionContent, @@ -20,15 +20,10 @@ import rehypeKatex from "rehype-katex"; import rehypeHighlight from "rehype-highlight"; import { code, p } from "./markdownRenderHelpers"; import { codeLanguageSubset } from "@/lib/constants"; -import { z } from "zod"; import { toast } from "sonner"; import Link from "next/link"; import { createChatObject } from "@/app/actions/doers"; -import { - ClipboardIcon, - ShareIcon, - SpeakerWaveIcon, -} from "@heroicons/react/24/outline"; +import { ClipboardIcon } from "@heroicons/react/24/outline"; import { SendIcon } from "lucide-react"; function ChatWindow({ @@ -83,11 +78,6 @@ function ChatWindow({ // TODO: handle this properly const sources = await sourcesFetch.json(); - const sourcesZod = z.object({ - ids: z.array(z.string()), - metadata: z.array(z.any()), - }); - const sourcesParsed = sourcesZod.safeParse(sources); if (!sourcesParsed.success) { @@ -100,7 +90,6 @@ function ChatWindow({ behavior: "smooth", }); - // Assuming this is part of a larger function within a React component const updateChatHistoryAndFetch = async () => { // Step 1: Update chat history with the assistant's response await new Promise((resolve) => { @@ -143,7 +132,7 @@ function ChatWindow({ `/api/chat?q=${query}&spaces=${spaces}&threadId=${threadId}`, { method: "POST", - body: JSON.stringify({ chatHistory }), + body: JSON.stringify({ chatHistory, sources: sourcesParsed.data }), }, ); |