diff --git a/docs/chinese-llm-setup.md b/docs/chinese-llm-setup.md index 37042aa2f..1fb0ce2a1 100644 --- a/docs/chinese-llm-setup.md +++ b/docs/chinese-llm-setup.md @@ -24,7 +24,7 @@ SurfSense 现已支持以下国产 LLM: 1. 登录 SurfSense Dashboard 2. 进入 **Settings** → **API Keys** (或 **LLM Configurations**) -3. 点击 **Add New Configuration** +3. 点击 **Add LLM Model** 4. 从 **Provider** 下拉菜单中选择你的国产 LLM 提供商 5. 填写必填字段(见下方各提供商详细配置) 6. 点击 **Save** diff --git a/surfsense_web/atoms/new-llm-config/new-llm-config-mutation.atoms.ts b/surfsense_web/atoms/new-llm-config/new-llm-config-mutation.atoms.ts index b3b9b2bab..00156b844 100644 --- a/surfsense_web/atoms/new-llm-config/new-llm-config-mutation.atoms.ts +++ b/surfsense_web/atoms/new-llm-config/new-llm-config-mutation.atoms.ts @@ -2,7 +2,9 @@ import { atomWithMutation } from "jotai-tanstack-query"; import { toast } from "sonner"; import type { CreateNewLLMConfigRequest, + CreateNewLLMConfigResponse, DeleteNewLLMConfigRequest, + DeleteNewLLMConfigResponse, GetNewLLMConfigsResponse, UpdateLLMPreferencesRequest, UpdateNewLLMConfigRequest, @@ -25,14 +27,14 @@ export const createNewLLMConfigMutationAtom = atomWithMutation((get) => { mutationFn: async (request: CreateNewLLMConfigRequest) => { return newLLMConfigApiService.createConfig(request); }, - onSuccess: () => { - toast.success("LLM model created"); + onSuccess: (_: CreateNewLLMConfigResponse, request: CreateNewLLMConfigRequest) => { + toast.success(`${request.name} created`); queryClient.invalidateQueries({ queryKey: cacheKeys.newLLMConfigs.all(Number(searchSpaceId)), }); }, onError: (error: Error) => { - toast.error(error.message || "Failed to create configuration"); + toast.error(error.message || "Failed to create LLM model"); }, }; }); @@ -50,7 +52,7 @@ export const updateNewLLMConfigMutationAtom = atomWithMutation((get) => { return newLLMConfigApiService.updateConfig(request); }, onSuccess: (_: UpdateNewLLMConfigResponse, request: UpdateNewLLMConfigRequest) => { - toast.success("LLM model updated"); + toast.success(`${request.data.name ?? "Configuration"} updated`); queryClient.invalidateQueries({ queryKey: cacheKeys.newLLMConfigs.all(Number(searchSpaceId)), }); @@ -59,7 +61,7 @@ export const updateNewLLMConfigMutationAtom = atomWithMutation((get) => { }); }, onError: (error: Error) => { - toast.error(error.message || "Failed to update configuration"); + toast.error(error.message || "Failed to update"); }, }; }); @@ -73,11 +75,11 @@ export const deleteNewLLMConfigMutationAtom = atomWithMutation((get) => { return { mutationKey: ["new-llm-configs", "delete"], enabled: !!searchSpaceId, - mutationFn: async (request: DeleteNewLLMConfigRequest) => { - return newLLMConfigApiService.deleteConfig(request); + mutationFn: async (request: DeleteNewLLMConfigRequest & { name: string }) => { + return newLLMConfigApiService.deleteConfig({ id: request.id }); }, - onSuccess: (_, request: DeleteNewLLMConfigRequest) => { - toast.success("LLM model deleted"); + onSuccess: (_: DeleteNewLLMConfigResponse, request: DeleteNewLLMConfigRequest & { name: string }) => { + toast.success(`${request.name} deleted`); queryClient.setQueryData( cacheKeys.newLLMConfigs.all(Number(searchSpaceId)), (oldData: GetNewLLMConfigsResponse | undefined) => { @@ -87,7 +89,7 @@ export const deleteNewLLMConfigMutationAtom = atomWithMutation((get) => { ); }, onError: (error: Error) => { - toast.error(error.message || "Failed to delete configuration"); + toast.error(error.message || "Failed to delete"); }, }; }); diff --git a/surfsense_web/components/settings/model-config-manager.tsx b/surfsense_web/components/settings/model-config-manager.tsx index a20086492..409aa4f3c 100644 --- a/surfsense_web/components/settings/model-config-manager.tsx +++ b/surfsense_web/components/settings/model-config-manager.tsx @@ -116,7 +116,7 @@ export function ModelConfigManager({ searchSpaceId }: ModelConfigManagerProps) { const handleDelete = async () => { if (!configToDelete) return; try { - await deleteConfig({ id: configToDelete.id }); + await deleteConfig({ id: configToDelete.id, name: configToDelete.name }); setConfigToDelete(null); } catch { // Error handled by mutation state @@ -431,12 +431,11 @@ export function ModelConfigManager({ searchSpaceId }: ModelConfigManagerProps) { open={!!configToDelete} onOpenChange={(open) => !open && setConfigToDelete(null)} > - + - - - Delete Configuration - + + Delete LLM Model + Are you sure you want to delete{" "} {configToDelete?.name}? This @@ -450,17 +449,14 @@ export function ModelConfigManager({ searchSpaceId }: ModelConfigManagerProps) { disabled={isDeleting} className="bg-destructive text-destructive-foreground hover:bg-destructive/90" > - {isDeleting ? ( - <> - - Deleting - - ) : ( - <> - - Delete - - )} + {isDeleting ? ( + <> + + Deleting + + ) : ( + "Delete" + )} diff --git a/surfsense_web/components/shared/model-config-dialog.tsx b/surfsense_web/components/shared/model-config-dialog.tsx index 4dff5f173..f786ee2c1 100644 --- a/surfsense_web/components/shared/model-config-dialog.tsx +++ b/surfsense_web/components/shared/model-config-dialog.tsx @@ -379,39 +379,35 @@ export function ModelConfigDialog({ Cancel {mode === "create" || (!isGlobal && !isAutoMode && config) ? ( - + ) : isAutoMode ? ( - + ) : isGlobal && config ? ( - + ) : null}