feat: 增强智能体模型调用兼容能力
- 增加模型流式开关和 HTTP 传输策略配置 - 使用 AgentScope 执行基础连接、流式与 VLM 双阶段验证 - 固定多模态校验图片并统一验证状态展示
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
/* eslint-disable vue/no-mutating-props */
|
||||
import type {AgentInfo, AgentOption} from '../types';
|
||||
import type { AgentInfo, AgentOption } from '../types';
|
||||
|
||||
import {InfoFilled} from '@element-plus/icons-vue';
|
||||
import { InfoFilled } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
ElInputNumber,
|
||||
ElOption,
|
||||
ElSelect,
|
||||
ElSwitch,
|
||||
ElTooltip,
|
||||
} from 'element-plus';
|
||||
|
||||
@@ -75,6 +76,27 @@ const emit = defineEmits<{ change: [] }>();
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem>
|
||||
<template #label>
|
||||
<span class="agent-form__label">
|
||||
模型流式响应
|
||||
<ElTooltip
|
||||
content="关闭后,模型会在生成完成后一次性返回回答。"
|
||||
effect="light"
|
||||
placement="top"
|
||||
>
|
||||
<ElIcon class="agent-form__info" aria-label="模型流式响应说明">
|
||||
<InfoFilled />
|
||||
</ElIcon>
|
||||
</ElTooltip>
|
||||
</span>
|
||||
</template>
|
||||
<ElSwitch
|
||||
v-model="agent.generationConfigJson!.stream"
|
||||
aria-label="模型流式响应"
|
||||
@change="emit('change')"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="系统提示词">
|
||||
<ElInput
|
||||
v-model="agent.promptConfigJson!.systemPrompt"
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import {
|
||||
createEmptyAgent,
|
||||
useAgentDesignerState,
|
||||
} from './useAgentDesignerState';
|
||||
|
||||
describe('useAgentDesignerState generation stream', () => {
|
||||
it('defaults new and legacy agents to streaming', () => {
|
||||
expect(createEmptyAgent().generationConfigJson?.stream).toBe(true);
|
||||
|
||||
const designer = useAgentDesignerState();
|
||||
designer.reset({ name: '旧智能体' });
|
||||
|
||||
expect(designer.state.agent.generationConfigJson?.stream).toBe(true);
|
||||
expect(designer.buildPayloadAgent().generationConfigJson?.stream).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
it('preserves an explicitly disabled stream value in the payload', () => {
|
||||
const designer = useAgentDesignerState();
|
||||
designer.reset({
|
||||
name: '非流式智能体',
|
||||
generationConfigJson: { stream: false },
|
||||
});
|
||||
|
||||
expect(designer.state.agent.generationConfigJson?.stream).toBe(false);
|
||||
expect(designer.buildPayloadAgent().generationConfigJson?.stream).toBe(
|
||||
false,
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -84,6 +84,7 @@ export function createEmptyAgent(): AgentInfo {
|
||||
categoryId: '',
|
||||
modelId: '',
|
||||
promptConfigJson: { systemPrompt: '' },
|
||||
generationConfigJson: { stream: true },
|
||||
memoryConfigJson: {
|
||||
compressionParameter: {
|
||||
enabled: true,
|
||||
@@ -111,6 +112,10 @@ function normalizeAgent(agent?: AgentInfo): AgentInfo {
|
||||
systemPrompt: '',
|
||||
...source.promptConfigJson,
|
||||
},
|
||||
generationConfigJson: {
|
||||
...source.generationConfigJson,
|
||||
stream: source.generationConfigJson?.stream !== false,
|
||||
},
|
||||
memoryConfigJson: {
|
||||
...memoryConfig,
|
||||
compressionParameter: {
|
||||
@@ -356,6 +361,10 @@ export function useAgentDesignerState() {
|
||||
interactionConfigJson: buildInteractionConfigPayload(
|
||||
state.agent.interactionConfigJson,
|
||||
),
|
||||
generationConfigJson: {
|
||||
...state.agent.generationConfigJson,
|
||||
stream: state.agent.generationConfigJson?.stream !== false,
|
||||
},
|
||||
memoryConfigJson: {
|
||||
...restMemoryConfigJson,
|
||||
compressionParameter: {
|
||||
|
||||
Reference in New Issue
Block a user