feat(admin): 面板暴露 contextWindow(可见可改)+ DocumentRef 语义注释同步
- 面板读写面与 maxTokens 逐处对齐:读 DTO 增 contextWindow(omitempty)、写请求 ContextWindow *int(缺失=保留、显式 0=未声明同义、负数 400)、回写 models.json;负数红线仍由 runtimeconfig.Group.Validate 唯一裁决,网关守卫只做「更早失败 + 面板可读字段名」。前端:类型 + 表单字段(提交前 /^\d+$/ 校验)+ 分组行角标 + Notice + 目录候选用早已解析却没人用的 contextLimit 预填。文案写明「重启后生效」(推导只在进程启动时算一次)。 - 顺手修既有红线违反:ProviderFields 87→76(抽 ApiKeyAndBudgetField)、LlmProviderForm 113→74(buildRequest 提为模块级纯函数)——本次碰过的文件里已无 >80 的函数,行为/文案逐字未变。 - DocumentRef 的 chars/truncated 注释从「抽取侧」改为「本回合注入侧」(全文长度只在 document-read 的 totalChars、extractTruncated 专指撞 8 MiB 安全上限);机械校验为空 ⇒ 代码零改动。 - 主会话独立验收:隔离 worktree Go 侧 build/vet + gateway/history 两包绿;主树 npx tsc --noEmit exit 0、npm run build 成功并 copy 到 internal/webui/dist;注释机械校验为空;变异由子代理复现(写路径不认该键 ⇒ 3 红;去掉网关负数守卫 ⇒ 400 变 500)。
This commit is contained in:
1 parent
3a01b4e236
commit
47e56ca13c
11 files changed
+355
-68
No files matched your search
@@ -2,9 +2,10 @@ import type { AdminLlmProvider } from "../../../lib/types";
|
||||
import { Button, Switch, Tag } from "../../../components/primitives";
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* 阶段 5 新增的字段(multimodal / reasoning.kind / per-persona 路由)的编辑界面。
|
||||
* 取值域一律由后端下发(GET /admin/llm 的 reasoningKinds / personaProviderOptions),
|
||||
* 本文件只提供展示文案与本地校验,不硬编码第二套枚举,也不拿任何示例值顶替。
|
||||
* 阶段 5 新增的字段(multimodal / reasoning.kind / per-persona 路由)与上下文
|
||||
* 窗口(contextWindow)的编辑界面。取值域一律由后端下发(GET /admin/llm 的
|
||||
* reasoningKinds / personaProviderOptions),本文件只提供展示文案与本地校验,
|
||||
* 不硬编码第二套枚举,也不拿任何示例值顶替。
|
||||
* -------------------------------------------------------------------------*/
|
||||
|
||||
/** 一个 persona 路由行的编辑草稿。 */
|
||||
@@ -107,6 +108,70 @@ export function MultimodalField({
|
||||
);
|
||||
}
|
||||
|
||||
/** API key 与 maxTokens 一行(同排布的两列)。抽出来只为让 ProviderFields 守住
|
||||
* ≤80 行:字段、文案与交互与抽取前逐字一致(编辑态下钥匙的提示语照旧跟着切换)。 */
|
||||
export function ApiKeyAndBudgetField({
|
||||
apiKey,
|
||||
maxTokens,
|
||||
editing,
|
||||
onApiKey,
|
||||
onMaxTokens,
|
||||
}: {
|
||||
apiKey: string;
|
||||
maxTokens: string;
|
||||
editing: boolean;
|
||||
onApiKey: (next: string) => void;
|
||||
onMaxTokens: (next: string) => void;
|
||||
}): React.ReactNode {
|
||||
return (
|
||||
<div className="grid grid-cols-1 gap-2 sm:grid-cols-2">
|
||||
<label className="block space-y-1">
|
||||
<span className="text-xs text-[var(--mu-text-lo)]">
|
||||
API key({editing ? "留空 = 保留原 key" : "写入 models.json,不回显"})
|
||||
</span>
|
||||
<input value={apiKey} onChange={(e) => onApiKey(e.target.value)} placeholder="sk-…" className={`${inputCls} w-full`} />
|
||||
</label>
|
||||
<label className="block space-y-1">
|
||||
<span className="text-xs text-[var(--mu-text-lo)]">maxTokens(该组预算,留空 = 保持/默认)</span>
|
||||
<input
|
||||
value={maxTokens}
|
||||
onChange={(e) => onMaxTokens(e.target.value)}
|
||||
inputMode="numeric"
|
||||
placeholder="8192"
|
||||
className={`${inputCls} w-full`}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** 模型上下文窗口(token)输入行 —— 与 maxTokens 同排布同交互:留空 = 不提交
|
||||
* 该键(缺省 = 保留已存窗口),填了才作为一个明确声明提交。窗口只有部署者知道
|
||||
* (本仓没有 provider 侧发现代码),因此面板既不预填猜测值、也不把它当成必填。 */
|
||||
export function ContextWindowField({
|
||||
value,
|
||||
onChange,
|
||||
}: {
|
||||
value: string;
|
||||
onChange: (next: string) => void;
|
||||
}): React.ReactNode {
|
||||
return (
|
||||
<label className="block space-y-1">
|
||||
<span className="text-xs text-[var(--mu-text-lo)]">上下文窗口 contextWindow(token,留空 = 未声明)</span>
|
||||
<input
|
||||
value={value}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
inputMode="numeric"
|
||||
placeholder="1048576"
|
||||
className={`${inputCls} w-full`}
|
||||
/>
|
||||
<span className="text-xs text-[var(--mu-text-lo)]">
|
||||
留空 = 未声明(按 128 Ki token 保守估算);填该模型真实窗口(如 1048576)才能吃到按窗口推导的上下文预算(重启后生效)。
|
||||
</span>
|
||||
</label>
|
||||
);
|
||||
}
|
||||
|
||||
/** reasoning.kind 的展示文案:键是后端下发的取值,值是**形状说明**。
|
||||
* 后端将来新增的取值没有文案时原样显示,不编造含义。 */
|
||||
const REASONING_LABEL: Record<string, string> = {
|
||||
|
||||
Reference in new issue
Block a user