mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-26 17:26:23 +02:00
feat: add updateLLMPreferencesMutationAtom to handle LLM preferences updates
This commit is contained in:
parent
1aa10db910
commit
0c0491cd49
1 changed files with 20 additions and 0 deletions
|
|
@ -6,6 +6,7 @@ import type {
|
|||
UpdateLLMConfigRequest,
|
||||
DeleteLLMConfigRequest,
|
||||
GetLLMConfigsResponse,
|
||||
UpdateLLMPreferencesRequest,
|
||||
} from "@/contracts/types/llm-config.types";
|
||||
import { llmConfigApiService } from "@/lib/apis/llm-config-api.service";
|
||||
import { cacheKeys } from "@/lib/query-client/cache-keys";
|
||||
|
|
@ -91,3 +92,22 @@ export const deleteLLMConfigMutationAtom = atomWithMutation((get) => {
|
|||
},
|
||||
};
|
||||
});
|
||||
|
||||
export const updateLLMPreferencesMutationAtom = atomWithMutation((get) => {
|
||||
const searchSpaceId = get(activeSearchSpaceIdAtom);
|
||||
|
||||
return {
|
||||
mutationKey: cacheKeys.llmConfigs.preferences(searchSpaceId!),
|
||||
enabled: !!searchSpaceId,
|
||||
mutationFn: async (request: UpdateLLMPreferencesRequest) => {
|
||||
return llmConfigApiService.updateLLMPreferences(request);
|
||||
},
|
||||
|
||||
onSuccess: () => {
|
||||
toast.success("LLM preferences updated successfully");
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: cacheKeys.llmConfigs.preferences(searchSpaceId!),
|
||||
});
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue