第二十七轮: 三线直传(/v1/messages,/v1/responses)+删除路由别名;第二十八轮: element-plus 按需引入+死代码清理+前端支持格式列/API Key 文档

This commit is contained in:
api-gateway committed 2026-09-18 16:33:33 +08:00
1 parent 1b54802ad3
commit 4c1973b13d
28 files changed
+3016 -1263

No files matched your search

+1 -2
View File
@@ -7,7 +7,6 @@ export interface Meta {
served: string
provider: string
requested: string
fallback: boolean
}
export interface Usage {
@@ -25,7 +24,7 @@ export interface ChatMessage {
imgThumbs?: string[] // 第十三轮:缩略图 data URI —— 落服务端历史时用它替代原图
// (服务端单条 512KB,原图 base64 会被截断成坏图)
reasoning?: string // 推理内容(reasoning_content),单独折叠展示
meta?: Meta // 网关元信息(served/provider/fallback)
meta?: Meta // 网关元信息(served/provider)
usage?: Usage
cost?: number // estimated_cost_cny(仅非流式)
streaming?: boolean // 正在流式输出中
+40 -47
View File
@@ -19,10 +19,10 @@ export default {
control: 'Console',
more: 'More',
subdashboard: 'Gateway overview · refreshed every 8s',
subchat: 'Vision-ready · route wjd picks the fastest provider',
subchat: 'Vision-ready · multi-provider direct routing',
subimages: 'Params on the left, history on the right · downloads proxied by the gateway',
subvideos: '720P · 4–12s · async polling',
submodels: 'Providers / models / route chains',
submodels: 'Providers / models / protocol lines',
submetrics: 'Usage & cost · isolated per account',
subkeys: 'Up to 3 per account · stored in plaintext, copyable anytime',
subusers: 'Accounts & roles · admin can inspect others’ logs and assets',
@@ -86,8 +86,6 @@ export default {
dashboard: {
modelCount: 'Models',
providers: 'Providers',
routes: 'Route aliases',
fallback: 'Fallbacks',
inflight: 'In-flight',
callsMix: 'Calls ok/fail',
provShare: 'Provider success share',
@@ -97,7 +95,6 @@ export default {
circuit: 'Circuit',
modelCountShort: 'Models',
keySet: 'Key set',
routeAlias: 'Route aliases',
name: 'Name',
modelChain: 'Model chain',
gatewayInfo: 'Gateway info',
@@ -114,7 +111,6 @@ export default {
requests: 'Total requests',
successRate: 'Success rate',
avgLatency: 'Avg latency',
fallbackShort: 'Fallbacks',
noteOkFail: 'ok {ok} · fail {fail}',
noteFail: '{n} failed',
noteP95: 'highest P95 {v}s',
@@ -127,22 +123,21 @@ export default {
noModels: 'No calls recorded yet',
share: 'Share',
live: 'Live',
routeChain: 'Availability + speed first',
byProtocol: 'Protocol lines',
byProtocolSub: 'Models per line',
modelCountN: '{n} models',
},
metrics: {
uptime: 'Uptime',
inflight: 'In-flight/peak',
fallback: 'Fallbacks',
promptTokens: 'Prompt tokens',
completionTokens: 'Completion tokens',
callsTotal: 'Total calls (ok/fail)',
modelCalls: 'Calls per model (success / fail)',
provShare: 'Provider success share',
routeVsProvider: 'Route vs provider (success / fail / fallback)',
latency: 'Model latency P50 / P95 (s)',
success: 'Success',
fail: 'Fail',
fallback2: 'Fallback',
ok: 'ok',
none: 'None',
circuitStatus: 'Circuit breaker status',
@@ -165,6 +160,7 @@ export default {
failRateNote: 'failure rate {v}%',
snapshot: 'Live snapshot',
circuitCard: 'Circuit breakers',
byProvider: 'Calls by provider (success / fail)',
},
logs: {
all: 'All',
@@ -226,20 +222,17 @@ export default {
systemShort: 'System',
visionReady: 'Vision ready · images supported',
visionOff: 'This model does not accept images',
chainLabel: '{id} ({chain})',
emptyChain: 'empty',
phDefault: 'Default',
phOptional: 'Optional',
totalTokens: 'Total {n}',
uploadedImage: 'Uploaded image',
reasoningTag: 'Reasoning',
routeGroup: 'Routes (auto fallback)',
textModels: 'Text models',
params: 'Parameters',
clear: 'Clear',
generating: 'Generating…',
empty: 'Start a conversation with the gateway (any text model or route wjd)',
fallback: 'Fallback · by {provider}',
empty: 'Start a conversation with the gateway (pick a model below)',
servedBy: 'by {provider}',
requestedTo: 'requested {req} → served {served}',
reasoning: 'Reasoning',
@@ -266,6 +259,7 @@ export default {
streaming: 'Streaming output',
system: 'System prompt (prepended to each conversation)',
loadModelsErr: 'Failed to load models: {msg}',
pickModel: 'Pick a model',
},
images: {
historyTitle: 'History',
@@ -363,10 +357,8 @@ export default {
loadErr: 'Failed to load videos',
},
models: {
routeAliasTitle: 'Route aliases (auto fallback chain)',
modelListTitle: 'Model list',
name: 'Name',
chainLabel: 'Model chain (tried in order, auto fallback on failure)',
providerCount: 'Providers',
id: 'Model ID',
type: 'Type',
@@ -375,12 +367,10 @@ export default {
text: 'Text',
image: 'Image',
video: 'Video',
route: 'Route',
model: 'Models',
textModels: 'Text models',
imageModels: 'Image models',
videoModels: 'Video models',
routes: 'Route aliases',
providers: 'Providers',
loadErr: 'Failed to load models',
capability: 'Capability',
@@ -391,10 +381,8 @@ export default {
providerCard: 'Providers',
keyOk: 'Key configured',
keyMissing: 'Key missing',
routeCount: '{n} routes',
chainCount: '{n} models',
providerCount2: '{n} providers',
noRoute: 'No route alias configured',
speedtest: 'Test speed',
testing: 'Probing latency of every text model…',
testingShort: 'Testing…',
@@ -403,6 +391,16 @@ export default {
failed: 'Failed',
speedtestDone: 'Speed test done, {n} models',
speedtestFail: 'Speed test failed',
speedtestHint: 'Latency probed per protocol line',
textModelCount: '{n} text models',
// Round 27: the supported-formats column (three protocol lines). Line names are the
// vendors' own endpoint names, so they are not translated.
protocols: 'Supported formats',
protocolHint: 'Which lines this model accepts: chat/completions (OpenAI-compatible), messages (Anthropic), responses (OpenAI Responses). Any other format is rejected with 400 at the gateway edge — the gateway never translates between formats and never silently swaps in another model',
protocolNa: 'N/A',
protocolNaHint: 'Image / video models use the dedicated /v1/images/generations and /v1/videos endpoints and are not tied to the three protocol lines',
protocolHintRow: 'Supported formats: {lines} ',
probedLine: 'probed via {p}',
},
history: {
saveFail: 'History could not be saved to the gateway (it may be lost on refresh) — check your session or network',
@@ -435,7 +433,7 @@ export default {
logoutBtn: 'Sign out',
chatDefaults: 'Chat default parameters',
defsTip: 'Used as defaults for a new chat (already-adjusted params are untouched).',
defaultModel: 'Default model / route',
defaultModel: 'Default model',
temperature: 'Temperature',
topP: 'top_p',
maxTokens: 'max_tokens (empty = gateway default)',
@@ -448,7 +446,7 @@ export default {
modelsCount: 'Models',
userManagement: 'Account management (admin)',
gwConfigBtn: 'Open',
gwConfigSub: 'Tune gateway / providers / routes / pricing — applied on save',
gwConfigSub: 'Tune gateway / providers / pricing — applied on save',
gwConfig: 'Gateway config (admin)',
userCol: 'User',
roleCol: 'Role',
@@ -504,38 +502,50 @@ export default {
auth: 'Auth',
authVal: 'Header: Authorization: Bearer <your API Key>',
modelPick: 'Model selection',
modelPickVal: 'model: wjd = route alias (auto-fallback by availability + speed, recommended); or a concrete model id to bypass fallback',
modelPickVal: 'model takes a real model id (e.g. agnes-3.0-flash). Each of the three lines forwards its own native protocol and the gateway never translates formats, so a wrong line returns 400 (listing the lines that model supports)',
formats: 'Supported formats',
formatsVal: 'Which lines a model accepts is listed in the Supported formats column on the Providers & Models page: chat/completions, messages, responses. Each line is forwarded verbatim (no field rewriting, no cross-format translation), so write your URL and body exactly as the vendor SDK expects',
ctype: 'Request format',
ctypeVal: 'application/json; chat supports SSE streaming (stream: true)',
endpoints: 'Endpoints',
colMethod: 'Method',
colPath: 'Path',
colDesc: 'Description',
epModels: 'Models and routes (with a vision flag)',
epModels: 'Models (with vision flag and supported protocol lines)',
epChat: 'Chat completions (OpenAI compatible, streaming + image input)',
epMessages: 'Chat completions (Anthropic Messages format, forwarded verbatim)',
epResponses: 'Chat completions (OpenAI Responses format, forwarded verbatim)',
epImages: 'Image generation / image-to-image (n must be 1; call repeatedly for more)',
epVideoCreate: 'Video generation (async, returns video_id immediately)',
epVideoPoll: 'Poll a video task (every ~5s; returns throttled when upstream rate-limits)',
epDownload: 'Download generated images / videos through the gateway (bypasses upstream hotlink protection and expiry; allow-listed hosts only)',
epHistory: 'Read your own history (images / videos / chats)',
epLogs: 'Your own call log',
epMetrics: 'Metrics snapshot (incl. circuit breaker states)',
epHealth: 'Health check (version / provider status)',
exChat: 'Example · chat',
exMessages: 'Example · chat (Anthropic Messages format)',
exResponses: 'Example · chat (OpenAI Responses format)',
exImg: 'Example · image generation',
exVideo: 'Example · video generation + polling',
exPy: 'Example · Python (OpenAI SDK compatible)',
// Comments / sample payloads inside the code samples (mirror of zh.ts)
sampleChat: 'Hello, introduce yourself',
sampleModelMessages: 'minimax-m2.7',
sampleModelResponses: 'grok-4.6',
sampleImg: 'Neon city street at night',
sampleVideo: 'Slow camera push-in',
sampleStep1: 'submit a task (async, returns video_id immediately)',
sampleStep2: 'poll every 5s (a throttled reply means wait, then retry)',
notes: 'Notes',
noteVision: 'For image input use a vision model (agnes-3.0-flash, marked "Vision" in the list); with the wjd alias the gateway puts vision models first.',
noteVision: 'For image input use a vision model (agnes-3.0-flash, marked Vision in the list). The gateway no longer swaps models for you: a non-vision model receives the request as-is',
noteCross: 'No cross-format translation: which lines a model accepts is decided by the Supported formats column on the Providers & Models page (e.g. minimax-m2.7 only speaks messages, grok-4.6 only speaks responses). A wrong format is rejected with 400 at the gateway edge, listing the lines that model does support — your request is never silently rewritten, and no other model is swapped in',
noteConvId: 'Optional conversation_id (chat-style requests): reusing the same string for one conversation raises the upstream prompt-cache hit rate. It is a gateway-internal field and is never forwarded as-is — the gateway derives the real session id per account, so accounts never share a cache namespace; omit it and each call gets a random one',
noteN1: 'Image n must be 1 (upstream limit) — call once per image; n≠1 is rejected with a clean 400.',
noteVideo: 'Video seconds: 4–12 only; size is fixed at 720P; 6 aspect ratios (21:9/16:9/4:3/1:1/3:4/9:16); mode=text / keyframe / reference.',
notePoll: 'Do not poll faster than 5s (upstream answers 429 "too frequent"; the gateway returns throttled so you can back off).',
noteMedia: 'Assets (reference images / first-last frames / audio / chat images) accept data:image/...;base64,... or a public URL; data URIs avoid exposing the file, but keep each request body under 2MB.',
noteDownload: 'Upstream image / video URLs may expire or block hotlinking. To save a file, fetch /v1/media/download?url=... with your key and let the gateway retrieve it; URLs outside the allow-list are rejected with 400.',
noteKey: 'If a key leaks, delete it here (401 immediately) or revoke all keys of the account from the Users page.',
noteAudit: 'Every call is logged per account on the Logs page (you see yours; admins can inspect each account from the Users page).',
copyBase: 'Copy URL',
@@ -656,17 +666,13 @@ export default {
addItem: 'Add',
addModel: 'Add model',
addProvider: 'Add provider',
addRoute: 'Add route alias',
addPrice: 'Add pricing',
delete: 'Delete',
delProvider: 'Delete provider',
delRoute: 'Delete route',
delConfirm: 'Delete "{name}"? It takes effect once you save.',
needKey: 'Provider key cannot be empty',
needRoute: 'Route alias cannot be empty',
dupKey: '"{name}" is duplicated — please rename',
newProvider: '(new provider)',
newRoute: '(new alias)',
unlimited: 'empty = unlimited',
useServerTimeout: 'empty = server.timeout',
mediaEmpty: 'empty = unsupported',
@@ -683,19 +689,17 @@ export default {
tabServerSub: 'Binding, timeout/retry, rate limits, CORS, session TTL and other runtime switches',
tabProviders: 'Providers & models',
tabProvidersSub: 'Key source, base URL, image/video endpoints and the model list per provider',
tabRoutes: 'Routes & circuit',
tabRoutesSub: 'Route aliases with their fallback chains (order = priority) plus the circuit breaker',
tabLog: 'Logs & pricing',
tabLogSub: 'Log level/format/capacity plus model pricing (CNY per million tokens)',
tabDownload: 'Download proxy',
tabDownloadSub: 'CDN hosts allowed for the download proxy and the per-file size limit',
circuit: 'Provider circuit breaker',
h_circuit: 'A provider that fails to the threshold within the window is skipped for the cooldown; fallback takes over',
h_circuit: 'A provider failing to the threshold is cooled down; its requests get 503',
f_c_enabled: 'Enable circuit breaker',
f_c_failure_threshold: 'Failure threshold',
f_c_cooldown: 'Cooldown (s)',
f_c_window: 'Window (s)',
h_c_enabled: 'Off = never skip a failing provider (fallback still works)',
h_c_enabled: 'Off = never skip a failing provider',
h_c_failure_threshold: 'Opens the circuit once failures reach this count in the window',
h_c_cooldown: 'While open the provider is skipped; it half-opens automatically after the cooldown',
h_c_window: 'Counts failures inside the window (not necessarily consecutive)',
@@ -704,9 +708,9 @@ export default {
f_port: 'Port',
h_port: 'Production uses 8808 and Nginx points at it — change the proxy too',
f_timeout: 'Upstream timeout (s)',
h_timeout: 'Per upstream request; a route-level timeout overrides it',
h_timeout: 'Per upstream request timeout',
f_retry: 'Retries for direct model id',
h_retry: 'Retries (incl. first try) when calling a real model id instead of a route alias',
h_retry: 'Retries for the same model (incl. the first try)',
f_health_auth: 'Require auth on /health',
// vue-i18n parses {...} as a placeholder: literal braces must be written {'{'} / {'}'},
// otherwise the whole message fails to compile (and the UI using it renders nothing).
@@ -719,7 +723,7 @@ export default {
f_metrics_enabled: 'Record metrics',
h_metrics_enabled: 'Off = /metrics and dashboard counters stop updating (calls still work)',
f_rate_limit_rps: 'Global QPS per account',
h_rate_limit_rps: 'Empty = unlimited (provider/route level limits are configured separately)',
h_rate_limit_rps: 'Empty = unlimited (provider-level limits live in the provider entry)',
f_max_body_size: 'Max request body (bytes)',
h_max_body_size: '~2MB = 2000000; keep it generous if you send images',
f_cors_origins: 'CORS allowed origins',
@@ -755,17 +759,6 @@ export default {
pModels: 'Models',
h_pModels: 'Model ids must match upstream; vision = accepts image input (preferred for image chats)',
mVision: 'vision',
routeHint: 'A route alias is a virtual model name (e.g. wjd): models are tried top-down and only a full failure returns 502. Order = priority.',
rName: 'Alias',
h_rName: 'Pass this as "model" when calling',
rTimeout: 'Per-model timeout (s)',
h_rTimeout: 'How long a single model may take before switching to the next one',
rRetry: 'Per-model retries',
h_rRetry: 'Retries before moving on (incl. first try); 1 = switch immediately',
rRate: 'Route QPS limit',
h_rRate: 'Empty = unlimited',
rModels: 'Fallback chain',
h_rModels: 'Tried top-down; available ids come from the providers above',
f_o_log_level: 'Log level',
h_o_log_level: 'DEBUG is noisy; INFO is fine for production',
f_o_log_json: 'Structured JSON logs',
+39 -48
View File
@@ -19,10 +19,10 @@ export default {
control: '控制台',
more: '更多',
subdashboard: '网关运行概况 · 数据每 8 秒刷新',
subchat: '支持附图视觉 · 路由 wjd 自动选路',
subchat: '支持附图视觉 · 多供应商直连',
subimages: '参数在左 · 历史在右 · 下载走网关代拉',
subvideos: '720P · 时长 4–12 秒 · 异步轮询',
submodels: '供应商 / 模型 / 路由链',
submodels: '供应商 / 模型 / 协议线',
submetrics: '用量与成本 · 按账号隔离',
subkeys: '每个账号最多 3 把 · 明文保存,可反复复制',
subusers: '账号与权限 · 管理员可查他人日志与资产',
@@ -86,8 +86,6 @@ export default {
dashboard: {
modelCount: '模型数',
providers: '供应商',
routes: '路由别名',
fallback: '成功降级',
inflight: '当前并发',
callsMix: '调用 ok/fail',
provShare: '供应商成功调用份额',
@@ -97,7 +95,6 @@ export default {
circuit: '熔断',
modelCountShort: '模型数',
keySet: '已配 Key',
routeAlias: '路由别名',
name: '名称',
modelChain: '模型链',
gatewayInfo: '网关信息',
@@ -114,7 +111,6 @@ export default {
requests: '请求总数',
successRate: '成功率',
avgLatency: '平均延迟',
fallbackShort: '成功降级',
noteOkFail: 'ok {ok} · fail {fail}',
noteFail: '失败 {n} 次',
noteP95: 'P95 最高 {v}s',
@@ -127,22 +123,21 @@ export default {
noModels: '暂无调用记录',
share: '份额',
live: '实时',
routeChain: '可用性 + 速度优先链',
byProtocol: '协议线覆盖',
byProtocolSub: '每条线有多少模型',
modelCountN: '{n} 个模型',
},
metrics: {
uptime: '已运行',
inflight: '在途/峰值',
fallback: '成功降级',
promptTokens: 'Prompt tokens',
completionTokens: 'Completion tokens',
callsTotal: '总调用(ok/fail)',
modelCalls: '各模型调用(成功 / 失败)',
provShare: '供应商成功调用份额',
routeVsProvider: '路由 vs 供应商调用(成功 / 失败 / 降级)',
latency: '模型延迟 P50 / P95(秒)',
success: '成功',
fail: '失败',
fallback2: '降级',
ok: 'ok',
none: '暂无',
circuitStatus: '熔断器状态',
@@ -165,6 +160,7 @@ export default {
failRateNote: '失败率 {v}%',
snapshot: '实时快照',
circuitCard: '熔断器',
byProvider: '按供应商调用(成功 / 失败)',
},
logs: {
all: '全部',
@@ -226,20 +222,17 @@ export default {
systemShort: '系统提示',
visionReady: '视觉能力已就绪 · 可附图',
visionOff: '当前模型不支持图像输入',
chainLabel: '{id}({chain})',
emptyChain: '空',
phDefault: '默认',
phOptional: '可选',
totalTokens: '共 {n}',
uploadedImage: '已上传图片',
reasoningTag: '推理',
routeGroup: '路由(自动降级)',
textModels: '文本模型',
params: '参数',
clear: '清空',
generating: '正在生成…',
empty: '开始与网关对话(可选任意文本模型或路由 wjd)',
fallback: '降级 · 由 {provider} 响应',
empty: '开始与网关对话(在下方选一个模型)',
servedBy: '由 {provider} 响应',
requestedTo: '请求 {req} → 实际 {served}',
reasoning: '推理过程(reasoning)',
@@ -266,6 +259,7 @@ export default {
streaming: '流式输出',
system: '系统提示词(每条会话开头注入)',
loadModelsErr: '加载模型列表失败:{msg}',
pickModel: '选择模型',
},
images: {
historyTitle: '生成历史',
@@ -363,10 +357,8 @@ export default {
loadErr: '加载视频失败',
},
models: {
routeAliasTitle: '路由别名(自动降级链)',
modelListTitle: '模型清单',
name: '名称',
chainLabel: '模型链(依次尝试,失败自动降级)',
providerCount: '供应商数',
id: '模型 ID',
type: '类型',
@@ -375,12 +367,10 @@ export default {
text: '文本',
image: '图像',
video: '视频',
route: '路由',
model: '模型',
textModels: '文本模型',
imageModels: '图像模型',
videoModels: '视频模型',
routes: '路由别名',
providers: '供应商',
loadErr: '加载模型失败',
capability: '能力',
@@ -391,10 +381,8 @@ export default {
providerCard: '供应商',
keyOk: 'Key 已配置',
keyMissing: 'Key 未配置',
routeCount: '{n} 条路由',
chainCount: '{n} 个模型',
providerCount2: '{n} 家供应商',
noRoute: '没有配置路由别名',
speedtest: '一键测速',
testing: '正在测试全部文本模型延迟…',
testingShort: '测速中…',
@@ -403,6 +391,15 @@ export default {
failed: '失败',
speedtestDone: '测速完成,共 {n} 个模型',
speedtestFail: '测速失败',
speedtestHint: '按模型自己的协议线探测延迟',
textModelCount: '{n} 个文本模型',
// 第二十七轮:支持的格式列(三条协议线)。格式名直接用各家标准端点名,不译。
protocols: '支持的格式',
protocolHint: '该模型可以走哪几条线:chat/completions(OpenAI 兼容)、messages(Anthropic)、responses(OpenAI Responses)。不在列表里的格式会在网关入口直接 400 —— 网关不做跨格式转换,也绝不偷偷换个模型顶上',
protocolNa: '不适用',
protocolNaHint: '图像 / 视频模型走 /v1/images/generations、/v1/videos 专用端点,不涉及这三条协议线',
protocolHintRow: '支持的格式:{lines} ',
probedLine: '本次测速走 {p}',
},
history: {
saveFail: '历史未能保存到服务端(刷新后可能丢失),请检查登录状态或网络',
@@ -435,7 +432,7 @@ export default {
logoutBtn: '退出登录',
chatDefaults: '对话默认参数',
defsTip: '作为对话页初始值(本会话已改动的参数不受影响)。',
defaultModel: '默认模型 / 路由',
defaultModel: '默认模型',
temperature: '温度 temperature',
topP: 'top_p',
maxTokens: 'max_tokens(留空用网关默认)',
@@ -448,7 +445,7 @@ export default {
modelsCount: '模型数',
userManagement: '账号管理(管理员)',
gwConfigBtn: '去配置',
gwConfigSub: '改网关参数 / 供应商 / 路由 / 定价 —— 保存即生效',
gwConfigSub: '改网关参数 / 供应商 / 定价 —— 保存即生效',
gwConfig: '网关配置(管理员)',
userCol: '账号',
roleCol: '角色',
@@ -504,38 +501,50 @@ export default {
auth: '鉴权',
authVal: '请求头 Authorization: Bearer <你的 API Key>',
modelPick: '模型选择',
modelPickVal: 'model 填 wjd = 路由别名(按「可用 + 速度」自动降级,推荐);也可填具体模型 id 直连,不被降级影响',
modelPickVal: 'model 填真实模型 id(如 agnes-3.0-flash);三条线各按自家协议直传,网关不做跨格式转换 —— 选错线会 400(响应里会列出该模型支持哪些线)',
formats: '支持的格式',
formatsVal: '每个模型能用哪几条线,见「供应商与模型」页的「支持的格式」列:chat/completions、messages、responses。三条线各自原样转发(不改字段、不做跨格式翻译),因此接口地址与请求体按各家官方 SDK 写就行',
ctype: '请求格式',
ctypeVal: 'application/json;对话支持 SSE 流式(stream: true)',
endpoints: '常用端点',
colMethod: '方法',
colPath: '路径',
colDesc: '说明',
epModels: '模型与路由列表(含视觉能力标记)',
epModels: '模型列表(含视觉能力标记与支持的协议线)',
epChat: '对话补全(OpenAI 兼容,支持流式与图片输入)',
epMessages: '对话补全(Anthropic Messages 格式,原样直传)',
epResponses: '对话补全(OpenAI Responses 格式,原样直传)',
epImages: '图像生成 / 图生图(n 必须为 1,多张请多次调用)',
epVideoCreate: '视频生成(异步,立即返回 video_id)',
epVideoPoll: '查询视频任务(建议每 5s 一次;被上游限流时返回 throttled)',
epDownload: '代下载生成出来的图片 / 视频(绕过上游地址的防盗链与过期,白名单域名)',
epHistory: '读取本人历史(图像 / 视频 / 对话)',
epLogs: '本人调用日志',
epMetrics: '指标快照(含熔断器状态)',
epHealth: '健康检查(版本 / 供应商状态)',
exChat: '示例 · 对话',
exMessages: '示例 · 对话(Anthropic Messages 格式)',
exResponses: '示例 · 对话(OpenAI Responses 格式)',
exImg: '示例 · 图像生成',
exVideo: '示例 · 视频生成 + 轮询',
exPy: '示例 · Python(OpenAI SDK 兼容)',
// 示例代码里的注释与示例文案(整段照抄时也该是当前语言)
sampleChat: '你好,介绍一下你自己',
sampleModelMessages: 'minimax-m2.7',
sampleModelResponses: 'grok-4.6',
sampleImg: '霓虹夜景的城市街道',
sampleVideo: '镜头缓慢推进',
sampleStep1: '提交任务(异步,立即返回 video_id)',
sampleStep2: '每 5s 轮询一次(被限流会回 throttled,等一下再问)',
notes: '注意事项',
noteVision: '带图对话请用支持视觉的模型(agnes-3.0-flash,列表里标「视觉」);填路由别名 wjd 时网关会自动把视觉模型排到链首。',
noteVision: '带图对话请用支持视觉的模型(agnes-3.0-flash,列表里标「视觉」);网关不再自动换模型 —— 选了不支持视觉的模型就照原样发上去,由上游决定怎么处理',
noteCross: '跨格式不转换:某个模型支持哪几条线,由「供应商与模型」页的「支持的格式」列决定(例:minimax-m2.7 只认 messages,grok-4.6 只认 responses)。用错格式网关会在入口直接 400 并列出它支持的线,不会偷偷翻译你的请求、也不会换个模型顶上',
noteConvId: '可选字段 conversation_id(对话类请求):同一段对话复用同一个串,上游的提示词缓存更容易命中(省钱省时)。它是网关内部字段,不会原样发给上游 —— 网关按账号派生真实会话 id,账号之间互不串缓存;不传则每次随机',
noteN1: '图像 n 只能为 1(上游限制),要几张就调几次;n≠1 会被网关直接 400 拦下。',
noteVideo: '视频 seconds 只支持 4–12,size 固定 720P,比例 6 种(21:9/16:9/4:3/1:1/3:4/9:16);mode=text 文生视频 / keyframe 首尾帧 / reference 参考图·音频。',
notePoll: '轮询别快于 5s(上游会回 429「查询过于频繁」,网关会以 throttled 提示退避)。',
noteMedia: '素材(参考图 / 首尾帧 / 参考音频 / 对话附图)可直接传 data:image/...;base64,... 或公网 URL;data URI 不必暴露素材,但单次请求体需 < 2MB。',
noteDownload: '上游返回的图片 / 视频地址可能有时效或防盗链。要落盘请走 /v1/media/download?url=...(需带上你的 Key),它由网关代为取回;地址不在白名单内会被 400 拒绝。',
noteKey: 'Key 泄漏时到本页删除(立即 401),或用「用户管理」页一键吊销该账号全部 Key。',
noteAudit: '所有调用按账号记入「日志」页(仅本人可见;admin 可在用户管理页看各账号)。',
copyBase: '复制地址',
@@ -656,17 +665,13 @@ export default {
addItem: '添加',
addModel: '添加模型',
addProvider: '添加供应商',
addRoute: '添加路由别名',
addPrice: '添加定价',
delete: '删除',
delProvider: '删除供应商',
delRoute: '删除路由',
delConfirm: '删除「{name}」?保存后才真正写盘生效。',
needKey: '供应商的 key 不能为空',
needRoute: '路由别名的名字不能为空',
dupKey: '「{name}」重复了,请改一个名字',
newProvider: '(新供应商)',
newRoute: '(新路由别名)',
unlimited: '留空 = 不限',
useServerTimeout: '留空 = 用 server.timeout',
mediaEmpty: '留空 = 不支持',
@@ -683,19 +688,17 @@ export default {
tabServerSub: '监听、超时/重试、限流、CORS、会话时长等运行开关',
tabProviders: '供应商与模型',
tabProvidersSub: '供应商密钥来源、接口地址、图像/视频端点、模型清单',
tabRoutes: '路由与熔断',
tabRoutesSub: '路由别名与 fallback 模型链(顺序 = 优先级)+ 供应商熔断',
tabLog: '日志与定价',
tabLogSub: '日志级别/格式/容量 + 模型定价(人民币 / 百万 token)',
tabDownload: '下载代理',
tabDownloadSub: '允许网关代下载的 CDN 域名与单文件上限',
circuit: '供应商熔断',
h_circuit: '某供应商窗口内失败到阈值就熔断冷却,期间跳过它让 fallback 顶上',
h_circuit: '某供应商窗口内失败到阈值就熔断冷却,期间它的请求直接 503',
f_c_enabled: '启用熔断',
f_c_failure_threshold: '触发阈值(次)',
f_c_cooldown: '熔断冷却(秒)',
f_c_window: '统计窗口(秒)',
h_c_enabled: '关掉 = 失败也不跳过(fallback 照常工作)',
h_c_enabled: '关掉 = 失败也不跳过',
h_c_failure_threshold: '窗口内失败到该次数就熔断',
h_c_cooldown: '熔断期间直接跳过该供应商,冷却结束后自动半开试探',
h_c_window: '按"窗口内失败次数"计数(不是连续失败)',
@@ -705,9 +708,9 @@ export default {
f_port: '监听端口',
h_port: '生产用 8808,且 Nginx 反代指向它 —— 改了要同步改反代',
f_timeout: '上游超时(秒)',
h_timeout: '单次上游请求超时;路由自身写了 timeout 的以路由为准',
h_timeout: '单次上游请求超时',
f_retry: '直连模型重试次数',
h_retry: '直接用模型 id(不走路由别名)时的重试次数,含首次',
h_retry: '同一模型的重试次数(含首次)',
f_health_auth: '/health 需要鉴权',
// 注意:vue-i18n 把 {...} 当占位符,花括号要么写成 {'{'} / {'}'},要么整条编译不过 ——
// 编译不过的表现是"用到这条文案的整块界面不渲染",不报在文案上(踩过一次,见 check:i18n)。
@@ -720,7 +723,7 @@ export default {
f_metrics_enabled: '记录调用指标',
h_metrics_enabled: '关掉后 /metrics 与看板计数停更(不影响调用)',
f_rate_limit_rps: '全局单账号 QPS 上限',
h_rate_limit_rps: '留空 = 不限(供应商级、路由级限流见各自配置)',
h_rate_limit_rps: '留空 = 不限(供应商级限流见供应商配置)',
f_max_body_size: '请求体上限(字节)',
h_max_body_size: '约 2MB = 2000000;带图对话别调太小',
f_cors_origins: 'CORS 允许来源',
@@ -757,18 +760,6 @@ export default {
pModels: '模型清单',
h_pModels: '模型 id 必须与上游一致;vision = 支持图像输入(带图对话会优先选它)',
mVision: '视觉',
// ── 路由 ──
routeHint: '路由别名是给调用方用的"虚拟模型名"(如 wjd):按下面顺序逐个尝试,全失败才 502。数组顺序 = 优先级。',
rName: '别名',
h_rName: '调用时 model 填这个名字',
rTimeout: '单模型超时(秒)',
h_rTimeout: '某个模型多久没出结果就切下一个,避免整链挂死',
rRetry: '单模型重试次数',
h_rRetry: '切下一个之前的重试次数(含首次);想让链路快速切换就填 1',
rRate: '本路由 QPS 上限',
h_rRate: '留空 = 不限',
rModels: 'fallback 模型链',
h_rModels: '从上到下依次尝试;可用模型来自上面的供应商清单',
// ── 可观测性 ──
f_o_log_level: '日志级别',
h_o_log_level: 'DEBUG 最啰嗦,生产 INFO 够用',
+9 -7
View File
@@ -1,10 +1,16 @@
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
// 第二十八轮:element-plus 改按需引入(vite.config.ts 的 Components/AutoImport 负责模板里的
// <el-*>),这里不再 `import ElementPlus` + `app.use(ElementPlus)`、不再引全量 index.css。
// 仍然手动引的只有三样:
// ① 深色变量基座(A 皮肤用)—— 组件级样式依赖这三个 CSS 变量,必须全局在;
// ② ElMessage 的样式(Dialogs 里命令式调用,模板里没 <el-message>,resolver 扫不到);
// ③ ElMessageBox 的样式(同上,confirm() 弹窗)。
// ElLoading / ElNotification 本项目未用,无需引(未来要用了记得补)。
import 'element-plus/theme-chalk/dark/css-vars.css' // 深色变量基座(A 皮肤用)
import 'element-plus/es/components/message/style/css'
import 'element-plus/es/components/message-box/style/css'
import 'highlight.js/styles/github.css'
import * as ElementIcons from '@element-plus/icons-vue'
import App from './App.vue'
import router from './router'
import { initTheme } from './lib/theme'
@@ -15,9 +21,5 @@ initTheme() // mount 前应用主题(data-theme + dark class),避免闪色
const app = createApp(App)
app.use(createPinia())
app.use(router)
app.use(ElementPlus)
app.use(i18n) // 多语言
for (const [name, comp] of Object.entries(ElementIcons)) {
app.component(name as string, comp as any)
}
app.mount('#app')
+23 -4
View File
@@ -77,6 +77,9 @@
</div>
<div><b>{{ t('apidoc.auth') }}</b> <span class="code">{{ t('apidoc.authVal') }}</span></div>
<div><b>{{ t('apidoc.modelPick') }}</b> <span>{{ t('apidoc.modelPickVal') }}</span></div>
<!-- 第二十七轮:三条协议线各自的请求格式不同,先在这里点明「去哪看支持哪些线」,
免得用户点了 400 才知道格式选错(400 文案也会列出该模型支持的线)。 -->
<div><b>{{ t('apidoc.formats') }}</b> <span>{{ t('apidoc.formatsVal') }}</span></div>
<div><b>{{ t('apidoc.ctype') }}</b> <span>{{ t('apidoc.ctypeVal') }}</span></div>
</div>
@@ -141,12 +144,19 @@ const limit = ref<number | null>(null) // null = 不限(admin)
const base = window.location.origin
// 端点表:与 app/main.py 的真实路由一一对应(别写成 README 里才有的东西)
// 第二十七轮:三条协议线并排 —— chat/completions(OpenAI 兼容,走专用路径)、
// messages(Anthropic)、responses(OpenAI Responses)。后两条是「直传」:原始 JSON 进、
// 上游响应原样出,网关不翻译字段;某个模型能不能用这条线,看「供应商与模型」页的
// 「支持的格式」列(用错线会在入口 400 并列出该模型支持哪些线)。
const endpoints = computed(() => [
{ method: 'GET', path: '/v1/models', desc: t('apidoc.epModels') },
{ method: 'POST', path: '/v1/chat/completions', desc: t('apidoc.epChat') },
{ method: 'POST', path: '/v1/messages', desc: t('apidoc.epMessages') },
{ method: 'POST', path: '/v1/responses', desc: t('apidoc.epResponses') },
{ method: 'POST', path: '/v1/images/generations', desc: t('apidoc.epImages') },
{ method: 'POST', path: '/v1/videos', desc: t('apidoc.epVideoCreate') },
{ method: 'GET', path: '/v1/videos/{video_id}?model=...', desc: t('apidoc.epVideoPoll') },
{ method: 'GET', path: '/v1/media/download?url=...', desc: t('apidoc.epDownload') },
{ method: 'GET', path: '/history/{kind}', desc: t('apidoc.epHistory') },
{ method: 'GET', path: '/logs', desc: t('apidoc.epLogs') },
{ method: 'GET', path: '/metrics', desc: t('apidoc.epMetrics') },
@@ -154,8 +164,9 @@ const endpoints = computed(() => [
])
const notes = computed(() => [
t('apidoc.noteVision'), t('apidoc.noteN1'), t('apidoc.noteVideo'),
t('apidoc.notePoll'), t('apidoc.noteMedia'), t('apidoc.noteKey'), t('apidoc.noteAudit'),
t('apidoc.noteVision'), t('apidoc.noteCross'), t('apidoc.noteConvId'), t('apidoc.noteN1'),
t('apidoc.noteVideo'), t('apidoc.notePoll'), t('apidoc.noteMedia'), t('apidoc.noteDownload'),
t('apidoc.noteKey'), t('apidoc.noteAudit'),
])
// 示例里的 Key 用占位符 $GW_KEY(不把真 Key 渲染进文档;本页的 Key 明文只在上方列表里回显)
@@ -166,7 +177,15 @@ const examples = computed(() => {
{ title: t('apidoc.exChat'), code:
`curl ${base}/v1/chat/completions \\
${H} \\
-d '{"model":"wjd","messages":[{"role":"user","content":"${t('apidoc.sampleChat')}"}]}'` },
-d '{"model":"agnes-3.0-flash","messages":[{"role":"user","content":"${t('apidoc.sampleChat')}"}]}'` },
{ title: t('apidoc.exMessages'), code:
`curl ${base}/v1/messages \\
${H} \\
-d '{"model":"${t('apidoc.sampleModelMessages')}","max_tokens":64,"messages":[{"role":"user","content":"${t('apidoc.sampleChat')}"}]}'` },
{ title: t('apidoc.exResponses'), code:
`curl ${base}/v1/responses \\
${H} \\
-d '{"model":"${t('apidoc.sampleModelResponses')}","input":"${t('apidoc.sampleChat')}","max_output_tokens":64}'` },
{ title: t('apidoc.exImg'), code:
`curl ${base}/v1/images/generations \\
${H} \\
@@ -185,7 +204,7 @@ curl "${base}/v1/videos/task_xxx?model=agnes-video-2.5-flash" \\
`from openai import OpenAI
c = OpenAI(base_url="${base}/v1", api_key="wjd-xxxxxxxx")
r = c.chat.completions.create(model="wjd", messages=[{"role": "user", "content": "${t('apidoc.sampleChat')}"}])
r = c.chat.completions.create(model="agnes-3.0-flash", messages=[{"role": "user", "content": "${t('apidoc.sampleChat')}"}])
print(r.choices[0].message.content)` },
]
})
+22 -34
View File
@@ -104,15 +104,12 @@
</div>
<div v-for="msg in messages" :key="msg.id" class="msg" :class="msg.role === 'user' ? 'me' : 'ai'">
<!-- 助手:降级/服务信息 -->
<!-- 助手:服务信息(第二十七轮起没有"降级"这回事 —— 路由别名已删除) -->
<div v-if="msg.role === 'assistant' && msg.meta" class="resp-meta">
<el-tag size="small" :type="msg.meta.fallback ? 'warning' : 'success'" effect="light">
<template v-if="msg.meta.fallback">{{ t('chat.fallback', { provider: msg.meta.provider }) }}</template><template v-else>{{ t('chat.servedBy', { provider: msg.meta.provider }) }}</template>
<el-tag size="small" type="success" effect="light">
{{ t('chat.servedBy', { provider: msg.meta.provider }) }}
</el-tag>
<span class="meta-txt">
<template v-if="msg.meta.fallback">{{ t('chat.requestedTo', { req: msg.meta.requested, served: msg.meta.served }) }}</template>
<template v-else>{{ msg.meta.served }}</template>
</span>
<span class="meta-txt">{{ msg.meta.served }}</span>
<span v-if="msg.usage || msg.cost != null" class="meta-txt">
· {{ msg.cost != null ? `¥${msg.cost}` : '' }}
<template v-if="msg.usage">{{ tokensText(msg.usage) }}</template>
@@ -199,15 +196,7 @@
</el-tooltip>
<input ref="fileEl" type="file" accept="image/*" multiple class="hide-file" @change="onFiles" />
<el-select v-model="params.model" class="model-sel" size="small" :disabled="streaming" filterable :placeholder="t('chat.routeGroup')">
<el-option-group :label="t('chat.routeGroup')">
<el-option v-for="r in routes" :key="r.id" :value="r.id" :label="chainLabel(r)">
<span class="opt">
<span>{{ chainLabel(r) }}</span>
<Icon v-if="r.vision" name="eye" :size="13" />
</span>
</el-option>
</el-option-group>
<el-select v-model="params.model" class="model-sel" size="small" :disabled="streaming" filterable :placeholder="t('chat.pickModel')">
<el-option-group :label="t('chat.textModels')">
<el-option v-for="m in textModels" :key="m.id" :value="m.id" :label="modelLabel(m)">
<span class="opt">
@@ -289,36 +278,36 @@ const router = useRouter()
const { t } = useI18n()
// ── 模型选项 ──
const routes = ref<any[]>([])
// 第二十七轮: 路由别名(wjd)功能已整体删除 —— /v1/models 里只剩真实模型,
// 调用方选哪个模型就是哪个(网关不再"自动挑最快模型")。
const textModels = ref<any[]>([])
async function loadModels() {
try {
const j = await api('/v1/models')
const data: any[] = j.data || []
routes.value = data.filter((x) => x.type === 'route')
textModels.value = data.filter((x) => x.type !== 'route')
textModels.value = data.filter((x) => x.type !== 'image' && x.type !== 'video')
// 默认模型:优先 agnes-3.0-flash(旗舰),否则用列表第一个。
// 同时兜住"本地存着旧模型 id(比如已删除的 wjd)"的情况 —— 认不出来就换默认,
// 免得下拉框空着、发出去却被网关 400。
if (!textModels.value.some((m) => m.id === params.model)) {
const def = textModels.value.find((m) => m.id === 'agnes-3.0-flash')
params.model = def ? def.id : (textModels.value[0]?.id || '')
}
} catch (e: any) {
if (e && e.status === 401) { router.push('/login'); return }
ElMessage.error(t('chat.loadModelsErr', { msg: (e && e.message) || e }))
}
}
function chainLabel(r: any) {
const chain = (r.models || []).join(' → ')
// 括号样式(全角/半角)也交给 i18n:英文里用半角更自然
return t('chat.chainLabel', { id: r.id, chain: chain || t('chat.emptyChain') })
}
// ── 视觉能力(第十三轮)──
// 网关 /v1/models 会回 vision 字段(Agnes 3.0 Flash = true,其余文本模型默认 false)。
// 带图请求走路由别名时网关会把视觉模型排到链首;选了**不支持视觉的真实模型**时
// 这里提前告警并提供一键切换,避免"发了图但模型根本没看"。
// 第二十七轮: 路由链删除后网关不再"把视觉模型排到链首" —— 选了不支持视觉的模型时,
// 这里提前告警并提供一键切换,避免"发了图但模型根本没看"。
const visionModels = computed(() =>
textModels.value.filter((m) => m.vision).map((m) => m.id))
const visionOk = computed(() => {
const m = routes.value.find((r) => r.id === params.model)
if (m) return !!m.vision || !!(m.models || []).some((id: string) => visionModels.value.includes(id))
const t2 = textModels.value.find((x) => x.id === params.model)
return !!t2?.vision
const m = textModels.value.find((x) => x.id === params.model)
return !!m?.vision
})
const firstVisionModel = computed(() => visionModels.value[0] || '')
function useVisionModel() {
@@ -330,7 +319,8 @@ function modelLabel(m: any) {
// ── 参数与状态 ──
const params = reactive({
model: 'wjd',
// 空串 = 还没拿到模型列表;loadModels() 里填入默认模型(第二十七轮: 不再默认 wjd)
model: '',
temperature: 0.7,
top_p: 1,
max_tokens: null as number | null,
@@ -654,12 +644,11 @@ async function runOnce(input: string) {
}
reply.usage = j?.usage || undefined
reply.cost = j?.estimated_cost_cny ?? undefined
if (j?.route || j?.provider) {
if (j?.provider || j?.served_model) {
reply.meta = {
served: j.served_model || j.model || params.model,
provider: j.provider_name || j.provider,
requested: j.model || params.model,
fallback: !!(j.route && j.route.fallback_used),
}
}
} catch (e: any) {
@@ -687,7 +676,6 @@ async function runStream(_input: string) {
served: chunk.served_model || chunk.model || params.model,
provider: chunk.provider_name || chunk.provider,
requested: chunk.model || params.model,
fallback: !!(chunk.route && chunk.route.fallback_used),
}
}
if (chunk.usage && !chunk.choices?.length) {
+15 -19
View File
@@ -41,16 +41,16 @@
<div class="sep" />
<div class="card-h" style="margin-bottom: 8px">
<b>{{ t('dashboard.routeAlias') }}</b>
<span class="sub">{{ t('dashboard.routeChain') }}</span>
<b>{{ t('dashboard.byProtocol') }}</b>
<span class="sub">{{ t('dashboard.byProtocolSub') }}</span>
</div>
<div class="pv" style="gap: 7px">
<div v-for="(r, i) in routeRows" :key="r.name" class="pv-i" style="font-size: 12px">
<div v-for="(r, i) in protoRows" :key="r.name" class="pv-i" style="font-size: 12px">
<span class="pill mute">{{ i + 1 }}</span>
<span class="code flex-1">{{ r.name }}</span>
<span class="st muted-2 nowrap">{{ r.short }}</span>
</div>
<div v-if="!routeRows.length" class="hint">{{ t('dashboard.noData') }}</div>
<div v-if="!protoRows.length" class="hint">{{ t('dashboard.noData') }}</div>
</div>
</div>
</div>
@@ -94,7 +94,6 @@
<span>{{ t('dashboard.running') }}</span>
<span>{{ t('dashboard.uptime') }} {{ uptimeText }}</span>
<span>{{ t('dashboard.inflight') }} {{ health.in_flight ?? '-' }} / {{ health.in_flight_peak ?? '-' }}</span>
<span>{{ t('dashboard.fallback') }} {{ health.fallback_total ?? 0 }}</span>
</div>
</div>
</div>
@@ -116,7 +115,7 @@ const { resolved } = useTheme() // 主题变化时重算图表配色
const health = ref<any>({})
const metrics = ref<any>({})
const models = ref<any>({})
const routes = ref<any[]>([])
const modelsList = ref<any[]>([])
const loading = ref(false)
const err = ref('')
@@ -149,7 +148,6 @@ const cards = computed(() => {
{ k: t('dashboard.requests'), v: total.value, note: t('dashboard.noteOkFail', { ok: totalOk.value, fail: totalFail.value }) },
{ k: t('dashboard.successRate'), v: rate.value.toFixed(1) + '%', note: t('dashboard.noteFail', { n: totalFail.value }) },
{ k: t('dashboard.avgLatency'), v: avgP50.value.toFixed(2) + 's', note: t('dashboard.noteP95', { v: maxP95.value.toFixed(2) }) },
{ k: t('dashboard.fallbackShort'), v: health.value.fallback_total ?? 0, note: t('dashboard.noteInflight', { n: health.value.in_flight ?? 0 }) },
]
})
@@ -171,12 +169,14 @@ const providerRows = computed(() => {
})
})
const routeRows = computed(() => {
const m = models.value
return routes.value.map((r: any) => {
const chain: string[] = (m[r.id] || []).map((x: any) => (typeof x === 'string' ? x : x.id || x.name))
return { name: r.id, short: chain.length ? t('models.chainCount', { n: chain.length }) : '—' }
})
// 第二十七轮: 路由别名链已删除 → 这里改成"每条协议线各有几个模型"
// (三线直传后这个分布才是运维真正关心的:哪条线现在有货)
const protoRows = computed(() => {
const count: Record<string, number> = {}
for (const m of modelsList.value) {
for (const p of (m.protocols || ['chat/completions'])) count[p] = (count[p] || 0) + 1
}
return Object.keys(count).sort().map((k) => ({ name: k, short: t('dashboard.modelCountN', { n: count[k] }) }))
})
const callRows = computed(() => {
@@ -258,14 +258,10 @@ async function load() {
try {
const um = await api('/v1/models')
const data = um.data || []
routes.value = data.filter((x: any) => x.type === 'route')
modelsList.value = data
const map: Record<string, string> = {}
for (const x of data) if (x.type !== 'route') map[x.id] = x.provider_name || ''
for (const x of data) map[x.id] = x.provider_name || ''
textModels.value = map
const list = data.filter((x: any) => x.type === 'route')
const m: Record<string, any> = {}
for (const r of list) m[r.id] = r.models || []
models.value = m
} catch { /* 模型列表可选 */ }
} catch (e: any) {
if (e && e.status === 401) { router.push('/login'); return }
+2 -1
View File
@@ -122,7 +122,8 @@ async function load() {
value: envs[env].value || '',
show: false,
}))
warns.value = (body.meta?.warnings || []).concat(body.meta?.route_warnings || [])
// 第二十七轮: 路由告警(meta.route_warnings)随路由功能删除,体检结论只看 warnings
warns.value = body.meta?.warnings || []
} catch (e: any) {
err.value = (e?.body?.detail || e?.message || String(e))
} finally {
+14 -16
View File
@@ -36,15 +36,14 @@
<div class="grid-eq">
<div class="card">
<div class="card-h">
<b>{{ t('metrics.routeVsProvider') }}</b>
<b>{{ t('metrics.byProvider') }}</b>
<span class="sub">{{ t('metrics.snapshot') }}</span>
<div class="legend">
<span><i style="background: var(--chart-a)" />ok</span>
<span><i style="background: var(--err)" />fail</span>
<span><i style="background: var(--warn)" />fallback</span>
</div>
</div>
<EChart :option="routeOpt" height="250px" />
<EChart :option="providerOpt" height="250px" />
</div>
<div class="card">
<div class="card-h">
@@ -88,7 +87,6 @@
<div class="about-line">
<b>{{ t('metrics.snapshot') }}</b>
<span>{{ t('metrics.uptime') }} {{ fmtUptime }}</span>
<span>{{ t('metrics.fallback') }} {{ data.fallback_total ?? 0 }}</span>
<span>{{ t('metrics.inflight') }} {{ data.in_flight ?? 0 }} / {{ data.in_flight_peak ?? 0 }}</span>
</div>
</div>
@@ -156,7 +154,8 @@ const cards = computed(() => {
{ k: t('metrics.requests'), v: all, note: t('dashboard.noteOkFail', { ok, fail }) },
{ k: t('metrics.failCount'), v: fail, note: t('metrics.failRateNote', { v: rate.toFixed(1) }) },
{ k: t('metrics.tokenUsage'), v: (tk.prompt || 0) + (tk.completion || 0), note: t('metrics.tokenNote', { p: tk.prompt ?? 0, c: tk.completion ?? 0 }) },
{ k: t('metrics.inflightPeak'), v: `${data.value.in_flight ?? 0} / ${data.value.in_flight_peak ?? 0}`, note: t('metrics.fallback') + ' ' + (data.value.fallback_total ?? 0) },
// 第二十七轮: fallback 计数随路由功能删除 → 这张卡片的注脚改成运行时长
{ k: t('metrics.inflightPeak'), v: `${data.value.in_flight ?? 0} / ${data.value.in_flight_peak ?? 0}`, note: t('metrics.uptime') + ' ' + fmtUptime.value },
]
})
@@ -194,27 +193,26 @@ const provOpt = computed<EChartsCoreOption>(() => {
}
})
const routeOpt = computed<EChartsCoreOption>(() => {
// 第二十七轮: 路由维度指标随路由功能删除(routes/fallback_total 已不在 /metrics 里),
// 这里改成按供应商看 成功 / 失败(供应商是现在唯一的"聚合维度")。
const providerOpt = computed<EChartsCoreOption>(() => {
void resolved.value
const c = chartTheme()
const r = data.value.routes || {}
const ks = Object.keys(r)
const names = ks.length ? ks : ['wjd']
const get = (k: string, f: string) => (r[k] || {})[f] || 0
const p = data.value.providers || {}
const names = Object.keys(p)
const get = (k: string, f: string) => (p[k] || {})[f] || 0
const ok = names.map((n) => get(n, 'ok'))
const fail = names.map((n) => get(n, 'fail'))
const fallback = names.map((n) => get(n, 'fallback'))
return {
tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } },
legend: legend(['ok', 'fail', 'fallback']),
legend: legend(['ok', 'fail']),
grid,
graphic: emptyTip([ok, fail, fallback], t('metrics.none')),
graphic: emptyTip([ok, fail], t('metrics.none')),
xAxis: categoryAxis(names, 10),
yAxis: valueAxis('', 1),
series: [
{ name: 'ok', type: 'bar', stack: 'r', data: ok, itemStyle: { color: c.a } },
{ name: 'fail', type: 'bar', stack: 'r', data: fail, itemStyle: { color: c.err } },
{ name: 'fallback', type: 'bar', stack: 'r', data: fallback, itemStyle: { color: c.warn } },
{ name: 'ok', type: 'bar', stack: 'p', data: ok, itemStyle: { color: c.a } },
{ name: 'fail', type: 'bar', stack: 'p', data: fail, itemStyle: { color: c.err } },
],
}
})
+85 -48
View File
@@ -11,36 +11,32 @@
</div>
<div class="grid2">
<!-- 路由链:只读展示(排序策略在后端,页面不写盘) -->
<!-- 路由别名 + 全部文本模型延迟(一键测速填充) -->
<!-- 全部文本模型 + 一键测速(延迟逐行填充;测速按模型自己的协议线探测) -->
<div class="card">
<div class="card-h">
<b>{{ t('models.routeAliasTitle') }}</b>
<b>{{ t('models.allTextModels') }}</b>
<span class="sub">{{ t('models.speedtestHint') }}</span>
<span style="flex:1"></span>
<el-button size="small" :loading="latTesting" @click="runSpeedtest()">
{{ latTesting ? t('models.testingShort') : t('models.speedtest') }}
</el-button>
</div>
<div v-for="r in routeRows" :key="r.name" class="route-block">
<div class="route-head">
<span class="code route-name">{{ r.name }}</span>
<span style="flex:1"></span>
<el-button size="small" :loading="latTesting" @click="runSpeedtest()">
{{ latTesting ? t('models.testingShort') : t('models.speedtest') }}
</el-button>
</div>
</div>
<div v-if="!routeRows.length" class="hint">{{ t('models.noRoute') }}</div>
<div class="lat-head">
<span class="muted-2 hint">{{ t('models.allTextModels') }}</span>
<span style="flex:1"></span>
<span class="muted-2 hint">{{ t('models.latency') }}</span>
</div>
<div v-for="m in textModelRows" :key="m.id" class="st-item">
<div class="st-row">
<div class="st-row" :title="rowTitle(m)">
<Icon v-if="m.vision" name="eye" :size="12" class="vision" />
<!-- 第二十五轮:该模型的参数被上游固定(如 temperature 只能是 1),
挂锁标注 + 悬浮说明,省掉「为什么我传的参数不生效」这类困惑。 -->
<Icon v-if="m.paramNote" name="lock" :size="12" class="plock" :title="m.paramNote" />
<span class="code">{{ m.id }}</span>
<!-- 支持的格式不在这里铺标签:这行还要放供应商/延迟/测速按钮,窄卡放不下第三颗
(悬停整行可见格式 + 本次测速走的线,见 rowTitle)。权威展示在下方表格的
「支持的格式」列。 -->
<span class="muted-2 st-prov">{{ m.provider }}</span>
<span style="flex:1"></span>
<span class="pill st-lat" :class="latCls(m.id)">
@@ -87,20 +83,42 @@
<b>{{ t('models.modelListTitle') }}</b>
<span class="sub">{{ t('models.capability') }}</span>
<div class="pager">
<span class="pill mute">{{ t('models.routeCount', { n: routeRows.length }) }}</span>
<span class="pill mute">{{ t('models.textModelCount', { n: textModelRows.length }) }}</span>
</div>
</div>
<el-table :data="modelRows" size="small" v-loading="loading">
<el-table-column :label="t('models.id')" min-width="200">
<el-table-column :label="t('models.id')" min-width="185">
<template #default="{ row }"><span class="code">{{ row.id }}</span></template>
</el-table-column>
<el-table-column :label="t('models.type')" width="100">
<el-table-column :label="t('models.type')" width="90">
<template #default="{ row }"><span class="pill" :class="typeCls(row.type)">{{ t(typeKey(row.type)) }}</span></template>
</el-table-column>
<el-table-column :label="t('models.provider')" min-width="150">
<el-table-column :label="t('models.provider')" min-width="140">
<template #default="{ row }">{{ row.provider_name || '—' }}</template>
</el-table-column>
<el-table-column :label="t('models.capability')" width="190">
<!-- 第二十七轮追加:支持的格式(三条协议线)——
后端 /v1/models 里每个文本模型带 protocols 数组(chat/completions、messages、
responses 的一个子集)。这里只做展示,但它有实际约束力:用不在列表里的格式
调网关,会在入口被 400 挡下(网关不做跨格式转换,见 /v1/messages 的 400 文案)。
图像/视频模型走专用端点,不涉及三条协议线,统一显示「不适用」。
width 取 300:实测三颗标签(chat/completions=120px + messages=67px + responses=74px
+ 间距)并排一行需 ~273px,留足余量让多线模型那行也单行,不挤到换行。 -->
<el-table-column width="300">
<template #header>
<el-tooltip :content="t('models.protocolHint')" placement="top">
<span class="proto-th">{{ t('models.protocols') }}</span>
</el-tooltip>
</template>
<template #default="{ row }">
<span v-if="protocolsOf(row).length" class="proto-cell">
<span v-for="p in protocolsOf(row)" :key="p" class="pill proto" :title="protoTitle(p)">{{ p }}</span>
</span>
<el-tooltip v-else :content="t('models.protocolNaHint')" placement="top">
<span class="muted-2">{{ t('models.protocolNa') }}</span>
</el-tooltip>
</template>
</el-table-column>
<el-table-column :label="t('models.capability')" width="170">
<template #default="{ row }">
<span v-if="row.vision" class="pill ok cap">
<Icon name="eye" :size="12" />{{ t('models.visionTag') }}
@@ -111,7 +129,7 @@
<span v-if="!row.vision && !paramKeys(row).length" class="muted-2">—</span>
</template>
</el-table-column>
<el-table-column :label="t('models.keySet')" width="120">
<el-table-column :label="t('models.keySet')" width="90">
<template #default="{ row }">
<span class="pill" :class="row.key_set ? 'ok' : 'err'">
{{ row.key_set ? t('common.yes') : t('common.no') }}
@@ -138,14 +156,27 @@ const health = ref<any>({})
const loading = ref(false)
const err = ref('')
const typeKeyMap: Record<string, string> = { text: 'models.text', image: 'models.image', video: 'models.video', route: 'models.route' }
const typeClsMap: Record<string, string> = { text: 'mute', image: 'warn', video: 'warn', route: 'ok' }
const typeKeyMap: Record<string, string> = { text: 'models.text', image: 'models.image', video: 'models.video' }
const typeClsMap: Record<string, string> = { text: 'mute', image: 'warn', video: 'warn' }
function typeKey(ty: string) { return typeKeyMap[ty] || ty }
function typeCls(ty: string) { return typeClsMap[ty] || 'mute' }
// ── 支持的格式(第二十七轮)──
// 取值范围与后端 PROTOCOLS 一致:chat/completions(OpenAI 兼容线)、messages(Anthropic 线)、
// responses(OpenAI Responses 线)。**名字直接取各家标准端点名**,不另起中文别名 —— 配置、
// 日志、前端标签、上游文档四处同名,出问题时对得上号。
function protocolsOf(row: any): string[] {
if (!row || row.type !== 'text') return [] // 图像/视频模型走专用端点,没有协议线概念
return (row.protocols as string[]) || []
}
// 每个格式标签的悬浮说明:这条线对应哪个端点(点进说明文档也是这个对应关系)
function protoTitle(p: string): string { return `POST /v1/${p}` }
const latTesting = ref(false)
const latCurrentId = ref('') // 当前正在测的模型 id:该行延迟位显示加载图标
const latByModel = ref<Record<string, { ok: boolean; latency_ms: number | null; error: string }>>({})
// protocol 由后端返回:探针**按模型自己的协议线**挑一条(优先级 chat → messages → responses),
// 记下来才能在悬浮提示里说清「这次多少毫秒是走哪条线测的」——多线模型不写清楚会让人误解。
const latByModel = ref<Record<string, { ok: boolean; latency_ms: number | null; error: string; protocol: string }>>({})
async function runSpeedtest() {
if (latTesting.value) return
// 逐个测速:按列表顺序,测一个立刻显示那一行、再测下一个;当前测的行显示加载图标。
@@ -155,17 +186,17 @@ async function runSpeedtest() {
latTesting.value = true
for (const id of ids) {
latCurrentId.value = id
let row: { ok: boolean; latency_ms: number | null; error: string }
let row: { ok: boolean; latency_ms: number | null; error: string; protocol: string }
try {
const j = await api('/v1/models/speedtest', { method: 'POST', body: JSON.stringify({ model: id }) })
const r: any[] = (j && j.results) || []
const hit = r[0]
row = hit
? { ok: !!hit.ok, latency_ms: hit.latency_ms ?? null, error: hit.error || '' }
: { ok: false, latency_ms: null, error: t('models.speedtestFail') }
? { ok: !!hit.ok, latency_ms: hit.latency_ms ?? null, error: hit.error || '', protocol: hit.protocol || '' }
: { ok: false, latency_ms: null, error: t('models.speedtestFail'), protocol: '' }
} catch (e: any) {
// 单个模型出错不中断整轮,标记失败后继续下一个
row = { ok: false, latency_ms: null, error: (e && e.message) || String(e) }
row = { ok: false, latency_ms: null, error: (e && e.message) || String(e), protocol: '' }
}
latByModel.value = { ...latByModel.value, [id]: row } // 响应式替换 → 该行即时更新
}
@@ -182,11 +213,11 @@ async function retestOne(id: string) {
const r: any[] = (j && j.results) || []
const hit = r[0]
const row = hit
? { ok: !!hit.ok, latency_ms: hit.latency_ms ?? null, error: hit.error || '' }
: { ok: false, latency_ms: null, error: t('models.speedtestFail') }
? { ok: !!hit.ok, latency_ms: hit.latency_ms ?? null, error: hit.error || '', protocol: hit.protocol || '' }
: { ok: false, latency_ms: null, error: t('models.speedtestFail'), protocol: '' }
latByModel.value = { ...latByModel.value, [id]: row }
} catch (e: any) {
latByModel.value = { ...latByModel.value, [id]: { ok: false, latency_ms: null, error: (e && e.message) || String(e) } }
latByModel.value = { ...latByModel.value, [id]: { ok: false, latency_ms: null, error: (e && e.message) || String(e), protocol: '' } }
} finally {
latCurrentId.value = ''
}
@@ -208,8 +239,8 @@ function latCls(id: string): string {
return row ? (row.ok ? 'ok' : 'err') : 'mute'
}
const routes = computed(() => items.value.filter((x) => x.type === 'route'))
const models = computed(() => items.value.filter((x) => x.type !== 'route'))
// 第二十七轮: 路由别名条目(type === 'route')已从 /v1/models 消失 → 这里只剩真实模型
const models = computed(() => items.value)
const providerOf = computed(() => {
const m: Record<string, string> = {}
@@ -222,16 +253,6 @@ const visionOf = computed(() => {
return m
})
const routeRows = computed(() =>
routes.value.map((r) => {
const chain: string[] = r.models || []
return {
name: r.id,
models: chain.map((id) => ({ id, provider: providerOf.value[id] || '—', vision: visionOf.value[id] })),
providerCount: new Set(chain.map((id) => providerOf.value[id] || '—')).size,
}
}),
)
const textModelRows = computed(() =>
models.value.filter((x) => x.type === 'text').map((m) => ({
id: m.id,
@@ -239,9 +260,21 @@ const textModelRows = computed(() =>
vision: !!m.vision,
// 模型级强制参数(第二十五轮):被上游固定住的采样参数,用挂锁标注出来。
paramNote: paramKeys(m).length ? paramNote(m) : '',
// 支持的格式(第二十七轮):悬浮这一行就能看到「能用哪几条线 + 本次测速走的哪条」
formats: protocolsOf(m),
})),
)
// 测速行的悬浮提示:先说这个模型支持哪些格式,再说这次测的是哪条线
// (多线模型不标注的话,"12 ms"到底测的是哪条线是看不出来的)。
function rowTitle(m: any): string {
const lines = (m.formats || []).join(' / ') || t('models.protocolNa')
const p = latByModel.value[m.id]?.protocol
return p
? `${t('models.protocolHintRow', { lines })}· ${t('models.probedLine', { p })}`
: t('models.protocolHintRow', { lines })
}
// ── 模型级强制参数(第二十五轮)──
// 后端 /v1/models 在 params 里给出「该模型发往上游前会被强制覆盖的参数」
// (例:kimi-k2.7-code 只接受 temperature=1)。这里只做展示,不提供编辑入口。
@@ -279,7 +312,6 @@ const cards = computed(() => [
{ k: t('models.model'), v: models.value.length, note: t('models.providerCount2', { n: providerRows.value.length }) },
{ k: t('models.textModels'), v: models.value.filter((m) => m.type === 'text').length, note: t('models.visionTag') + ' · ' + models.value.filter((m) => m.vision).length },
{ k: t('models.imageModels'), v: models.value.filter((m) => m.type === 'image').length, note: t('images.title') },
{ k: t('models.routes'), v: routes.value.length, note: t('models.routeAliasTitle') },
])
onMounted(async () => {
@@ -298,15 +330,20 @@ onMounted(async () => {
</script>
<style scoped>
.route-block { padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.route-block:last-child { border-bottom: 0; }
.route-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.route-name { font-weight: 700; color: var(--text); font-size: 13px; }
.chain { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chain-item { display: inline-flex; align-items: center; gap: 6px; }
.arrow { color: var(--muted-2); }
.vision { color: var(--primary); }
.plock { color: var(--warn); }
/* 支持的格式:三条线是并列关系(没有谁更优),统一用主题色弱底,
不用 ok/warn/err —— 否则「messages」看起来像警告、「responses」像被禁用。 */
.proto {
color: var(--primary); background: var(--primary-soft);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace; /* 与全局 .code 同一套 */
font-size: 11px; padding: 2px 7px;
}
.proto-cell { display: inline-flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.proto-th { border-bottom: 1px dotted var(--muted-2); cursor: help; }
.prov { padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.prov:last-child { border-bottom: 0; }
.prov-top { display: flex; align-items: center; gap: 8px; }
-20
View File
@@ -1,20 +0,0 @@
<template>
<div class="page">
<div class="card">
<div class="ph-title">「{{ title }}」页面</div>
<div class="ph-sub">该功能在后续里程碑开发(M2 对话 / M3 媒体 / M4 指标日志 等)。</div>
</div>
</div>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { useRoute } from 'vue-router'
const route = useRoute()
const title = computed(() => (route.meta.title as string) || '')
</script>
<style scoped>
.ph-title { font-size: 18px; font-weight: 600; }
.ph-sub { color: var(--muted); margin-top: 8px; }
</style>
+8 -10
View File
@@ -67,7 +67,7 @@
<div class="set-row">
<div class="lb">{{ t('settings.defaultModel') }}</div>
<div class="rt">
<el-select v-model="defs.model" size="small" clearable :placeholder="t('chat.routeGroup')" style="width: 210px">
<el-select v-model="defs.model" size="small" clearable :placeholder="t('chat.pickModel')" style="width: 210px">
<el-option v-for="m in textModels" :key="m" :label="m" :value="m" />
</el-select>
</div>
@@ -179,10 +179,6 @@
<div class="lb">{{ t('dashboard.inflight') }}</div>
<div class="rt">{{ health.in_flight ?? '-' }} / {{ health.in_flight_peak ?? '-' }}</div>
</div>
<div class="set-row">
<div class="lb">{{ t('dashboard.fallback') }}</div>
<div class="rt">{{ health.fallback_total ?? 0 }}</div>
</div>
<div class="set-row" style="align-items: flex-start">
<div class="lb">{{ t('settings.providerStatus') }}</div>
<div class="rt" style="flex-wrap: wrap; justify-content: flex-end">
@@ -228,8 +224,8 @@ const err = ref('')
const { t, locale } = useI18n()
const { theme, followSystem, setTheme, setFollowSystem } = useTheme()
// 对话默认模型下拉(老板决策:wjd 链路 = 全部文本模型;这里同样覆盖全部文本模型)
const TEXT_MODELS = ['wjd',
// 对话默认模型下拉(覆盖全部文本模型;第二十七轮: wjd 路由别名已删除,不再有"别名"选项)
const TEXT_MODELS = [
'agnes-3.0-flash', 'agnes-2.5-flash', 'ark-code-latest',
// OpenCode Go(订阅编程模型,17 个文本模型)
'glm-5.3-flash', 'glm-5.3', 'glm-5.2', 'glm-5.1',
@@ -252,7 +248,9 @@ const savingDefs = ref(false)
function loadDefs() {
const d = getChatDefaults()
defs.model = d.model ?? 'wjd'
// 第二十七轮: 默认模型不再回落到 wjd(该别名已删除)—— 认不出就留空串,
// Settings 的模型下拉在 onMounted 里会用真实模型列表兜底。
defs.model = d.model ?? ''
defs.temperature = d.temperature ?? 0.7
defs.top_p = d.top_p ?? 1
defs.max_tokens = d.max_tokens ?? null
@@ -315,8 +313,8 @@ onMounted(async () => {
// 默认模型下拉用真实模型列表(拿不到就退回内置候选)
try {
const um = await api('/v1/models')
const list = (um.data || []).filter((x: any) => x.type !== 'route').map((x: any) => x.id)
if (list.length) textModels.value = ['wjd', ...list]
const list = (um.data || []).filter((x: any) => x.type !== 'image' && x.type !== 'video').map((x: any) => x.id)
if (list.length) textModels.value = list
} catch { /* 模型列表可选 */ }
} catch (e: any) {
if (e && e.status === 401) { router.push('/login'); return }