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), + }); + }, + }; +});