From 22d08252c8a0f4fbed60db9968887cebbe06391c Mon Sep 17 00:00:00 2001 From: CaptainB Date: Fri, 13 Sep 2024 13:40:43 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=A4=84=E7=90=86=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BC=A0=E5=85=A5=E5=92=8C=E6=89=8B=E5=8A=A8=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E7=9A=84=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/components/ai-chat/index.vue | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/ui/src/components/ai-chat/index.vue b/ui/src/components/ai-chat/index.vue index df3ea2b62..6cfc3e58d 100644 --- a/ui/src/components/ai-chat/index.vue +++ b/ui/src/components/ai-chat/index.vue @@ -259,6 +259,7 @@ const inputValue = ref('') const chartOpenId = ref('') const chatList = ref([]) const inputFieldList = ref([]) +const apiInputFieldList = ref([]) const form_data = ref({}) const isDisabledChart = computed( @@ -317,7 +318,7 @@ function handleInputFieldList() { ?.filter((v: any) => v.id === 'base-node') .map((v: any) => { inputFieldList.value = v.properties.input_field_list - ? v.properties.input_field_list.map((v: any) => { + ? v.properties.input_field_list.filter((v: any) => v.assignment_method === 'user_input').map((v: any) => { switch (v.type) { case 'input': return { @@ -353,6 +354,15 @@ function handleInputFieldList() { } }) : [] + apiInputFieldList.value = v.properties.input_field_list + ? v.properties.input_field_list.filter((v: any) => v.assignment_method === 'api_input').map((v: any) => { + return { + field: v.variable, + label: v.name, + required: v.is_required + } + }) + : [] }) } @@ -566,6 +576,14 @@ const errorWrite = (chat: any, message?: string) => { } function chatMessage(chat?: any, problem?: string, re_chat?: boolean) { + // 浏览器query参数找到接口传参 + for (let f of apiInputFieldList.value) { + if (f.required && !route.query[f.field]) { + MsgWarning(`请在接入的URL补全必填参数${f.field}`) + return + } + form_data.value[f.field] = route.query[f.field] + } loading.value = true if (!chat) { chat = reactive({