mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-04 22:02:16 +02:00
feat: add updateLLMConfigMutationAtom to llm-config mutations
This commit is contained in:
parent
2200d7b63c
commit
737169248e
1 changed files with 26 additions and 1 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
import { atomWithMutation } from "jotai-tanstack-query";
|
import { atomWithMutation } from "jotai-tanstack-query";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { activeSearchSpaceIdAtom } from "@/atoms/seach-spaces/seach-space-queries.atom";
|
import { activeSearchSpaceIdAtom } from "@/atoms/seach-spaces/seach-space-queries.atom";
|
||||||
import type { CreateLLMConfigRequest } from "@/contracts/types/llm-config.types";
|
import type { CreateLLMConfigRequest, UpdateLLMConfigRequest } from "@/contracts/types/llm-config.types";
|
||||||
import { llmConfigApiService } from "@/lib/apis/llm-config-api.service";
|
import { llmConfigApiService } from "@/lib/apis/llm-config-api.service";
|
||||||
import { cacheKeys } from "@/lib/query-client/cache-keys";
|
import { cacheKeys } from "@/lib/query-client/cache-keys";
|
||||||
import { queryClient } from "@/lib/query-client/client";
|
import { queryClient } from "@/lib/query-client/client";
|
||||||
|
|
@ -27,3 +27,28 @@ export const createLLMConfigMutationAtom = atomWithMutation((get) => {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const updateLLMConfigMutationAtom = atomWithMutation((get) => {
|
||||||
|
const searchSpaceId = get(activeSearchSpaceIdAtom);
|
||||||
|
|
||||||
|
return {
|
||||||
|
mutationKey: cacheKeys.llmConfigs.all(searchSpaceId!),
|
||||||
|
enabled: !!searchSpaceId,
|
||||||
|
mutationFn: async (request: UpdateLLMConfigRequest) => {
|
||||||
|
return llmConfigApiService.updateLLMConfig(request);
|
||||||
|
},
|
||||||
|
|
||||||
|
onSuccess: (_, request: UpdateLLMConfigRequest) => {
|
||||||
|
toast.success("LLM configuration updated successfully");
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: cacheKeys.llmConfigs.all(searchSpaceId!),
|
||||||
|
});
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: cacheKeys.llmConfigs.byId(String(request.id)),
|
||||||
|
});
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: cacheKeys.llmConfigs.global(),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue