@@ -9,11 +9,14 @@ import { ModelWaitSettings, type WaitSettings } from './ModelWaitSettings';
import { NativeParameters } from './NativeParameters' ;
import { ModelErrorDetails } from './ModelErrorDetails' ;
import { ModelBudgetSettings } from './ModelBudgetSettings' ;
import { modelRequestUrl , protocolLabel } from '../shared/contracts/model-endpoint.mjs' ;
type Connection = { id : string ; name : string ; brand : string ; protocol : string ; baseUrl : string ; model : string ; enabled : boolean ; revision : number ; hasKey : boolean ;
const previewUrl = ( value : { protocol : string ; baseUrl : string } ) = > { try { return modelRequestUrl ( value ) ; } catch { return '请填写有效的接口根地址' ; } } ;
type Connection = { id : string ; name : string ; brand : string ; protocol : string ; messagesAuth? : string ; baseUrl : string ; model : string ; enabled : boolean ; revision : number ; hasKey : boolean ;
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 } } ;
type Pool = { id? : string ; name : string ; members : { connectionId : string ; weight : number } [ ] ; strategy : string ; sticky : boolean ; maxAttempts : number ; revision? : number ; queueTimeoutMs : number } ;
type Attempt = { modelIdentity? : ModelIdentity ; diagnostic? : RuntimeFailure ; upstreamResponse ? : { requestId? : string | null } ; id : string ; connectionId : string ; poolId : string | null ; model : string ; protocol? : string ; streaming? : boolean ; rejections ? : { connectionName : string ; capability : string ; reason : string } [ ] ; status : string ; startedAt : string ; ordinal : number ; usageStatus : string ; reason? : string ; taskId? : string ; sessionId? : string ; runId : string ; requestArtifactId? : string ; responseArtifactId? : string ; responseSha256? : string ; responseRedacted? : boolean ; stream ? : { bytes : number ; capturedBytes? : number ; frames : number ; sha256 : string ; terminal : boolean } ; usage ? : { prompt_tokens? : number ; completion_tokens? : number } } ;
type Attempt = { modelIdentity? : ModelIdentity ; diagnostic? : RuntimeFailure ; requestUrl? : string ; upstreamResponse ? : { requestId? : string | null ; requestUrl? : string ; responseUrl? : string | null ; redirectMode? : string } ; id : string ; connectionId : string ; poolId : string | null ; model : string ; protocol? : string ; streaming? : boolean ; rejections ? : { connectionName : string ; capability : string ; reason : string } [ ] ; status : string ; startedAt : string ; ordinal : number ; usageStatus : string ; reason? : string ; taskId? : string ; sessionId? : string ; runId : string ; requestArtifactId? : string ; responseArtifactId? : string ; responseSha256? : string ; responseRedacted? : boolean ; stream ? : { bytes : number ; capturedBytes? : number ; frames : number ; sha256 : string ; terminal : boolean } ; usage ? : { prompt_tokens? : number ; completion_tokens? : number } } ;
type ImportRecord = { id : string ; source : string ; path : string ; enabled : boolean ; lastCheckedAt? : string ; lastSyncedAt? : string ; lastError? : string ; lastResult ? : { imported? : number ; conflicts? : string [ ] } } ;
type Center = { revision : number ; selected : { type : string ; id : string } ; waitSettings : WaitSettings ; connections : Connection [ ] ; pools : Pool [ ] ; imports : ImportRecord [ ] ; attempts : Attempt [ ] ; waiting : number } ;
type Operations = { checkedAt : string ; version : string ; scope : string ; activeTasks : number ; queue : number ; checks : { id : string ; title : string ; status : string ; detail : string } [ ] ;
@@ -30,7 +33,7 @@ export function ModelCenter({ onConfig, onLegacy, busy, runModel }: { onConfig:
const [ view , setView ] = useState < Center | null > ( null ) ;
const [ runtimeConfig , setRuntimeConfig ] = useState < Config | null > ( null ) ;
const [ tab , setTab ] = useState ( 'connections' ) ;
const [ draft , setDraft ] = useState < typeof initial & { id ? : string ; revision ? : number } > ( initial ) ;
const [ draft , setDraft ] = useState < typeof initial & { id ? : string ; revision ? : number ; messagesAuth ? : string ; nativeParameters ? : Record < string , unknown > ; outputTokenField ? : string } > ( initial ) ;
const [ editing , setEditing ] = useState ( false ) , [ key , setKey ] = useState ( '' ) ;
const [ nativeTarget , setNativeTarget ] = useState < Connection | null > ( null ) ;
const [ persistKey , setPersistKey ] = useState ( false ) , [ persistImports , setPersistImports ] = useState ( false ) ;
@@ -97,7 +100,7 @@ export function ModelCenter({ onConfig, onLegacy, busy, runModel }: { onConfig:
< optgroup label = "模型连接" > { view . connections . map ( connection = > < option key = { connection . id } value = { ( connection . id === 'legacy-default' ? 'legacy' : 'connection' ) + ':' + connection . id } disabled = { ! connection . enabled || connection . requiresKey && ! connection . hasKey } > { connection . name } · { connection . model || '尚未填写型号' } { connection . status !== 'configured' ? ' · ' + states [ connection . status ] : '' } < / option > ) } < / optgroup >
{ ! ! view . pools . length && < optgroup label = "模型池" > { view . pools . map ( pool = > < option key = { pool . id } value = { 'pool:' + pool . id } > { pool . name } · { pool . members . length } 个 连 接 < / option > ) } < / optgroup > }
< / select > < / label >
< div className = "mc-route-detail" > { runtimeConfig ? . mode === 'demo' ? '离线演示使用固定脚本,不调用大模型。' : selected ? . type === 'pool' ? '模型池按成员配置调度;每次实际连接和返回型号保存在请求账本。' : ( ( ) = > { const connection = view . connections . find ( c = > c . id === selected ? . id ) ; return connection ? ` ${ connection . protocol === 'responses' ? 'Responses' : 'Chat Completions' } · ${ connection . baseUrl } · 请求 ${ connection . model || '未配置' } ` : '请选择可用连接。' ; } ) ( ) } < / div >
< div className = "mc-route-detail" > { runtimeConfig ? . mode === 'demo' ? '离线演示使用固定脚本,不调用大模型。' : selected ? . type === 'pool' ? '模型池按成员配置调度;每次实际连接和返回型号保存在请求账本。' : ( ( ) = > { const connection = view . connections . find ( c = > c . id === selected ? . id ) ; return connection ? ` ${ protocolLabel ( connection . protocol ) } · ${ previewUrl ( connection ) } · 请求 ${ connection . model || '未配置' } ` : '请选择可用连接。' ; } ) ( ) } < / div >
{ runModel && < div className = "mc-run-model" > < strong > 当 前 会 话 最 近 运 行 < / strong > < span > { runModel . mode === 'demo' ? '离线演示' : runModel . routing ? . members ? . length ? runModel . routing . members . map ( member = > member . name + ' · ' + member . model ) . join ( '; ' ) : runModel . model } < / span > < small > 这 是 该 次 运 行 封 存 的 请 求 配 置 ; 实 际 返 回 型 号 请 看 请 求 账 本 。 更 改 默 认 选 择 不 会 改 写 旧 记 录 。 < / small > < / div > }
< / section >
{ tab === 'budgets' && runtimeConfig && < ModelBudgetSettings key = { JSON . stringify ( runtimeConfig ) } value = { runtimeConfig } disabled = { locked } onSave = { input = > void act ( async ( ) = > { await api ( '/model-center/runtime-budgets' , input ) ; if ( alive . current ) setNotice ( '运行预算已保存,当前模型选择保持。' ) ; } ) } / > }
@@ -108,8 +111,8 @@ export function ModelCenter({ onConfig, onLegacy, busy, runModel }: { onConfig:
{ tab === 'connections' && < >
< div className = "mc-section-title" > < div > < h3 > 模 型 连 接 < / h3 > < p > 保 存 多 条 连 接 后 可 在 上 方 切 换 ; 添 加 连 接 不 会 替 换 当 前 模 型 。 凭 据 可 选 择 本 机 加 密 保 存 。 < / p > < / div > < button className = "button primary" disabled = { locked } onClick = { addConnection } > < Plus size = { 16 } / > 添 加 连 接 < / button > < / div >
< 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 } · { value . protocol === 'responses' ? 'Responses' : 'Chat Completions' } { 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 > { value . baseUrl } < / dd > < dt > 凭 据 < / dt > < dd > { value . hasKey ? value . savedCredential ? . status === 'saved' ? '已设置,可从本机加密保存加载' : '已设置,重启需重新填写' : value . requiresKey ? '尚未填写' : '此服务可不填' } < / dd > < dt > 请 求 / 容 量 < / dt > < dd > { value . activeRequests } 在 途 · 并 发 { value . concurrency } · 上 下 文 { value . contextLimit . toLocaleString ( ) } < / dd > < / dl >
< 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 . hasKey ? value . savedCredential ? . status === 'saved' ? '已设置,可从本机加密保存加载' : '已设置,重启需重新填写' : value . requiresKey ? '尚未填写' : '此服务可不填' } < / dd > < dt > 请 求 / 容 量 < / dt > < dd > { value . activeRequests } 在 途 · 并 发 { value . concurrency } · 上 下 文 { value . contextLimit . toLocaleString ( ) } < / dd > < / dl >
< 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 > }
< footer > < button className = "button secondary" disabled = { locked || ! value . enabled } onClick = { ( ) = > void act ( async ( ) = > { const result = await api < { config : Config } > ( '/model-center/select' , { type : value . id === 'legacy-default' ? 'legacy' : 'connection' , id : value.id } ) ; onConfig ( result . config , { type : value . id === 'legacy-default' ? 'legacy' : 'connection' , id : value.id , name : value.name } ) ; } ) } > { selected ? . id === value . id ? < Check size = { 14 } / > : < Route size = { 14 } / > } { selected ? . id === value . id ? '当前使用' : '用于新任务' } < / button >
@@ -122,12 +125,14 @@ export function ModelCenter({ onConfig, onLegacy, busy, runModel }: { onConfig:
< h3 > { draft . id ? '编辑模型连接' : '添加模型连接' } < / h3 > < div className = "mc-form-grid" >
< label > 连 接 名 称 < input required value = { draft . name } onChange = { event = > setDraft ( { . . . draft , name : event.target.value } ) } / > < / label >
< label > 服 务 品 牌 < select value = { draft . brand } onChange = { event = > setDraft ( { . . . draft , brand : event.target.value } ) } > { [ '自定义' , 'OpenAI' , 'Claude 兼容代理' , 'DeepSeek' , 'Ollama' , 'vLLM' , '兼容服务' ] . map ( brand = > < option key = { brand } > { brand } < / option > ) } < / select > < / label >
< label > 接 口 协 议 < select aria-label = "接口协议" value = { draft . protocol } onChange = { event = > setDraft ( { . . . draft , protocol : event.target.value } ) } > < option value = "chat-completions" > Chat Completions < / option > < option value = "responses" > OpenAI Responses < / option > < / select > < / label >
< label > 接 口 协 议 < select aria-label = "接口协议" value = { draft . protocol } onChange = { event = > setDraft ( { . . . draft , protocol : event.target.value , nativeParameters : { } , outputTokenField : undefined } ) } > < option value = "chat-completions" > Chat Completions < / option > < option value = "responses" > OpenAI Responses < / option > < option value = "anthropic-messages" > Anthropic Messages < / option > < / select > < / label >
< label > 工 具 调 用 能 力 < select aria-label = "工具调用能力" value = { draft . capabilityDeclarations . tools } onChange = { event = > setDraft ( { . . . draft , capabilityDeclarations : { . . . draft . capabilityDeclarations , tools : event.target.value } } ) } > < option value = "supported" > 服 务 声 明 支 持 < / option > < option value = "unknown" > 尚 未 确 定 < / option > < option value = "unsupported" > 明 确 不 支 持 < / option > < / select > < / label >
< label > 流 式 能 力 < select aria-label = "流式能力" value = { draft . capabilityDeclarations . streaming } onChange = { event = > setDraft ( { . . . draft , streaming : event.target.value === 'supported' && draft . streaming , capabilityDeclarations : { . . . draft . capabilityDeclarations , streaming : event.target.value } } ) } > < option value = "unknown" > 尚 未 确 定 < / option > < option value = "supported" > 服 务 声 明 支 持 < / option > < option value = "unsupported" > 明 确 不 支 持 < / option > < / select > < / label >
< label > 视 觉 能 力 < select aria-label = "视觉能力" value = { draft . capabilityDeclarations . vision } onChange = { event = > setDraft ( { . . . draft , capabilityDeclarations : { . . . draft . capabilityDeclarations , vision :event.target.value } } ) } > < option value = "unknown" > 尚 未 确 定 < / option > < option value = "supported" > 服 务 声 明 支 持 < / option > < option value = "unsupported" > 明 确 不 支 持 < / option > < / select > < / label >
< label className = "mc-checkbox" > < input type = "checkbox" checked = { draft . streaming } disabled = { draft . capabilityDeclarations . streaming !== 'supported' } onChange = { event = > setDraft ( { . . . draft , streaming : event.target.checked } ) } / > 使 用 流 式 输 出 < / label >
< label className = "mc-full" > 接 口 根 地 址 < input type = "url" required value = { draft . baseUrl } onChange = { event = > setDraft ( { . . . draft , baseUrl : event.target.value } ) } / > < / label >
< p className = "mc-help mc-full" aria-label = "请求地址预览" > POST { previewUrl ( draft ) } < br / > { draft . protocol === 'anthropic-messages' ? '填写服务根地址或 /v1 根地址,工作台补齐 /v1/messages。鉴权按供应商文档选择。' : '工作台按此根地址追加协议路径;服务要求 /v1 时,请在根地址中填写。' } 切 换 协 议 会 重 置 本 表 单 的 原 生 参 数 , 保 存 后 从 新 任 务 生 效 。 < / p >
{ draft . protocol === 'anthropic-messages' && < label > Messages 鉴 权 < select aria-label = "Messages 鉴权" value = { draft . messagesAuth ? ? 'api-key' } onChange = { event = > setDraft ( { . . . draft , messagesAuth : event.target.value } ) } > < option value = "api-key" > x - api - key ( Anthropic 标 准 ) < / option > < option value = "bearer" > Bearer ( 兼 容 服 务 ) < / option > < / select > < / label > }
< label > 请 求 模 型 名 称 < input required value = { draft . model } onChange = { event = > setDraft ( { . . . draft , model : event.target.value } ) } / > < / label >
< label > 型 号 核 对 < select aria-label = "型号核对" value = { draft . modelIdentityPolicy } onChange = { event = > setDraft ( { . . . draft , modelIdentityPolicy : event.target.value } ) } > < option value = "record" > 记 录 请 求 与 返 回 型 号 < / option > < option value = "require-match" > 无 法 核 对 或 不 一 致 时 暂 停 < / option > < / select > < / label >
< label className = "mc-full" > 允 许 的 返 回 型 号 ( 可 选 , 逗 号 分 隔 ) < input value = { draft . modelIdentityAliasesText } onChange = { event = > setDraft ( { . . . draft , modelIdentityAliasesText : event.target.value } ) } / > < / label >
@@ -177,7 +182,7 @@ export function ModelCenter({ onConfig, onLegacy, busy, runModel }: { onConfig:
< fieldset > < legend > 模 型 池 成 员 与 权 重 < / legend > { view . connections . map ( connection = > { const member = pool . members . find ( value = > value . connectionId === connection . id ) ; return < label key = { connection . id } className = "mc-member-choice" > < input type = "checkbox" checked = { ! ! member } onChange = { event = > setPool ( { . . . pool , members : event.target.checked ? [ . . . pool . members , { connectionId : connection.id , weight : 1 } ] : pool . members . filter ( value = > value . connectionId !== connection . id ) } ) } / > < span > { connection . name } < small > { connection . model || '尚未选择模型' } · { states [ connection . status ] } < / small > < / span > < input type = "number" aria-label = { connection . name + '权重' } disabled = { ! member } min = "1" max = "10" value = { member ? . weight ? ? 1 } onChange = { event = > setPool ( { . . . pool , members : pool.members.map ( value = > value . connectionId === connection . id ? { . . . value , weight : Number ( event . target . value ) } : value ) } ) } / > < / label > ; } ) } < / fieldset >
< div className = "mc-actions" > < button className = "button secondary" type = "button" onClick = { ( ) = > setPoolEditing ( false ) } > 取 消 < / button > < button className = "button primary" disabled = { locked || ! pool . members . length } > 保 存 模 型 池 < / button > < / div > < / form > }
< / > }
{ tab === 'attempts' && < > < div className = "mc-section-title" > < div > < h3 > 请 求 账 本 < / h3 > < p > 最 近 100 次 物 理 请 求 ; 最 多 保 存 1000 次 。 未 知 用 量 保 持 未 知 。 < / p > < / div > < span > { view . attempts . length } 条 记 录 < / span > < / div > { ! view . attempts . length && < p className = "mc-empty" > 当 前 没 有 模 型 中 心 请 求 。 选 择 连 接 或 模 型 池 执 行 任 务 后 , 实 际 尝 试 会 保 存 在 这 里 。 < / p > } < div className = "mc-attempts" > { view . attempts . map ( value = > < article key = { value . id } > < div > < span className = { 'mc-state mc-state-' + value . status } > { states [ value . status ] } < / span > < strong > { value . model } < / strong > < time > { new Date ( value . startedAt ) . toLocaleString ( ) } < / time > < / div > < p > { view . connections . find ( connection = > connection . id === value . connectionId ) ? . name || '未派发' } · { value . protocol === 'responses' ? 'Responses' : value . protocol ? 'Chat Completions' : '能力筛选' } { value . streaming ? ' · 流式' : '' } · { value . ordinal ? '尝试 ' + value . ordinal : '未发送' } · { value . usageStatus === 'reported' ? ` ${ value . usage ? . prompt_tokens ? ? '?' } 输入 / ${ value . usage ? . completion_tokens ? ? '?' } 输出 tokens ` : value . usageStatus === 'not_dispatched' ? '未产生请求用量' : '用量未知' } < / p > < code > Run { value . runId } < / code > { value . stream && < div className = "mc-stream-receipt" > < p > { value . stream . terminal ? "响应完整终结" : "响应未完整,片段保留待核对" } · 已 接 收 { value . stream . bytes . toLocaleString ( ) } bytes · { value . stream . frames } 个 事 件 { value . stream . capturedBytes !== undefined && value . stream . capturedBytes < value . stream . bytes ? " · 仅保存上限内片段" : "" } < / p > < code > 原 流 SHA256 { value . stream . sha256 } < / code > { value . responseSha256 && < code > 工 件 SHA256 { value . responseSha256 } { value . responseRedacted ? "(已脱敏)" : "" } < / code > } { value . sessionId && value . responseArtifactId && < button className = "button secondary" disabled = { working } onClick = { ( ) = > void act ( async ( ) = > { await downloadArtifact ( value . sessionId ! , value . responseArtifactId ! , "model-stream-" + value . id + ".sse" ) ; } ) } > 下 载 已 保 存 的 响 应 < / button > } < / div > } { value . reason && < p className = "mc-card-warning" > { value . reason } < / p > } { < ModelIdentityDetails identity = { value . modelIdentity } requestedModel = { value . model } / > } { value . diagnostic && < ModelErrorDetails failure = { value . diagnostic } / > } { ! value . diagnostic && value . upstreamResponse ? . requestId && < p className = "mc-help" > 上 游 请 求 ID : { value . upstreamResponse . requestId } < / p > } { value . requestArtifactId && value . sessionId && < button className = "button secondary" disabled = { working } onClick = { ( ) = > void act ( async ( ) = > { await downloadArtifact ( value . sessionId ! , value . requestArtifactId ! , "model-request-" + value . id + ".json" ) ; } ) } > 下 载 实 际 请 求 < / button > } { ! ! value . rejections ? . length && < p className = "mc-route-rejections" > { value . rejections . map ( item = > item . connectionName + ': ' + ( capabilityLabels [ item . capability ] ? ? item . capability ) + ' · ' + item . reason ) . join ( '; ' ) } < / p > } < / article > ) } < / div > < / > }
{ tab === 'attempts' && < > < div className = "mc-section-title" > < div > < h3 > 请 求 账 本 < / h3 > < p > 最 近 100 次 物 理 请 求 ; 最 多 保 存 1000 次 。 未 知 用 量 保 持 未 知 。 < / p > < / div > < span > { view . attempts . length } 条 记 录 < / span > < / div > { ! view . attempts . length && < p className = "mc-empty" > 当 前 没 有 模 型 中 心 请 求 。 选 择 连 接 或 模 型 池 执 行 任 务 后 , 实 际 尝 试 会 保 存 在 这 里 。 < / p > } < div className = "mc-attempts" > { view . attempts . map ( value = > < article key = { value . id } > < div > < span className = { 'mc-state mc-state-' + value . status } > { states [ value . status ] } < / span > < strong > { value . model } < / strong > < time > { new Date ( value . startedAt ) . toLocaleString ( ) } < / time > < / div > < p > { view . connections . find ( connection = > connection . id === value . connectionId ) ? . name || '未派发' } · { value . protocol ? protocolLabel ( value . protocol ) : '能力筛选' } { value . streaming ? ' · 流式' : '' } · { value . ordinal ? '尝试 ' + value . ordinal : '未发送' } · { value . usageStatus === 'reported' ? ` ${ value . usage ? . prompt_tokens ? ? '?' } 输入 / ${ value . usage ? . completion_tokens ? ? '?' } 输出 tokens ` : value . usageStatus === 'not_dispatched' ? '未产生请求用量' : '用量未知' } < / p > < code > Run { value . runId } < / code > { value . stream && < div className = "mc-stream-receipt" > < p > { value . stream . terminal ? "响应完整终结" : "响应未完整,片段保留待核对" } · 已 接 收 { value . stream . bytes . toLocaleString ( ) } bytes · { value . stream . frames } 个 事 件 { value . stream . capturedBytes !== undefined && value . stream . capturedBytes < value . stream . bytes ? " · 仅保存上限内片段" : "" } < / p > < code > 原 流 SHA256 { value . stream . sha256 } < / code > { value . responseSha256 && < code > 工 件 SHA256 { value . responseSha256 } { value . responseRedacted ? "(已脱敏)" : "" } < / code > } { value . sessionId && value . responseArtifactId && < button className = "button secondary" disabled = { working } onClick = { ( ) = > void act ( async ( ) = > { await downloadArtifact ( value . sessionId ! , value . responseArtifactId ! , "model-stream-" + value . id + ".sse" ) ; } ) } > 下 载 已 保 存 的 响 应 < / button > } < / div > } { value . requestUrl && < p className = "mc-request-url" > 请 求 地 址 : { value . requestUrl } { value . upstreamResponse ? . responseUrl && < > < br / > 响 应 地 址 : { value . upstreamResponse . responseUrl } < / > } < / p > } { value . reason && < p className = "mc-card-warning" > { value . reason } < / p > } { < ModelIdentityDetails identity = { value . modelIdentity } requestedModel = { value . model } / > } { value . diagnostic && < ModelErrorDetails failure = { value . diagnostic } / > } { ! value . diagnostic && value . upstreamResponse ? . requestId && < p className = "mc-help" > 上 游 请 求 ID : { value . upstreamResponse . requestId } < / p > } { value . requestArtifactId && value . sessionId && < button className = "button secondary" disabled = { working } onClick = { ( ) = > void act ( async ( ) = > { await downloadArtifact ( value . sessionId ! , value . requestArtifactId ! , "model-request-" + value . id + ".json" ) ; } ) } > 下 载 实 际 请 求 < / button > } { ! ! value . rejections ? . length && < p className = "mc-route-rejections" > { value . rejections . map ( item = > item . connectionName + ': ' + ( capabilityLabels [ item . capability ] ? ? item . capability ) + ' · ' + item . reason ) . join ( '; ' ) } < / p > } < / article > ) } < / div > < / > }
{ tab === 'imports' && < > < div className = "mc-section-title" > < div > < h3 > 已 有 配 置 导 入 < / h3 > < p > 先 预 览 来 源 和 模 型 , 再 导 入 。 原 客 户 端 配 置 保 持 原 样 。 < / p > < / div > < button className = "button secondary" disabled = { working } onClick = { ( ) = > void act ( async ( ) = > { const value = await api < { sources : typeof discovery } > ( '/model-center/imports' ) ; if ( alive . current ) setDiscovery ( value . sources ) ; } ) } > 识 别 本 机 来 源 < / button > < / div >
{ view . imports . length > 0 && < > < h4 > 已 登 记 来 源 < / h4 > { view . imports . map ( value = > < article className = "mc-import-source" key = { value . id } > < strong > { value . source } < / strong > < code > { value . path } < / code > < span > { value . enabled ? '每分钟检查' : '自动同步已关闭' } < / span > { value . lastCheckedAt && < p > 最 近 检 查 { new Date ( value . lastCheckedAt ) . toLocaleString ( ) } < / p > } { value . lastError && < p className = "mc-card-warning" > { value . lastError } < / p > } { ! ! value . lastResult ? . conflicts ? . length && < p className = "mc-card-warning" > 有 { value . lastResult . conflicts . length } 项 与 手 动 修 改 冲 突 , 已 保 留 工 作 台 中 的 修 改 。 < / p > } < button className = "button secondary" disabled = { locked } onClick = { ( ) = > void act ( async ( ) = > { await api ( '/model-center/import-toggle' , { id : value.id , enabled : ! value . enabled } ) ; } ) } > { value . enabled ? '关闭自动同步' : '启用自动同步' } < / button > < / article > ) } < button className = "button secondary" disabled = { locked || ! view . imports . some ( value = > value . enabled ) } onClick = { ( ) = > void act ( async ( ) = > { const result = await api < { results : { imported? : string [ ] ; conflicts? : string [ ] ; error? : string } [ ] } > ( '/model-center/import-sync' , { } ) ; const imported = result . results . reduce ( ( sum , value ) = > sum + ( value . imported ? . length ? ? 0 ) , 0 ) ; const conflicts = result . results . reduce ( ( sum , value ) = > sum + ( value . conflicts ? . length ? ? 0 ) , 0 ) ; if ( alive . current ) setNotice ( ` 已检查启用来源:更新 ${ imported } 项,冲突 ${ conflicts } 项。 ` ) ; } ) } > 立 即 同 步 已 启 用 来 源 < / button > < / > }
{ discovery . map ( value = > < article className = "mc-import-source" key = { value . source } > < strong > { value . source } < / strong > < code > { value . path || '当前版本尚无可发现的配置路径' } < / code > < span > { value . available ? value . supported ? '可预览' : '当前不支持' : '未发现' } < / span > { value . detail && < p > { value . detail } < / p > } < button className = "button secondary" disabled = { ! value . available || ! value . supported || locked } onClick = { ( ) = > { setImportSource ( value . source ) ; setImportPath ( value . path ) ; } } > 选 择 来 源 < / button > < / article > ) }