diff --git a/surfsense_web/components/chat/ChatInputGroup.tsx b/surfsense_web/components/chat/ChatInputGroup.tsx index 543e83434..23246cba0 100644 --- a/surfsense_web/components/chat/ChatInputGroup.tsx +++ b/surfsense_web/components/chat/ChatInputGroup.tsx @@ -28,10 +28,10 @@ import { import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"; import { getConnectorIcon } from "@/contracts/enums/connectorIcons"; import { Document } from "@/contracts/types/document.types"; -import { useLLMPreferences } from "@/hooks/use-llm-configs"; import { useSearchSourceConnectors } from "@/hooks/use-search-source-connectors"; import { useAtomValue } from "jotai"; -import { llmConfigsAtom, globalLLMConfigsAtom } from "@/atoms/llm-config/llm-config-query.atoms"; +import { llmConfigsAtom, globalLLMConfigsAtom, llmPreferencesAtom } from "@/atoms/llm-config/llm-config-query.atoms"; +import { updateLLMPreferencesMutationAtom } from "@/atoms/llm-config/llm-config-mutation.atoms"; const DocumentSelector = React.memo( ({ @@ -543,11 +543,10 @@ const LLMSelector = React.memo(() => { const { data: llmConfigs = [], isFetching: llmLoading, isError: error } = useAtomValue(llmConfigsAtom); const { data: globalConfigs = [], isFetching: globalConfigsLoading, isError: globalConfigsError } = useAtomValue(globalLLMConfigsAtom); - const { - preferences, - updatePreferences, - loading: preferencesLoading, - } = useLLMPreferences(searchSpaceId); + + // Replace useLLMPreferences with jotai atoms + const { data: preferences = {}, isFetching: preferencesLoading } = useAtomValue(llmPreferencesAtom); + const { mutateAsync: updatePreferences } = useAtomValue(updateLLMPreferencesMutationAtom); const isLoading = llmLoading || preferencesLoading || globalConfigsLoading; @@ -580,9 +579,12 @@ const LLMSelector = React.memo(() => { const handleValueChange = React.useCallback( (value: string) => { const llmId = value ? parseInt(value, 10) : undefined; - updatePreferences({ fast_llm_id: llmId }); + updatePreferences({ + search_space_id: searchSpaceId, + data: { fast_llm_id: llmId } + }); }, - [updatePreferences] + [updatePreferences, searchSpaceId] ); // Loading skeleton