From e08eb50775e46ed98014ede6ffe675ecbdc9f090 Mon Sep 17 00:00:00 2001 From: john Date: Tue, 21 Jul 2026 17:01:42 +0800 Subject: [PATCH] feat: harden provider setup validation --- src/admin/pages/ProvidersPage.tsx | 64 ++++++++++++++++++++++++++++--- src/index.css | 7 ++++ 2 files changed, 66 insertions(+), 5 deletions(-) diff --git a/src/admin/pages/ProvidersPage.tsx b/src/admin/pages/ProvidersPage.tsx index ab92fbd..8e355c6 100644 --- a/src/admin/pages/ProvidersPage.tsx +++ b/src/admin/pages/ProvidersPage.tsx @@ -19,6 +19,7 @@ import { setLlmVisionKey, stopLlmExecutor, syncLlmProviderToGoosed, + testLlmProviderDraft, testLlmProviderKey, updateLlmProviderKey, } from '../../api/client'; @@ -34,6 +35,11 @@ import type { } from '../../types'; const CUSTOM_PROVIDER_ID = '__custom__'; +const KIMI_DIRECT_PRESET = { + apiUrl: 'https://api.moonshot.cn/v1', + modelsText: 'kimi-k3\nkimi-k2.6', + defaultModel: 'kimi-k3', +}; const EXECUTOR_VISUALS: Record = { goose: { icon: 'G', accent: 'blue' }, @@ -62,6 +68,14 @@ function parseModelsText(text: string) { return [...new Set(text.split(/[\n,]/).map((item) => item.trim()).filter(Boolean))]; } +function formatProviderConnectionError(message?: string) { + const detail = String(message ?? '未知错误').trim(); + if (/not found the model|permission denied|resource_not_found_error/i.test(detail)) { + return `模型不存在或当前 API Key 没有该模型权限,请检查模型 ID。上游响应:${detail}`; + } + return detail; +} + function statusText(status?: LlmExecutorLaunchState | null) { if (!status) return '未启动'; if (status.running) return `运行中${status.pid ? ` · pid ${status.pid}` : ''}`; @@ -170,6 +184,24 @@ function ProviderDialog({ {isCustom ? ( <> +
+ + 自动填写官方 API 地址和模型 ID;直连 Moonshot 时 Relay Provider 必须留空。 +