From 0e5c07b5daa72d52cd0653fdd1e310c6b04cde7b Mon Sep 17 00:00:00 2001 From: lifizer <913626195@qq.com> Date: Wed, 3 Jun 2026 16:29:26 +0800 Subject: [PATCH] =?UTF-8?q?Feat(=E4=BA=91=E7=81=B5AI):=E9=80=81=E7=A4=BC?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aiChat/mixins/chatMixinsV2.js | 38 ++++++++++++++++++++++++++--------- api/chat/index.js | 4 ++++ 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/aiChat/mixins/chatMixinsV2.js b/aiChat/mixins/chatMixinsV2.js index 9e9ea6f..9205bf6 100644 --- a/aiChat/mixins/chatMixinsV2.js +++ b/aiChat/mixins/chatMixinsV2.js @@ -6,7 +6,8 @@ import { getAnalyzeKeywordsChangeV3, getSseCountyAiConfigV1, getCountyAiCompletionsV1, - getGiftRecommendOptions + getGiftRecommendOptions, + getGiftRecommendPrompt } from '@/api/chat/index' import { getExceptionConfig, @@ -795,24 +796,43 @@ export const chatMixinsV2 = { } }, finishGiftSteps() { - let promptStr = '我想送礼' + const selectedSteps = [] this.giftBuyOptions.forEach(step => { if (step.type === 'option_card') { const selectedIds = this.giftSelections[step.id] || [] if (selectedIds.length > 0) { const selectedNames = step.options.filter(opt => selectedIds.includes(opt.id)).map(opt => opt.optionName) - promptStr += `,${step.title.replace('?', '')}:${selectedNames.join('、')}` + selectedSteps.push({ + sort: step.sort, + title: step.title, + type: step.type, + options: selectedNames + }) } } else if (step.type === 'price_input') { if (this.giftBudget) { - promptStr += `,${step.title.replace('?', '')}:${this.giftBudget}` + selectedSteps.push({ + sort: step.sort, + title: step.title, + type: step.type, + options: [this.giftBudget] + }) } } - }); - this.showGiftSteps = false - this.streamReq({ - prompt: promptStr, - init: 0 + }) + console.log(selectedSteps) + uni.showLoading() + getGiftRecommendPrompt(selectedSteps).then(res => { + const { success, data } = res + if (success) { + this.showGiftSteps = false + this.streamReq({ + prompt: data.prompt || '我想送礼', + init: 0 + }) + } + }).finally(() => { + uni.hideLoading() }) } } diff --git a/api/chat/index.js b/api/chat/index.js index 2c083a9..e831dc6 100644 --- a/api/chat/index.js +++ b/api/chat/index.js @@ -85,3 +85,7 @@ export function getCountyAiChatList(params) { export function getCountyAiHistoryChatMessage(params) { return request.get('/county-ai/chat/message', params, { login: true }) } + +export function getGiftRecommendPrompt(data) { + return request.post('/ai/gift-recommend/build-prompt', data, { login: true }) +}