feat: 增加 system 消息格式配置

- 模型管理支持选择字符串或内容块数组格式

- 验证连接携带 system 消息并复用正式运行时模型配置

- 补充配置映射与验证消息角色测试
This commit is contained in:
2026-07-27 15:47:58 +08:00
parent ba4253e13e
commit dc7e46260b
5 changed files with 109 additions and 3 deletions

View File

@@ -27,9 +27,11 @@ import {
} from '#/views/ai/model/modelUtils/model-ability-utils';
type AgentHttpVersionPolicy = 'AUTO' | 'HTTP_1_1' | 'HTTP_2_PREFERRED';
type AgentSystemContentFormat = 'STRING' | 'TEXT_PARTS';
interface ModelOptions {
agentHttpVersionPolicy: AgentHttpVersionPolicy;
agentSystemContentFormat: AgentSystemContentFormat;
[key: string]: unknown;
}
@@ -102,6 +104,7 @@ const formData = reactive<FormData>({
supportToolMessage: true,
options: {
agentHttpVersionPolicy: 'AUTO',
agentSystemContentFormat: 'STRING',
},
});
@@ -111,6 +114,11 @@ const agentHttpVersionOptions = [
{ label: 'HTTP/2 优先', value: 'HTTP_2_PREFERRED' },
] as const;
const agentSystemContentFormatOptions = [
{ label: '字符串(默认)', value: 'STRING' },
{ label: '内容块数组', value: 'TEXT_PARTS' },
] as const;
const normalizeAgentHttpVersionPolicy = (
value?: unknown,
): AgentHttpVersionPolicy => {
@@ -120,6 +128,12 @@ const normalizeAgentHttpVersionPolicy = (
return 'AUTO';
};
const normalizeAgentSystemContentFormat = (
value?: unknown,
): AgentSystemContentFormat => {
return value === 'TEXT_PARTS' ? 'TEXT_PARTS' : 'STRING';
};
const normalizeModelOptions = (options?: unknown): ModelOptions => {
const source =
options && typeof options === 'object' && !Array.isArray(options)
@@ -130,6 +144,9 @@ const normalizeModelOptions = (options?: unknown): ModelOptions => {
agentHttpVersionPolicy: normalizeAgentHttpVersionPolicy(
source.agentHttpVersionPolicy,
),
agentSystemContentFormat: normalizeAgentSystemContentFormat(
source.agentSystemContentFormat,
),
};
};
@@ -448,6 +465,19 @@ const save = async () => {
/>
</ElSelect>
</ElFormItem>
<ElFormItem v-if="!hasSpecialModelType" label="System 消息格式">
<ElSelect
v-model="formData.options.agentSystemContentFormat"
aria-label="System 消息格式"
>
<ElOption
v-for="item in agentSystemContentFormatOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</ElSelect>
</ElFormItem>
</div>
</ElForm>
</div>