42 lines
4.8 KiB
TypeScript
42 lines
4.8 KiB
TypeScript
import { changeReasoningSetting, modelFeatureRows, modelParameterProfile, parameterProfiles, reasoningSetting } from '../shared/contracts/model-parameter-profiles.mjs';
|
||
import type { NativeConnection } from './NativeParameters';
|
||
|
||
const effortLabels: Record<string, string> = { minimal: '最低', low: '低', medium: '中', high: '高', xhigh: '很高', max: '最高' };
|
||
export function ReasoningSettings({ connection, parameters, profile, busy, onProfile, onChange }: {
|
||
connection: NativeConnection; parameters: Record<string, unknown> | null; profile: string; busy: boolean;
|
||
onProfile: (value: string) => void; onChange: (value: Record<string, unknown>) => void;
|
||
}) {
|
||
const configured = { ...connection, parameterProfile: profile }, resolved = modelParameterProfile(configured);
|
||
const setting = reasoningSetting(configured, parameters ?? {}), disabled = busy || !parameters;
|
||
const change = (field: string, value: string | number) => { if (parameters) onChange(changeReasoningSetting(configured, parameters, field, value)); };
|
||
const efforts = [...new Set([...resolved.efforts, ...(setting.effort ? [setting.effort] : [])])];
|
||
return <fieldset className="mc-reasoning">
|
||
<legend>推理设置</legend>
|
||
<div className="mc-form-grid">
|
||
<label>参数配置档<select aria-label="参数配置档" value={profile} disabled={disabled} onChange={event => onProfile(event.target.value)}>
|
||
{parameterProfiles(connection.protocol).map(value => <option key={value.id} value={value.id}>{value.label}</option>)}
|
||
</select></label>
|
||
<label>推理模式<select aria-label="推理模式" value={setting.mode} disabled={disabled} onChange={event => change('mode', event.target.value)}>
|
||
<option value="default">跟随模型默认</option><option value="disabled" disabled={!resolved.modes.includes('disabled')}>关闭推理</option>
|
||
<option value="enabled" disabled={!resolved.modes.includes('enabled')}>{connection.protocol === 'anthropic-messages' ? '开启 · 指定推理预算' : '开启推理'}</option>
|
||
{connection.protocol === 'anthropic-messages' && <option value="adaptive" disabled={!resolved.modes.includes('adaptive')}>开启 · 自适应推理</option>}
|
||
</select></label>
|
||
<label>推理强度<select aria-label="推理强度" value={setting.effort} disabled={disabled || setting.mode === 'disabled' || !resolved.efforts.length && !setting.effort} onChange={event => change('effort', event.target.value)}>
|
||
<option value="">跟随模型默认</option>{efforts.map(value => <option key={value} value={value}>{effortLabels[value] ?? value}({value})</option>)}
|
||
</select></label>
|
||
{connection.protocol === 'anthropic-messages' && setting.mode === 'enabled' && <label>推理预算 tokens<input aria-label="推理预算 tokens" type="number" min={1024} step={1} value={setting.budget} disabled={disabled} onChange={event => change('budget', Number(event.target.value))} /></label>}
|
||
</div>
|
||
<p className="mc-help">当前格式:{resolved.label}。{resolved.source}。自定义代理可按实际兼容格式选择配置档,保存后用于新任务。</p>
|
||
<p className="mc-help">强度越高通常需要更多时间和输出 tokens;推理与最终答复共用原输出预算。具体型号支持的开关和档位以上游为准,设置不会自动提高预算。</p>
|
||
{connection.upstreamModel && <p className="mc-help">已同步该型号的上游目录声明;提供了档位或模式时,按声明限制可选项。目录没有提供的能力仍待确认。</p>}
|
||
{connection.protocol === 'anthropic-messages' ? <p className="mc-help">指定预算至少 1024 tokens,且须小于本次任务实际输出上限。指定预算的能力检测使用当前输出上限,会消耗模型额度;自适应模式与强度需服务支持。</p>
|
||
: resolved.id === 'deepseek' && connection.protocol === 'chat-completions' ? <p className="mc-help">DeepSeek 使用 thinking 开关与 low / high / max 强度;工具往返携带对应的原生推理状态。</p>
|
||
: <p className="mc-help">关闭推理发送 none,仅适用于接受该值的型号;GPT-6.1 Sol 不支持 none / minimal。可选择受支持的强度或保留默认。</p>}
|
||
{!parameters && <p className="mc-card-warning">请先修正下方 JSON,推理控件会同步恢复。</p>}
|
||
<details className="mc-feature-scope"><summary>查看接口能力与接入范围</summary>
|
||
<p>品牌、型号与模型列表用于匹配配置,能力声明和单项检测结果按原来源保留。型号列表通常不包含完整功能元数据。</p>
|
||
<table><thead><tr><th>功能</th><th>接口能力</th><th>本地接入</th></tr></thead><tbody>{modelFeatureRows(connection).map(row => <tr key={row.name}><th scope="row">{row.name}</th><td>{row.upstream}</td><td>{row.local}</td></tr>)}</tbody></table>
|
||
</details>
|
||
</fieldset>;
|
||
}
|