From 586e4d0da8ad655782e78173007acde1b2640eb3 Mon Sep 17 00:00:00 2001 From: bracesproul Date: Wed, 5 Mar 2025 15:28:53 -0800 Subject: [PATCH] del old thread hook --- src/hooks/useThreads.tsx | 46 ---------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 src/hooks/useThreads.tsx diff --git a/src/hooks/useThreads.tsx b/src/hooks/useThreads.tsx deleted file mode 100644 index d706b94..0000000 --- a/src/hooks/useThreads.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import { validate } from "uuid"; -import { getApiKey } from "@/lib/api-key"; -import { Client, Thread } from "@langchain/langgraph-sdk"; -import { useQueryParam, StringParam } from "use-query-params"; - -function createClient(apiUrl: string, apiKey: string | undefined) { - return new Client({ - apiKey, - apiUrl, - }); -} - -function getThreadSearchMetadata( - assistantId: string, -): { graph_id: string } | { assistant_id: string } { - // Assume if the ID is a UUID, it's an assistant ID. Otherwise, it's a graph ID. - if (validate(assistantId)) { - return { assistant_id: assistantId }; - } else { - return { graph_id: assistantId }; - } -} - -export function useThreads() { - const [apiUrl] = useQueryParam("apiUrl", StringParam); - const [assistantId] = useQueryParam("assistantId", StringParam); - - const getThreads = async (): Promise => { - if (!apiUrl || !assistantId) return []; - - const client = createClient(apiUrl, getApiKey() ?? undefined); - - const threads = await client.threads.search({ - metadata: { - ...getThreadSearchMetadata(assistantId), - }, - limit: 100, - }); - - return threads; - }; - - return { - getThreads, - }; -}