From 3a65277e8b518b66f4ade3ef47e96849c2539dc6 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Wed, 10 Dec 2025 09:39:58 +0000 Subject: [PATCH] feat(llm-config): add llmPreferencesAtom query atom for fetching LLM preferences --- .../atoms/llm-config/llm-config-query.atoms.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/surfsense_web/atoms/llm-config/llm-config-query.atoms.ts b/surfsense_web/atoms/llm-config/llm-config-query.atoms.ts index 463e36fa8..0b2902f54 100644 --- a/surfsense_web/atoms/llm-config/llm-config-query.atoms.ts +++ b/surfsense_web/atoms/llm-config/llm-config-query.atoms.ts @@ -29,3 +29,18 @@ export const globalLLMConfigsAtom = atomWithQuery(() => { }, }; }); + +export const llmPreferencesAtom = atomWithQuery((get) => { + const searchSpaceId = get(activeSearchSpaceIdAtom); + + return { + queryKey: cacheKeys.llmConfigs.preferences(String(searchSpaceId)), + enabled: !!searchSpaceId, + staleTime: 5 * 60 * 1000, // 5 minutes + queryFn: async () => { + return llmConfigApiService.getLLMPreferences({ + search_space_id: Number(searchSpaceId), + }); + }, + }; +});