Trim online context from AI chat editors
This commit is contained in:
@@ -3,7 +3,11 @@ import type { DesignPreviewData } from './types';
|
||||
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import { Check, Copy, X } from '@vben/icons';
|
||||
import {
|
||||
Check,
|
||||
Close as X,
|
||||
CopyDocument as Copy,
|
||||
} from '@element-plus/icons-vue';
|
||||
|
||||
import {
|
||||
ElButton,
|
||||
@@ -71,13 +75,14 @@ const summaryItems = computed(() => {
|
||||
|
||||
const fieldItems = computed(() => {
|
||||
const source = payload.value as Record<string, any>;
|
||||
const fields = source.form_fields || source.fields || source.schema?.fields;
|
||||
const fields =
|
||||
source.schema_fields || source.form_fields || source.fields || source.schema?.fields;
|
||||
return Array.isArray(fields) ? fields.slice(0, 12) : [];
|
||||
});
|
||||
|
||||
const tableItems = computed(() => {
|
||||
const source = payload.value as Record<string, any>;
|
||||
const tables = source.table_configs || source.tables || source.data_sources;
|
||||
const tables = source.data_sources || source.table_configs || source.tables;
|
||||
return Array.isArray(tables) ? tables.slice(0, 8) : [];
|
||||
});
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ export function useChatApi(props: AiChatPanelProps): {
|
||||
const adapter: ChatApiAdapter = {
|
||||
sendMessage: (
|
||||
message: string,
|
||||
inputs: Record<string, any> | undefined,
|
||||
_inputs: Record<string, any> | undefined,
|
||||
onEvent: (event: StreamEvent) => void,
|
||||
onError: (error: Error) => void,
|
||||
onComplete: () => void,
|
||||
@@ -110,16 +110,12 @@ export function useChatApi(props: AiChatPanelProps): {
|
||||
type: att.type,
|
||||
}));
|
||||
|
||||
// 从 inputs 中提取 form_code(如果存在)
|
||||
const formCode = inputs?.form_code;
|
||||
|
||||
return sendAgentMessageStream(
|
||||
props.agentId,
|
||||
{
|
||||
message,
|
||||
conversation_id: conversationId.value || undefined,
|
||||
attachments: attachmentInputs,
|
||||
form_code: formCode,
|
||||
},
|
||||
(event) => {
|
||||
// 捕获 conversation_id
|
||||
|
||||
@@ -97,8 +97,8 @@ export function useEventHandler(config: EventHandlerConfig) {
|
||||
title: configData.title || '设计预览',
|
||||
data: configData.data || {},
|
||||
nodeId: event.node_id || '',
|
||||
form_fields: configData.form_fields,
|
||||
table_configs: configData.table_configs,
|
||||
data_sources: configData.data_sources || configData.table_configs,
|
||||
schema_fields: configData.schema_fields || configData.form_fields,
|
||||
layoutOptions: configData.layoutOptions,
|
||||
themeOptions: configData.themeOptions,
|
||||
};
|
||||
|
||||
@@ -70,8 +70,8 @@ export interface DesignPreviewData {
|
||||
title: string;
|
||||
data: Record<string, any>;
|
||||
nodeId: string;
|
||||
form_fields?: any[];
|
||||
table_configs?: any[];
|
||||
data_sources?: any[];
|
||||
schema_fields?: any[];
|
||||
layoutOptions?: any[];
|
||||
themeOptions?: any[];
|
||||
}
|
||||
@@ -89,6 +89,7 @@ export interface NodeEvent {
|
||||
node_id: string;
|
||||
node_type?: string;
|
||||
node_label?: string;
|
||||
event_type?: string;
|
||||
status?: 'failed' | 'running' | 'success';
|
||||
inputs?: Record<string, any>;
|
||||
outputs?: Record<string, any>;
|
||||
@@ -96,6 +97,7 @@ export interface NodeEvent {
|
||||
tokens_used?: number;
|
||||
error_message?: string;
|
||||
loop_iteration?: number;
|
||||
warnings?: any[];
|
||||
}
|
||||
|
||||
/** 循环迭代事件 */
|
||||
@@ -132,7 +134,7 @@ export interface AiChatPanelProps {
|
||||
agent?: AgentInfo | null;
|
||||
/** 当前对话 ID(agent-chat 模式用于加载历史) */
|
||||
conversationId?: null | string;
|
||||
/** 初始输入参数(如 form_code 等系统变量) */
|
||||
/** 初始输入参数 */
|
||||
initialInputs?: Record<string, any>;
|
||||
|
||||
// ========== 功能开关 ==========
|
||||
|
||||
@@ -71,9 +71,9 @@ const waitingConfig = ref<any>(null);
|
||||
// 设计面板状态
|
||||
const currentDesign = ref<null | {
|
||||
data: any;
|
||||
form_fields?: any[];
|
||||
data_sources?: any[];
|
||||
nodeId: string;
|
||||
table_configs?: any[];
|
||||
schema_fields?: any[];
|
||||
title: string;
|
||||
type: string;
|
||||
}>(null);
|
||||
@@ -273,7 +273,7 @@ async function doSendMessage(message: string, addUserMessage: boolean = true) {
|
||||
scrollToBottom();
|
||||
|
||||
// 发送流式请求
|
||||
// 系统变量(application_id 等)由 API 层自动注入
|
||||
// 业务上下文由 API 层按 Agent 配置解析
|
||||
cancelStream = sendAgentMessageStream(
|
||||
props.agentId,
|
||||
{
|
||||
@@ -491,8 +491,8 @@ function handleStreamEvent(
|
||||
$t('ai-platform.agent.chatPanel.designPreview'),
|
||||
data: configData.data || {},
|
||||
nodeId: event.node_id || '',
|
||||
form_fields: configData.form_fields || [],
|
||||
table_configs: configData.table_configs || [],
|
||||
data_sources: configData.data_sources || configData.table_configs || [],
|
||||
schema_fields: configData.schema_fields || configData.form_fields || [],
|
||||
};
|
||||
showDesignPanel.value = true;
|
||||
|
||||
@@ -838,8 +838,8 @@ onUnmounted(() => {
|
||||
title: currentDesign.title,
|
||||
data: currentDesign.data,
|
||||
nodeId: currentDesign.nodeId,
|
||||
form_fields: currentDesign.form_fields,
|
||||
table_configs: currentDesign.table_configs,
|
||||
data_sources: currentDesign.data_sources,
|
||||
schema_fields: currentDesign.schema_fields,
|
||||
}"
|
||||
@confirm="handleDesignConfirm"
|
||||
@close="handleDesignCancel"
|
||||
|
||||
@@ -215,7 +215,7 @@ const runWorkflow = (userMessage: string, inputs: Record<string, any>) => {
|
||||
running.value = true;
|
||||
|
||||
// 流式运行(编辑器调试模式,使用草稿版本)
|
||||
// 系统变量(application_id 等)由 API 层自动注入
|
||||
// 业务上下文由 API 层按 Workflow 配置解析
|
||||
cancelStream = runWorkflowStreamApi(
|
||||
props.workflowId,
|
||||
inputs,
|
||||
@@ -589,8 +589,10 @@ const handleStreamEvent = (event: WorkflowStreamEvent, msgId: string) => {
|
||||
$t('ai-platform.workflow.editor.chatPanel.designPreviewTitle'),
|
||||
data: configData.data || {},
|
||||
nodeId: event.node_id || '',
|
||||
form_fields: configData.form_fields || [], // 传递表单字段列表(用于列表设计)
|
||||
table_configs: configData.table_configs || [], // 传递数据表配置(用于表单设计)
|
||||
data_sources:
|
||||
configData.data_sources || configData.table_configs || [],
|
||||
schema_fields:
|
||||
configData.schema_fields || configData.form_fields || [],
|
||||
};
|
||||
showDesignPanel.value = true;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
import { Plus, Trash2 } from '@vben/icons';
|
||||
import { Delete as Trash2, Plus } from '@element-plus/icons-vue';
|
||||
import { $t } from '@vben/locales';
|
||||
|
||||
import { ElButton, ElForm, ElInput, ElOption, ElSelect } from 'element-plus';
|
||||
@@ -50,45 +50,6 @@ const handleDelete = (index: number) => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 默认的 application_id 变量(不可删除) -->
|
||||
<div class="border-primary/30 bg-primary/5 rounded border p-3">
|
||||
<div class="mb-2 flex items-center justify-between">
|
||||
<span class="text-primary text-sm font-medium">application_id</span>
|
||||
<span class="text-muted-foreground text-xs">{{
|
||||
$t('ai-platform.workflow.panels.common.sysVar')
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="text-muted-foreground text-xs">
|
||||
{{ $t('ai-platform.workflow.panels.start.appIdDesc') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 默认的 application_code 变量(不可删除) -->
|
||||
<div class="border-primary/30 bg-primary/5 rounded border p-3">
|
||||
<div class="mb-2 flex items-center justify-between">
|
||||
<span class="text-primary text-sm font-medium">application_code</span>
|
||||
<span class="text-muted-foreground text-xs">{{
|
||||
$t('ai-platform.workflow.panels.common.sysVar')
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="text-muted-foreground text-xs">
|
||||
{{ $t('ai-platform.workflow.panels.start.appCodeDesc') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 默认的 form_code 变量(不可删除) -->
|
||||
<div class="border-primary/30 bg-primary/5 rounded border p-3">
|
||||
<div class="mb-2 flex items-center justify-between">
|
||||
<span class="text-primary text-sm font-medium">form_code</span>
|
||||
<span class="text-muted-foreground text-xs">{{
|
||||
$t('ai-platform.workflow.panels.common.sysVar')
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="text-muted-foreground text-xs">
|
||||
{{ $t('ai-platform.workflow.panels.start.formCodeDesc') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-between">
|
||||
<span class="text-foreground text-sm font-medium">{{
|
||||
$t('ai-platform.workflow.panels.common.customVars')
|
||||
|
||||
Reference in New Issue
Block a user