mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-28 16:56:16 +08:00
feat(stream-check): enhance health check with configurable prompt and CLI-compatible requests (#623)
- Add configurable test prompt field to StreamCheckConfig - Implement Claude CLI-compatible request format with proper headers: - Authorization + x-api-key dual auth - anthropic-beta, anthropic-version headers - x-stainless-* SDK headers with dynamic OS/arch detection - URL with ?beta=true parameter - Implement Codex CLI-compatible Responses API format: - /v1/responses endpoint - input array format with reasoning effort support - codex_cli_rs user-agent and originator headers - Add dynamic OS name and CPU architecture detection - Internationalize error messages (Chinese -> English) - Add test prompt Textarea UI component with i18n support - Remove obsolete testPromptDesc translation key
This commit is contained in:
@@ -2,6 +2,7 @@ import { useState, useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||
import { Save, Loader2 } from "lucide-react";
|
||||
@@ -25,6 +26,7 @@ export function ModelTestConfigPanel() {
|
||||
claudeModel: "claude-haiku-4-5-20251001",
|
||||
codexModel: "gpt-5.1-codex@low",
|
||||
geminiModel: "gemini-3-pro-preview",
|
||||
testPrompt: "Who are you?",
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
@@ -43,6 +45,7 @@ export function ModelTestConfigPanel() {
|
||||
claudeModel: data.claudeModel,
|
||||
codexModel: data.codexModel,
|
||||
geminiModel: data.geminiModel,
|
||||
testPrompt: data.testPrompt || "Who are you?",
|
||||
});
|
||||
} catch (e) {
|
||||
setError(String(e));
|
||||
@@ -66,6 +69,7 @@ export function ModelTestConfigPanel() {
|
||||
claudeModel: config.claudeModel,
|
||||
codexModel: config.codexModel,
|
||||
geminiModel: config.geminiModel,
|
||||
testPrompt: config.testPrompt || "Who are you?",
|
||||
};
|
||||
await saveStreamCheckConfig(parsed);
|
||||
toast.success(t("streamCheck.configSaved"), {
|
||||
@@ -189,6 +193,21 @@ export function ModelTestConfigPanel() {
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 检查提示词配置 */}
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="testPrompt">{t("streamCheck.testPrompt")}</Label>
|
||||
<Textarea
|
||||
id="testPrompt"
|
||||
value={config.testPrompt}
|
||||
onChange={(e) =>
|
||||
setConfig({ ...config, testPrompt: e.target.value })
|
||||
}
|
||||
placeholder="Who are you?"
|
||||
rows={2}
|
||||
className="min-h-[60px]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-end">
|
||||
|
||||
@@ -1192,7 +1192,8 @@
|
||||
"checkParams": "Check Parameters",
|
||||
"timeout": "Timeout (seconds)",
|
||||
"maxRetries": "Max Retries",
|
||||
"degradedThreshold": "Degraded Threshold (ms)"
|
||||
"degradedThreshold": "Degraded Threshold (ms)",
|
||||
"testPrompt": "Test Prompt"
|
||||
},
|
||||
"proxyConfig": {
|
||||
"proxyEnabled": "Proxy Enabled",
|
||||
|
||||
@@ -1186,7 +1186,8 @@
|
||||
"checkParams": "チェックパラメーター",
|
||||
"timeout": "タイムアウト(秒)",
|
||||
"maxRetries": "最大リトライ回数",
|
||||
"degradedThreshold": "劣化しきい値(ミリ秒)"
|
||||
"degradedThreshold": "劣化しきい値(ミリ秒)",
|
||||
"testPrompt": "テストプロンプト"
|
||||
},
|
||||
"proxyConfig": {
|
||||
"proxyEnabled": "プロキシ有効",
|
||||
|
||||
@@ -1192,7 +1192,8 @@
|
||||
"checkParams": "检查参数",
|
||||
"timeout": "超时时间(秒)",
|
||||
"maxRetries": "最大重试次数",
|
||||
"degradedThreshold": "降级阈值(毫秒)"
|
||||
"degradedThreshold": "降级阈值(毫秒)",
|
||||
"testPrompt": "检查提示词"
|
||||
},
|
||||
"proxyConfig": {
|
||||
"proxyEnabled": "代理总开关",
|
||||
|
||||
@@ -12,6 +12,7 @@ export interface StreamCheckConfig {
|
||||
claudeModel: string;
|
||||
codexModel: string;
|
||||
geminiModel: string;
|
||||
testPrompt: string;
|
||||
}
|
||||
|
||||
export interface StreamCheckResult {
|
||||
|
||||
Reference in New Issue
Block a user