diff --git a/surfsense_web/components/settings/llm-role-manager.tsx b/surfsense_web/components/settings/llm-role-manager.tsx
index 601dbf65e..92d2e6f16 100644
--- a/surfsense_web/components/settings/llm-role-manager.tsx
+++ b/surfsense_web/components/settings/llm-role-manager.tsx
@@ -27,10 +27,11 @@ import {
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
-import { useLLMPreferences } from "@/hooks/use-llm-configs";
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 ROLE_DESCRIPTIONS = {
long_context: {
icon: Brain,
@@ -76,12 +77,13 @@ export function LLMRoleManager({ searchSpaceId }: LLMRoleManagerProps) {
refetch: refreshGlobalConfigs,
} = useAtomValue(globalLLMConfigsAtom);
const {
- preferences,
- loading: preferencesLoading,
+ data: preferences = {},
+ isFetching: preferencesLoading,
error: preferencesError,
- updatePreferences,
- refreshPreferences,
- } = useLLMPreferences(searchSpaceId);
+ refetch: refreshPreferences,
+ } = useAtomValue(llmPreferencesAtom);
+
+ const { mutateAsync: updatePreferences } = useAtomValue(updateLLMPreferencesMutationAtom);
const [assignments, setAssignments] = useState({
long_context_llm_id: preferences.long_context_llm_id || "",
@@ -148,14 +150,15 @@ export function LLMRoleManager({ searchSpaceId }: LLMRoleManagerProps) {
? parseInt(assignments.strategic_llm_id)
: undefined
: assignments.strategic_llm_id,
- };
+ };
- const success = await updatePreferences(numericAssignments);
+ await updatePreferences({
+ search_space_id: searchSpaceId,
+ data: numericAssignments
+ });
- if (success) {
- setHasChanges(false);
- toast.success("LLM role assignments saved successfully!");
- }
+ setHasChanges(false);
+ toast.success("LLM role assignments saved successfully!");
setIsSaving(false);
};
@@ -214,12 +217,12 @@ export function LLMRoleManager({ searchSpaceId }: LLMRoleManagerProps) {
Configs