diff --git a/surfsense_web/app/dashboard/[search_space_id]/researcher/[[...chat_id]]/page.tsx b/surfsense_web/app/dashboard/[search_space_id]/researcher/[[...chat_id]]/page.tsx index 558b8b962..7481ddaa2 100644 --- a/surfsense_web/app/dashboard/[search_space_id]/researcher/[[...chat_id]]/page.tsx +++ b/surfsense_web/app/dashboard/[search_space_id]/researcher/[[...chat_id]]/page.tsx @@ -8,7 +8,7 @@ import { createChatMutationAtom, updateChatMutationAtom } from "@/atoms/chats/ch import { activeChatAtom } from "@/atoms/chats/chat-query.atoms"; import { activeChatIdAtom } from "@/atoms/chats/ui.atoms"; import ChatInterface from "@/components/chat/ChatInterface"; -import { useChatAPI, useChatState } from "@/hooks/use-chat"; +import { useChatState } from "@/hooks/use-chat"; import { useDocumentTypes } from "@/hooks/use-document-types"; import type { Document } from "@/hooks/use-documents"; import { useSearchSourceConnectors } from "@/hooks/use-search-source-connectors"; @@ -44,11 +44,6 @@ export default function ResearcherPage() { chat_id: activeChatId ?? undefined, }); - // const { updateChat } = useChatAPI({ - // token, - // search_space_id: search_space_id as string, - // }); - // Fetch all available sources (document types + live search connectors) const { documentTypes } = useDocumentTypes(Number(search_space_id)); const { connectors: searchConnectors } = useSearchSourceConnectors( diff --git a/surfsense_web/hooks/use-chat.ts b/surfsense_web/hooks/use-chat.ts index 4f183e13a..7424c7aea 100644 --- a/surfsense_web/hooks/use-chat.ts +++ b/surfsense_web/hooks/use-chat.ts @@ -45,57 +45,3 @@ export function useChatState({ chat_id }: UseChatStateProps) { setTopK, }; } - -interface UseChatAPIProps { - token: string | null; - search_space_id: string; -} - -export function useChatAPI({ token, search_space_id }: UseChatAPIProps) { - const updateChat = useCallback( - async ( - chatId: string, - messages: Message[], - researchMode: ResearchMode, - selectedConnectors: string[] - ) => { - if (!token) return; - - try { - const userMessages = messages.filter((msg) => msg.role === "user"); - if (userMessages.length === 0) return; - - const title = userMessages[0].content; - - const response = await fetch( - `${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/chats/${Number(chatId)}`, - { - method: "PUT", - headers: { - "Content-Type": "application/json", - Authorization: `Bearer ${token}`, - }, - body: JSON.stringify({ - type: researchMode, - title: title, - initial_connectors: selectedConnectors, - messages: messages, - search_space_id: Number(search_space_id), - }), - } - ); - - if (!response.ok) { - throw new Error(`Failed to update chat: ${response.statusText}`); - } - } catch (err) { - console.error("Error updating chat:", err); - } - }, - [token, search_space_id] - ); - - return { - updateChat, - }; -}