fix: 扩展模型消息内容块数组配置

- 升级高级设置为消息级格式并兼容旧 system 配置

- 增加 VLM 图片首轮与文本追问的多轮连接验证
This commit is contained in:
2026-07-28 12:24:42 +08:00
parent dc35ddc3e4
commit f392c896f9
5 changed files with 227 additions and 45 deletions

View File

@@ -34,11 +34,11 @@ import {
import { resetModelAbility } from '#/views/ai/model/modelUtils/model-ability-utils';
type AgentHttpVersionPolicy = 'AUTO' | 'HTTP_1_1' | 'HTTP_2_PREFERRED';
type AgentSystemContentFormat = 'STRING' | 'TEXT_PARTS';
type AgentMessageContentFormat = 'STANDARD' | 'TEXT_PARTS';
interface ModelOptions {
agentHttpVersionPolicy: AgentHttpVersionPolicy;
agentSystemContentFormat: AgentSystemContentFormat;
agentMessageContentFormat: AgentMessageContentFormat;
[key: string]: unknown;
}
@@ -116,7 +116,7 @@ const formData = reactive<FormData>({
supportToolMessage: null,
options: {
agentHttpVersionPolicy: 'AUTO',
agentSystemContentFormat: 'STRING',
agentMessageContentFormat: 'STANDARD',
},
});
@@ -126,8 +126,8 @@ const agentHttpVersionOptions = [
{ label: 'HTTP/2 优先', value: 'HTTP_2_PREFERRED' },
] as const;
const agentSystemContentFormatOptions = [
{ label: '字符串(默认)', value: 'STRING' },
const agentMessageContentFormatOptions = [
{ label: '标准格式(默认)', value: 'STANDARD' },
{ label: '内容块数组', value: 'TEXT_PARTS' },
] as const;
@@ -140,10 +140,10 @@ const normalizeAgentHttpVersionPolicy = (
return 'AUTO';
};
const normalizeAgentSystemContentFormat = (
const normalizeAgentMessageContentFormat = (
value?: unknown,
): AgentSystemContentFormat => {
return value === 'TEXT_PARTS' ? 'TEXT_PARTS' : 'STRING';
): AgentMessageContentFormat => {
return value === 'TEXT_PARTS' ? 'TEXT_PARTS' : 'STANDARD';
};
const normalizeModelOptions = (options?: unknown): ModelOptions => {
@@ -151,14 +151,25 @@ const normalizeModelOptions = (options?: unknown): ModelOptions => {
options && typeof options === 'object' && !Array.isArray(options)
? (options as Record<string, unknown>)
: {};
const {
agentSystemContentFormat: legacyMessageContentFormat,
...currentOptions
} = source;
const currentMessageContentFormat = source.agentMessageContentFormat;
const messageContentFormat =
currentMessageContentFormat === null ||
currentMessageContentFormat === undefined ||
(typeof currentMessageContentFormat === 'string' &&
currentMessageContentFormat.trim() === '')
? legacyMessageContentFormat
: currentMessageContentFormat;
return {
...source,
...currentOptions,
agentHttpVersionPolicy: normalizeAgentHttpVersionPolicy(
source.agentHttpVersionPolicy,
),
agentSystemContentFormat: normalizeAgentSystemContentFormat(
source.agentSystemContentFormat,
),
agentMessageContentFormat:
normalizeAgentMessageContentFormat(messageContentFormat),
};
};
@@ -592,13 +603,13 @@ const save = async () => {
/>
</ElSelect>
</ElFormItem>
<ElFormItem label="System 消息格式">
<ElFormItem label="消息内容格式">
<ElSelect
v-model="formData.options.agentSystemContentFormat"
aria-label="System 消息格式"
v-model="formData.options.agentMessageContentFormat"
aria-label="消息内容格式"
>
<ElOption
v-for="item in agentSystemContentFormatOptions"
v-for="item in agentMessageContentFormatOptions"
:key="item.value"
:label="item.label"
:value="item.value"