feat: display upstream model maximums as read-only capacity facts
This commit is contained in:
@@ -28,3 +28,4 @@
|
||||
.mc-section-title .mc-row-actions,.mc-catalog .mc-row-actions{display:flex;flex-wrap:wrap;gap:8px}.mc-catalog{margin-bottom:24px;border-top:3px solid #2560a3;min-width:0}.mc-catalog-heading{display:flex;align-items:end;flex-wrap:wrap;gap:12px;margin:18px 0 12px}.mc-catalog-heading label{display:grid;gap:7px;flex:1;min-width:180px}.mc-catalog-heading input{padding:10px;border:1px solid #a9bdcf;border-radius:5px;width:100%;min-width:0;background:#fff}.mc-catalog-heading>span{font-size:12px;color:#40566e;padding:10px 0}.mc-catalog-list{margin:12px 0;max-height:440px;overflow:auto;border:1px solid #b8cadb;border-radius:5px;background:#fff;overscroll-behavior:contain}.mc-catalog-model{display:flex;gap:12px;align-items:start;padding:13px 14px;border-bottom:1px solid #d3dde7;cursor:pointer;min-width:0}.mc-catalog-model:last-child{border-bottom:0}.mc-catalog-model.is-selected{background:#eaf2fa}.mc-catalog-model>input{margin-top:4px;flex:0 0 auto;width:18px;height:18px;accent-color:#2560a3}.mc-catalog-model>span{display:grid;gap:5px;min-width:0;overflow-wrap:anywhere;line-height:1.6}.mc-catalog-model strong{font-family:Consolas,"Microsoft YaHei",monospace;font-size:13px}.mc-catalog-model small{font-size:12px;color:#40566e}.mc-catalog input:focus-visible{outline:2px solid #2560a3;outline-offset:2px}.mc-catalog>.mc-checkbox{display:flex;align-items:start;gap:9px;line-height:1.8;margin:16px 0;color:#40566e;font-size:12px}.mc-catalog>.mc-checkbox>input{flex:0 0 auto;margin-top:4px}
|
||||
@media(max-width:620px){.mc-catalog-heading{align-items:stretch}.mc-catalog-heading>span{padding:0}.mc-catalog-model{padding:12px 10px;gap:10px}.mc-catalog-model>input{width:22px;height:22px}.mc-catalog-list{max-height:380px}.mc-catalog .mc-section-title>.button{align-self:flex-end}}
|
||||
.mc-reasoning .mc-form-grid{margin-top:12px}.mc-reasoning .mc-help{color:#40566e;font-size:12px}.mc-feature-scope{font-size:12px;line-height:1.7;margin:12px 0;overflow-wrap:anywhere}.mc-feature-scope summary{cursor:pointer;color:#245b92;padding:8px 0;min-height:40px}.mc-feature-scope table{width:100%;table-layout:fixed;border-collapse:collapse;margin-top:10px}.mc-feature-scope th,.mc-feature-scope td{text-align:left;vertical-align:top;border-bottom:1px solid #d3dde7;padding:9px 7px;font-size:12px;color:#40566e}.mc-feature-scope th{font-weight:600}.mc-reasoning input:focus-visible{outline:2px solid #2560a3;outline-offset:2px}
|
||||
.mc-capacity-facts{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;margin:16px 0}.mc-capacity-facts dt{color:#40566e;font-size:12px;margin-bottom:6px}.mc-capacity-facts dd{margin:0;color:#16324c;font-size:16px;font-weight:650;line-height:1.5;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}@media(max-width:620px){.mc-capacity-facts{grid-template-columns:1fr;gap:12px}}
|
||||
|
||||
@@ -16,6 +16,10 @@ import { ModelCatalog } from './ModelCatalog';
|
||||
import type { CatalogModel } from '../shared/contracts/model-catalog.mjs';
|
||||
|
||||
const previewUrl = (value: { protocol: string; baseUrl: string }) => { try { return modelRequestUrl(value); } catch { return '请填写有效的接口根地址'; } };
|
||||
const upstreamCapacity = (value: { model: string; upstreamModel?: CatalogModel }, field: 'contextLimit' | 'maxOutputTokens') => {
|
||||
const tokens = value.upstreamModel?.id === value.model ? value.upstreamModel[field] : undefined;
|
||||
return typeof tokens === 'number' && tokens > 0 ? tokens.toLocaleString() + ' tokens' : '本地无限制 · 由上游决定';
|
||||
};
|
||||
|
||||
type Connection = { id: string; name: string; brand: string; protocol: string; parameterProfile?: string; messagesAuth?: string; baseUrl: string; model: string; enabled: boolean; revision: number; hasKey: boolean; credentialSource?: { connectionId: string }; upstreamModel?: CatalogModel;
|
||||
requiresKey: boolean; modelIdentityPolicy?: string; modelIdentityAliases?: string[]; modelIdentityAliasSource?: string; nativeParameters?: Record<string, unknown>; outputTokenField?: string; streaming?: boolean; capabilityDeclarations?: Record<string, string>; capabilities?: Record<string, string>; capabilityEvidence?: { checkedAt: string }; contextLimit: number; maxOutputTokens: number; concurrency: number; status: string; activeRequests: number; savedCredential?: { status: string }; health: { state: string; reason?: string; cooldownUntil?: number } };
|
||||
@@ -120,7 +124,7 @@ export function ModelCenter({ onConfig, onLegacy, busy, runModel }: { onConfig:
|
||||
{catalogSource !== null && <ModelCatalog key={catalogSource} sources={view.connections} sourceId={catalogSource} busy={locked} onSaved={refresh} onClose={() => setCatalogSource(null)} />}
|
||||
<div className="mc-connections">{view.connections.map(value => <article className={'mc-connection ' + (!value.enabled ? 'mc-disabled' : '')} key={value.id}>
|
||||
<div className="mc-card-heading"><span className="mc-service-icon"><Server size={20} /></span><div><h4>{value.name}</h4><span>{value.brand} · {protocolLabel(value.protocol)}{value.streaming ? ' · 流式开启' : ''}</span></div><span className={'mc-state mc-state-' + value.status}>{states[value.status]}</span></div>
|
||||
<dl><dt>模型</dt><dd>{value.model || '尚未填写'}</dd><dt>请求地址</dt><dd>{previewUrl(value)}</dd>{value.protocol === 'anthropic-messages' && <><dt>鉴权</dt><dd>{value.messagesAuth === 'bearer' ? 'Bearer' : 'x-api-key'} · anthropic-version 2023-06-01</dd></>}<dt>凭据</dt><dd>{value.credentialSource ? '共用 ' + (view.connections.find(source => source.id === value.credentialSource!.connectionId)?.name ?? '源连接') + (value.hasKey ? ' 的上游凭据' : ';请核对源连接是否启用及凭据') : value.hasKey ? value.savedCredential?.status === 'saved' ? '已设置,可从本机加密保存加载' : '已设置,重启需重新填写' : value.requiresKey ? '尚未填写' : '此服务可不填'}</dd><dt>当前请求</dt><dd>{value.activeRequests} 在途 · 并发 {value.concurrency}</dd><dt>{passthrough ? '上下文 / 输出' : '连接容量声明'}</dt><dd>{passthrough ? '默认透传 · 由上游决定' : `上下文 ${value.contextLimit.toLocaleString()} · 输出 ${value.maxOutputTokens.toLocaleString()}`}</dd></dl>
|
||||
<dl><dt>模型</dt><dd>{value.model || '尚未填写'}</dd><dt>请求地址</dt><dd>{previewUrl(value)}</dd>{value.protocol === 'anthropic-messages' && <><dt>鉴权</dt><dd>{value.messagesAuth === 'bearer' ? 'Bearer' : 'x-api-key'} · anthropic-version 2023-06-01</dd></>}<dt>凭据</dt><dd>{value.credentialSource ? '共用 ' + (view.connections.find(source => source.id === value.credentialSource!.connectionId)?.name ?? '源连接') + (value.hasKey ? ' 的上游凭据' : ';请核对源连接是否启用及凭据') : value.hasKey ? value.savedCredential?.status === 'saved' ? '已设置,可从本机加密保存加载' : '已设置,重启需重新填写' : value.requiresKey ? '尚未填写' : '此服务可不填'}</dd><dt>当前请求</dt><dd>{value.activeRequests} 在途 · 并发 {value.concurrency}</dd>{passthrough ? <><dt>模型最大上下文</dt><dd>{upstreamCapacity(value, 'contextLimit')}</dd><dt>模型最大输出</dt><dd>{upstreamCapacity(value, 'maxOutputTokens')}</dd></> : <><dt>连接容量声明</dt><dd>上下文 {value.contextLimit.toLocaleString()} · 输出 {value.maxOutputTokens.toLocaleString()}</dd></>}</dl>
|
||||
{value.upstreamModel && <p className="mc-help">型号来自上游目录,能力按目录声明与显式设置保存;可在“推理与能力”查看已接入范围。</p>}
|
||||
<div className="mc-capabilities">{Object.entries(capabilityLabels).map(([key, title]) => <span key={key} data-capability={value.capabilities?.[key] ?? 'unknown'}>{title}:{capabilityStates[value.capabilities?.[key] ?? 'unknown']}</span>)}</div>
|
||||
{value.health.reason && <p className="mc-card-warning">{value.health.reason}{!!value.health.cooldownUntil && value.health.cooldownUntil > Date.now() && ' · 冷却至 ' + new Date(value.health.cooldownUntil).toLocaleTimeString()}</p>}
|
||||
@@ -149,12 +153,12 @@ export function ModelCenter({ onConfig, onLegacy, busy, runModel }: { onConfig:
|
||||
<label className="mc-full">允许的返回型号(可选,逗号分隔)<input value={draft.modelIdentityAliasesText} onChange={event => setDraft({ ...draft, modelIdentityAliasesText: event.target.value })} /></label>
|
||||
<label className="mc-full">型号映射依据<input required={draft.modelIdentityAliasesText.trim().length > 0} value={draft.modelIdentityAliasSource} placeholder="填写供应商映射说明或可核对的出处" onChange={event => setDraft({ ...draft, modelIdentityAliasSource: event.target.value })} /></label>
|
||||
<label>临时 API Key<input type="password" autoComplete="off" value={key} placeholder={draft.id ? '留空保留本次凭据' : '按服务要求填写'} onChange={event => setKey(event.target.value)} /></label>
|
||||
{passthrough ? <div className="mc-full" aria-label="连接容量策略"><strong>默认透传 · 不设本地上限</strong><p className="mc-help">完整发送上下文,不附加输出 token 上限。实际容量与限额由上游决定,上游错误原文保留。</p>{(draft.upstreamModel?.contextLimit || draft.upstreamModel?.maxOutputTokens) && <p className="mc-help">上游目录声明:{[draft.upstreamModel?.contextLimit && `上下文 ${draft.upstreamModel.contextLimit.toLocaleString()}`, draft.upstreamModel?.maxOutputTokens && `最大输出 ${draft.upstreamModel.maxOutputTokens.toLocaleString()}`].filter(Boolean).join(' · ')}。仅展示上游信息。</p>}</div> : <>
|
||||
{passthrough ? <div className="mc-full" aria-label="连接容量策略"><strong>默认透传 · 不设本地上限</strong><dl className="mc-capacity-facts"><div><dt>模型最大上下文</dt><dd aria-label="模型最大上下文">{upstreamCapacity(draft, 'contextLimit')}</dd></div><div><dt>模型最大输出</dt><dd aria-label="模型最大输出">{upstreamCapacity(draft, 'maxOutputTokens')}</dd></div></dl><p className="mc-help">容量数值来自当前型号的上游目录,仅供查看;上游未提供时显示本地无限制。完整发送上下文,不附加输出 token 上限,上游错误原文保留。</p></div> : <>
|
||||
<label>上下文上限<input type="number" required step="1" min="1000" value={draft.contextLimit} onChange={event => setDraft({ ...draft, contextLimit: Number(event.target.value) })} /></label>
|
||||
<label>输出上限<input type="number" required step="1" min="256" value={draft.maxOutputTokens} onChange={event => setDraft({ ...draft, maxOutputTokens: Number(event.target.value) })} /></label>
|
||||
<div className="mc-full"><p className="mc-help">容量优先使用上游目录声明;未提供时需要按供应商核对。推理可能共享输出额度。</p><button type="button" className="button secondary" onClick={() => setDraft({ ...draft, contextLimit: draft.upstreamModel?.contextLimit ?? DEFAULT_MODEL_CAPACITY.contextLimit, maxOutputTokens: draft.upstreamModel?.maxOutputTokens ?? DEFAULT_MODEL_CAPACITY.maxOutputTokens })}>{draft.upstreamModel?.contextLimit || draft.upstreamModel?.maxOutputTokens ? '采用上游容量' : '填入开发初始值'}</button></div>
|
||||
</>}
|
||||
<label>并发请求上限<input type="number" min="1" max="8" value={draft.concurrency} onChange={event => setDraft({ ...draft, concurrency: Number(event.target.value) })} /></label>
|
||||
<label>{runtimeConfig?.executionMode === 'unrestricted' ? '并发请求数(0 为不限)' : '并发请求上限'}<input type="number" min={runtimeConfig?.executionMode === 'unrestricted' ? 0 : 1} max={runtimeConfig?.executionMode === 'unrestricted' ? undefined : 8} value={draft.concurrency} onChange={event => setDraft({ ...draft, concurrency: Number(event.target.value) })} /></label>
|
||||
<label className="mc-checkbox"><input type="checkbox" checked={draft.requiresKey} onChange={event => setDraft({ ...draft, requiresKey: event.target.checked })} />服务需要 API Key</label></div>
|
||||
<label className="mc-checkbox"><input type="checkbox" checked={persistKey} onChange={event => setPersistKey(event.target.checked)} />本机加密保存本次填写的 API Key</label>
|
||||
<p className="mc-help"><CircleHelp size={14} />品牌仅用于分类,请选择服务实际提供的协议。能力检测会发起一次模型请求,可能产生费用;使用合成输入,不发送项目文件。文本检测不能证明工具或视觉能力。配置变化后需重新检测并核对凭据保存状态。</p>
|
||||
|
||||
Reference in New Issue
Block a user