Skip to content

Commit f2fcc00

Browse files
committed
feat: support upload img
1 parent 533e90a commit f2fcc00

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

apps/miniprogram-agent-ui/miniprogram/components/agent-ui/index.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Component({
2222
allowUploadFile: Boolean,
2323
allowWebSearch: Boolean,
2424
allowPullRefresh: Boolean,
25-
// allowUploadImage: Boolean,
25+
allowUploadImage: Boolean,
2626
},
2727
},
2828
modelConfig: {
@@ -106,7 +106,7 @@ Component({
106106
footerHeight: 73,
107107
lastScrollTop: 0,
108108
showUploadFile: true,
109-
showUploadImg: false,
109+
showUploadImg: true,
110110
showWebSearchSwitch: false,
111111
showPullRefresh: true,
112112
useWebSearch: false,
@@ -159,18 +159,20 @@ Component({
159159
const { chatRecords } = this.data;
160160
// 随机选取三个初始化问题
161161
const questions = randomSelectInitquestion(bot.initQuestions, 3);
162-
let { allowWebSearch, allowUploadFile, allowPullRefresh } = this.data.agentConfig;
162+
let { allowWebSearch, allowUploadFile, allowPullRefresh, allowUploadImage } = this.data.agentConfig;
163163
console.log("allowWebSearch", allowWebSearch);
164164
allowWebSearch = allowWebSearch === undefined ? true : allowWebSearch;
165165
allowUploadFile = allowUploadFile === undefined ? true : allowUploadFile;
166166
allowPullRefresh = allowPullRefresh === undefined ? true : allowPullRefresh;
167+
allowUploadImage = allowUploadImage === undefined ? true : allowUploadImage;
167168
console.log("allowUploadFile", allowUploadFile);
168169
this.setData({
169170
bot,
170171
questions,
171172
chatRecords: [...chatRecords, record],
172173
showWebSearchSwitch: allowWebSearch,
173174
showUploadFile: allowUploadFile,
175+
showUploadImg: allowUploadImage,
174176
showPullRefresh: allowPullRefresh,
175177
});
176178
}
@@ -485,6 +487,13 @@ Component({
485487
});
486488
},
487489
handleUploadImg: function (sourceType) {
490+
if(!this.data.bot.searchFileEnable) {
491+
wx.showModal({
492+
title: "提示",
493+
content: "请前往腾讯云开发平台启用 Agent 文件上传功能",
494+
});
495+
return;
496+
}
488497
const self = this;
489498
const isCurSendFile = this.data.sendFileList.find((item) => item.rawType === "file");
490499
if (isCurSendFile) {

apps/miniprogram-agent-ui/miniprogram/components/agent-ui/index.wxml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,14 @@
142142
<image src="./imgs/clear.svg" alt="widthFix" class="icon" />
143143
<text class="text_desc">清除</text>
144144
</view>
145-
<view wx:if="{{showUploadImg && chatMode === 'bot'}}" class="function" bind:tap="handleAlbum">
146-
<image src="./imgs/uploadImg.svg" alt="widthFix" class="icon" />
147-
<text class="text_desc">图片</text>
148-
</view>
149145
<view wx:if="{{showUploadFile && chatMode === 'bot'}}" class="function" bind:tap="handleUploadMessageFile">
150146
<image src="./imgs/wechat.svg" alt="widthFix" class="icon" />
151147
<text class="text_desc">微信文件</text>
152148
</view>
149+
<view wx:if="{{showUploadImg && chatMode === 'bot'}}" class="function" bind:tap="handleAlbum">
150+
<image src="./imgs/uploadImg.svg" alt="widthFix" class="icon" />
151+
<text class="text_desc">图片</text>
152+
</view>
153153
<view wx:if="{{showUploadImg && chatMode === 'bot'}}" class="function" bind:tap="handleCamera">
154154
<image src="./imgs/camera.svg" alt="widthFix" class="icon" />
155155
<text class="text_desc">相机</text>

apps/miniprogram-agent-ui/miniprogram/pages/chatBot/chatBot.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ Page({
1010
botId: "bot-db3cab4a", // agent id,
1111
allowWebSearch: true, // 允许客户端选择启用联网搜索
1212
allowUploadFile: true, // 允许上传文件
13-
allowPullRefresh: true // 允许下拉刷新
13+
allowPullRefresh: true, // 允许下拉刷新
14+
allowUploadImage: true, // 允许上传图片
1415
},
1516
modelConfig: {
1617
modelProvider: "hunyuan-open", // 大模型服务厂商

0 commit comments

Comments
 (0)