From 1b64c9580f752a9ddaf31d4083d149c78e5ffadd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=98=E6=B0=91=E5=BA=B7?= Date: Wed, 21 May 2025 11:33:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E4=BF=A1=E4=BB=A3=E7=A0=81=E5=BA=93-A?= =?UTF-8?q?I=E5=A4=A7=E6=A8=A1=E5=9E=8B=E7=8C=9C=E4=BD=A0=E6=83=B3?= =?UTF-8?q?=E9=97=AE=E6=8E=A5=E5=8F=A3=E5=AF=B9=E6=8E=A5=E5=8F=8A=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Jyh/AI/Home/index.vue | 68 +++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 20 deletions(-) diff --git a/src/views/Jyh/AI/Home/index.vue b/src/views/Jyh/AI/Home/index.vue index cb83499..ef07fa3 100644 --- a/src/views/Jyh/AI/Home/index.vue +++ b/src/views/Jyh/AI/Home/index.vue @@ -39,23 +39,20 @@ -
+
@@ -195,6 +192,7 @@ const inputFootIcons = [ ]; const messages = ref([]); +const followupQuestions = ref([]); // 控制 ViewHistoryAside 组件的显示状态 const isHistoryVisible = ref(false); @@ -225,6 +223,7 @@ const onSubmit = async (e, answer = undefined) => { avatarPosition: 'side-right', avatarConfig: { ...customerAvatar }, }); + followupQuestions.value = []; // getAIAnswer(answer ?? e); // 判断是否有会话id if(!CONV_ID.value) { @@ -244,7 +243,6 @@ const VITE_AI_API_HOST = (import.meta as any).env.VITE_AI_API_HOST; // AI对话接口对接 const getAIAnswer = async (content) => { - debugger if(CONV_ID.value) { messages.value.push({ role: 'ai-model', @@ -262,7 +260,7 @@ const getAIAnswer = async (content) => { }); if(response.data.type) { - const {text,type} = response.data; + const {text,type,id} = response.data; if(type==='text') { messages.value[messages.value.length - 1].content = text; @@ -273,6 +271,7 @@ const getAIAnswer = async (content) => { messages.value[messages.value.length - 1].loading = false; messages.value[messages.value.length - 1].type = 'df'; } + fetchFollowupQuestions(content,id) } else { Message.warning('接口异常!') } @@ -334,6 +333,31 @@ const createConversation = async () => { Message.error('创建会话失败,请重试'); } }; +// 猜你想问接口 +const fetchFollowupQuestions = async (question,df_id,sql_id='') => { + try { + // 构造请求参数(需根据实际文档补充 df_id 和 sql_id,示例中使用空字符串占位) + const params = { + question, + df_id: df_id || '', // 使用当前会话ID,若无则为空 + sql_id: sql_id || '' // 同上 + }; + const response = await axios.post( + `${VITE_AI_API_HOST}/api/v0/provide_followup_questions`, + params + ); + debugger + const createRes = response.data; + if (createRes&&createRes.questions) { + followupQuestions.value = createRes.questions + } else { + // Message.error('创建会话失败,未获取到会话ID'); + } + } catch (error) { + console.error('查询相关问题失败:', error); + // Message.error('创建会话失败,请重试'); + } +}; const handleSelectConv = (convId: string) => { CONV_ID.value = convId; // 更新为选中的会话 ID @@ -529,11 +553,14 @@ onMounted(() => { } .conversation-cnxw { margin-top: 8px; + display: flex; + flex-direction: column; /* 改为垂直排列 */ + align-items: flex-end; /* 内容右对齐 */ .conversation-cnxw-item { cursor: pointer; align-items: center; - justify-content: end; - margin-right: 12px; + //justify-content: end; + //margin-right: 12px; margin-bottom: 8px; } .span2{ @@ -547,16 +574,17 @@ onMounted(() => { margin-right: 8px; } .g-header-copilot { + margin-right: 16px; + margin-top: 4px; background: #fff; color: black; - //width: 120px; padding: 0 12px; border-radius: 48px; height: 32px; display: flex; align-items: center; cursor: pointer; - justify-content: center; + //justify-content: center; &:hover { background: rgba(41, 81, 224, 0.8); }