feat: make chat model routing configurable

This commit is contained in:
2026-07-31 17:57:26 +08:00
parent 85a6da5949
commit ab2c945f0b
22 changed files with 567 additions and 88 deletions

View File

@@ -148,6 +148,7 @@ const modelForm = reactive({
allowSummary: 1,
allowReport: 1,
allowFixedInfo: 1,
allowSimpleKnowledge: 1,
allowDeepChat: 1,
});
@@ -311,6 +312,7 @@ function modelSceneLabel(scene: string) {
background_report: "周期报告",
background_summary: "摘要沉淀",
fixed_info: "固定信息问答",
simple_knowledge: "简单知识问答",
knowledge_grounded: "知识问答",
general_chat: "通用对话",
} as Record<string, string>)[scene] || scene || "未分类";
@@ -707,6 +709,7 @@ async function quickAddModel() {
allowSummary: 1,
allowReport: 1,
allowFixedInfo: 1,
allowSimpleKnowledge: 1,
allowDeepChat: 1,
});
ElMessage.success(`${provider.label} 模型已新增`);
@@ -814,6 +817,7 @@ function editModel(row: ModelItem) {
allowSummary: row.allowSummary ?? 1,
allowReport: row.allowReport ?? 1,
allowFixedInfo: row.allowFixedInfo ?? 1,
allowSimpleKnowledge: row.allowSimpleKnowledge ?? 1,
allowDeepChat: row.allowDeepChat ?? 1,
});
}
@@ -849,6 +853,7 @@ function resetModelForm() {
allowSummary: 1,
allowReport: 1,
allowFixedInfo: 1,
allowSimpleKnowledge: 1,
allowDeepChat: 1,
});
}
@@ -905,7 +910,7 @@ function normalizeSystemSettingValue(setting: (typeof systemSettingDefinitions)[
if (setting.type === "switch") {
return ["1", "true", "yes", "on", "启用"].includes(rawValue.toLowerCase());
}
if (setting.type === "text" || setting.type === "password") {
if (setting.type === "text" || setting.type === "password" || setting.type === "select") {
return rawValue;
}
const parsed = Number(rawValue);
@@ -1463,6 +1468,7 @@ function formatRecordDateTime(value: string, boundary: "start" | "end") {
<div>
<div class="entitlement-capabilities">
<el-checkbox v-model="modelForm.allowFixedInfo" :true-value="1" :false-value="0">固定信息</el-checkbox>
<el-checkbox v-model="modelForm.allowSimpleKnowledge" :true-value="1" :false-value="0">简单知识</el-checkbox>
<el-checkbox v-model="modelForm.allowDeepChat" :true-value="1" :false-value="0">深度对话</el-checkbox>
<el-checkbox v-model="modelForm.allowSummary" :true-value="1" :false-value="0">摘要沉淀</el-checkbox>
<el-checkbox v-model="modelForm.allowReport" :true-value="1" :false-value="0">周期报告</el-checkbox>
@@ -1491,6 +1497,7 @@ function formatRecordDateTime(value: string, boundary: "start" | "end") {
<div class="model-capability-tags">
<el-tag v-if="row.allowDeepChat === 1" size="small">深度对话</el-tag>
<el-tag v-if="row.allowFixedInfo === 1" size="small">固定信息</el-tag>
<el-tag v-if="row.allowSimpleKnowledge === 1" size="small">简单知识</el-tag>
<el-tag v-if="row.allowSummary === 1" size="small" type="success">摘要</el-tag>
<el-tag v-if="row.allowReport === 1" size="small" type="warning">报告</el-tag>
</div>
@@ -1544,6 +1551,18 @@ function formatRecordDateTime(value: string, boundary: "start" | "end") {
type="password"
show-password
/>
<el-select
v-else-if="setting.type === 'select'"
v-model="systemSettingValues[setting.key]"
:placeholder="setting.placeholder"
>
<el-option
v-for="option in setting.options || []"
:key="option.value"
:label="option.label"
:value="option.value"
/>
</el-select>
<el-switch v-else v-model="systemSettingValues[setting.key]" />
<small>{{ setting.description }}</small>
</label>

View File

@@ -1,5 +1,10 @@
export type SystemSettingValue = string | number | boolean;
type SystemSettingType = "number" | "switch" | "text" | "password";
type SystemSettingType = "number" | "switch" | "text" | "password" | "select";
interface SystemSettingOption {
label: string;
value: string;
}
export interface SystemSettingDefinition {
key: string;
@@ -9,6 +14,7 @@ export interface SystemSettingDefinition {
min?: number;
max?: number;
placeholder?: string;
options?: SystemSettingOption[];
description: string;
}
@@ -160,11 +166,16 @@ export const systemSettingSections: SystemSettingSection[] = [
description: "后台始终记录引用;此项控制用户端是否展示。",
},
{
key: "fixed_info_model_routing_enabled",
label: "固定信息模型分流",
type: "switch",
defaultValue: true,
description: "仅当本轮实际召回内容全部来自固定信息类知识库时使用对应低成本模型;关闭后统一使用默认主模型。",
key: "chat_model_routing_mode",
label: "正式问答模型分流规则",
type: "select",
defaultValue: "fixed_only",
options: [
{ label: "关闭分流(全部使用主模型)", value: "off" },
{ label: "仅固定信息(推荐)", value: "fixed_only" },
{ label: "保守分流(固定信息 + 简单知识)", value: "conservative" },
],
description: "“简单知识”只覆盖短问题、明确知识问法且仅召回课程/问答/通用知识;涉及个人情况、情绪、关系、建议或混合固定信息时仍使用主模型。",
},
{
key: "chat_max_active_requests",

View File

@@ -1741,18 +1741,19 @@ textarea {
gap: 7px;
}
.setting-field span {
.setting-field > span {
color: #223631;
font-weight: 600;
}
.setting-field small {
.setting-field > small {
color: #667a73;
line-height: 1.5;
}
.setting-field .el-input-number,
.setting-field .el-input {
.setting-field .el-input,
.setting-field .el-select {
width: 100%;
}

View File

@@ -213,6 +213,7 @@ export interface ModelItem {
allowSummary: number;
allowReport: number;
allowFixedInfo: number;
allowSimpleKnowledge: number;
allowDeepChat: number;
}