diff --git a/CHANGELOG.md b/CHANGELOG.md index 9dd73f4..6c389fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [1.12.2](https://github.com/TencentCloudBase/cloudbase-agent-ui/compare/v1.12.1...v1.12.2) (2025-05-09) + + +### Bug Fixes + +* fix readme ([076cc4b](https://github.com/TencentCloudBase/cloudbase-agent-ui/commit/076cc4b1f5029a5a324a50daee56b55e18031455)) +* fix readme ([0864a14](https://github.com/TencentCloudBase/cloudbase-agent-ui/commit/0864a143ce28431db5ba975bef1037c7549cbac6)) + ### [1.12.1](https://github.com/TencentCloudBase/cloudbase-agent-ui/compare/v1.12.0...v1.12.1) (2025-05-07) ## [1.12.0](https://github.com/TencentCloudBase/cloudbase-agent-ui/compare/v1.11.0...v1.12.0) (2025-05-06) diff --git a/README.md b/README.md index 439f7a7..d0ade74 100644 --- a/README.md +++ b/README.md @@ -147,24 +147,25 @@ Page({ ![](https://qcloudimg.tencent-cloud.cn/raw/b45a95e06ec0df8dab5c9d9ec7707faa.png) +#### 4. agent-ui 组件工具卡片组件中配置自定义组件映射 -#### 4. 开发自定义卡片组件 +![](https://qcloudimg.tencent-cloud.cn/raw/b4cd35ccaa3e72189934ed59d35f7ae5.png) + +如图所示,示例中添加了腾讯地图自定义卡片组件引用 + +#### 5. 自定义卡片组件开发 -- 参照本工程中 apps/miniprogram-agent-ui/miniprogram/components/toolCard 目录内自定义工具卡片组件实现 +- 参照本工程中 apps/miniprogram-agent-ui/miniprogram/components/toolCard 目录内自定义腾讯地图卡片组件实现 ![](https://qcloudimg.tencent-cloud.cn/raw/14a4a82810f0b45bde0c124cc8f3ed1c.png) -#### 5. 卡片组件引用配置 +#### 6. 自定义卡片组件引用配置 - 自定义卡片组件引用声明配置(可在用户小程序项目全局app.json中配置 或 agent-ui组件index.json中配置) ![](https://qcloudimg.tencent-cloud.cn/raw/cd1dc376a1e238f3186a2209e5875698.png) -- agent-ui 组件内 customCard/index.wxml 中添加自定义组件 - -![](https://qcloudimg.tencent-cloud.cn/raw/b4cd35ccaa3e72189934ed59d35f7ae5.png) - -#### 6. 卡片效果 +#### 7. 卡片效果 diff --git a/apps/miniprogram-agent-ui/miniprogram/app.js b/apps/miniprogram-agent-ui/miniprogram/app.js index 05a0244..22bb594 100644 --- a/apps/miniprogram-agent-ui/miniprogram/app.js +++ b/apps/miniprogram-agent-ui/miniprogram/app.js @@ -10,7 +10,7 @@ App({ // env 参数决定接下来小程序发起的云开发调用(wx.cloud.xxx)会默认请求到哪个云环境的资源 // 此处请填入环境 ID, 环境 ID 可打开云控制台查看 // 如不填则使用默认环境(第一个创建的环境) - env: "luke-agent-dev-7g1nc8tqc2ab76af", + env: "luke-personal-test-new-8d0d90f5f", traceUser: true, }); } diff --git a/apps/miniprogram-agent-ui/miniprogram/components/agent-ui/index.js b/apps/miniprogram-agent-ui/miniprogram/components/agent-ui/index.js index 04b1193..2ff30c7 100644 --- a/apps/miniprogram-agent-ui/miniprogram/components/agent-ui/index.js +++ b/apps/miniprogram-agent-ui/miniprogram/components/agent-ui/index.js @@ -172,7 +172,6 @@ Component({ allowMultiConversation, allowVoice, } = this.data.agentConfig; - console.log("allowWebSearch", allowWebSearch); allowWebSearch = allowWebSearch === undefined ? true : allowWebSearch; allowUploadFile = allowUploadFile === undefined ? true : allowUploadFile; allowPullRefresh = allowPullRefresh === undefined ? true : allowPullRefresh; @@ -439,7 +438,6 @@ Component({ const res = await this.fetchConversationList(true, this.data.bot.botId); if (res) { const { data } = res; - console.log("default conversation", data); if (data && !data.code) { // 区分旧的默认会话结构与新的默认会话结构 if (data.data) { @@ -487,7 +485,6 @@ Component({ method: "GET", header: {}, success: (res) => { - console.log("conversation list res", res); resolve(res); }, fail(e) { @@ -517,7 +514,6 @@ Component({ }, method: "POST", success: (res) => { - console.log("create conversation res", res); resolve(res); }, fail(e) { @@ -567,7 +563,6 @@ Component({ page: this.data.conversationPageOptions.page + 1, }, }); - console.log("conversationPageOptions", this.data.conversationPageOptions); // 调用分页接口查询更多 if (this.data.bot.botId) { const res = await this.fetchConversationList(false, this.data.bot.botId); @@ -598,7 +593,6 @@ Component({ try { if (this.data.bot.botId) { const res = await this.fetchConversationList(false, this.data.bot.botId); - console.log("res", res); if (res) { const { data } = res; if (data && !data.code) { @@ -606,11 +600,9 @@ Component({ const sortData = data.data.sort( (a, b) => new Date(b.createTime).getTime() - new Date(a.createTime).getTime() ); - console.log("sortData", sortData); const finalConData = this.data.defaultConversation ? sortData.concat(this.data.defaultConversation) : sortData; - console.log("finalConData", finalConData); this.setData({ conversations: finalConData, transformConversations: this.transformConversationList(finalConData), @@ -644,7 +636,6 @@ Component({ earlyCon.push(item); } } - console.log("todayCon curMonthCon earlyCon", todayCon, curMonthCon, earlyCon); return { todayCon, curMonthCon, @@ -718,10 +709,12 @@ Component({ const transformToolCallObj = { id: curParam.tool_call.id, name: this.transformToolName(curParam.tool_call.function.name), + rawParams: curParam.tool_call.function.arguments, callParams: "```json\n\n" + JSON.stringify(curParam.tool_call.function.arguments, null, 2) + "\n```", content: ((curContent && curContent.content) || "").replaceAll("\t", "").replaceAll("\n", "\n\n"), }; if (curResult) { + transformToolCallObj.rawResult = curResult.result; transformToolCallObj.callResult = "```json\n\n" + JSON.stringify(curResult.result, null, 2) + "\n```"; } if (curError) { @@ -1847,7 +1840,6 @@ Component({ }, method: "POST", success: (res) => { - console.log("create text-to-speech task res", res); resolve(res); }, fail(e) { @@ -1856,7 +1848,6 @@ Component({ }, }); }); - console.log("text-to-speech", res); const { data } = res; if (data && data.TaskId) { const taskId = data.TaskId; @@ -1873,7 +1864,6 @@ Component({ }, method: "GET", success: (res) => { - console.log("create text-to-speech task res", res); resolve(res); }, fail(e) { @@ -1882,7 +1872,6 @@ Component({ }, }); }); - console.log("query task res", res); const { data } = res; if (data.code || data.Status === 2) { loopQueryStatus = false; @@ -2033,7 +2022,6 @@ Component({ }, chooseSpeed(e) { const speed = e.currentTarget.dataset.speed; - console.log("choose speed", speed); const audioContext = this.data.audioContext; audioContext.showSpeedList = !this.data.audioContext.showSpeedList; audioContext.currentSpeed = Number(speed); @@ -2081,7 +2069,6 @@ Component({ }); return; } - console.log("touchMove"); if (!this.data.longPressTriggered) return; const { clientY } = e.touches[0]; const deltaY = clientY - this.data.startY; @@ -2147,7 +2134,6 @@ Component({ }, startRecord() { console.log("startRecord sendStatus", this.data.sendStatus); - console.log("recorderManager", this.data.recorderManager); if (this.data.recorderManager && this.data.sendStatus === 1) { console.log("开始录音"); this.data.recorderManager.start(this.data.recordOptions); diff --git a/apps/miniprogram-agent-ui/miniprogram/components/agent-ui/index.wxss b/apps/miniprogram-agent-ui/miniprogram/components/agent-ui/index.wxss index 9549f10..30e856e 100644 --- a/apps/miniprogram-agent-ui/miniprogram/components/agent-ui/index.wxss +++ b/apps/miniprogram-agent-ui/miniprogram/components/agent-ui/index.wxss @@ -107,6 +107,7 @@ padding: 0rpx !important; width: 64rpx !important; height: 64rpx; + border: none !important; } .avatar { diff --git a/apps/miniprogram-agent-ui/miniprogram/components/toolCard/business-list/index.js b/apps/miniprogram-agent-ui/miniprogram/components/toolCard/business-list/index.js index 1e6b4e9..33c1a1d 100644 --- a/apps/miniprogram-agent-ui/miniprogram/components/toolCard/business-list/index.js +++ b/apps/miniprogram-agent-ui/miniprogram/components/toolCard/business-list/index.js @@ -43,12 +43,10 @@ Component({ const { name, toolData } = this.data; // 将详细的结构化地址转换为经纬度坐标 if (name === "placeSearchNearby") { - console.log("toolData", toolData); const { content } = toolData; if (content[0].type === "text") { const contentData = JSON.parse(content[0].text); const { data } = contentData; - console.log("placeSearchNearby data", data); this.setData({ restaurants: data.map((item, index) => ({ // ...item, diff --git a/apps/miniprogram-agent-ui/miniprogram/components/toolCard/food-list/index.js b/apps/miniprogram-agent-ui/miniprogram/components/toolCard/food-list/index.js index 5a93501..9360255 100644 --- a/apps/miniprogram-agent-ui/miniprogram/components/toolCard/food-list/index.js +++ b/apps/miniprogram-agent-ui/miniprogram/components/toolCard/food-list/index.js @@ -41,7 +41,6 @@ Component({ methods: { // 添加点击事件处理函数 onFoodItemTap: function (e) { - console.log("tofood e", e); const foodId = e.currentTarget.dataset.id; const foodItem = this.data.foodList.find((item) => item.id === foodId); diff --git a/apps/miniprogram-agent-ui/miniprogram/components/toolCard/map/index.js b/apps/miniprogram-agent-ui/miniprogram/components/toolCard/map/index.js index 7cb7c18..67d1711 100644 --- a/apps/miniprogram-agent-ui/miniprogram/components/toolCard/map/index.js +++ b/apps/miniprogram-agent-ui/miniprogram/components/toolCard/map/index.js @@ -39,11 +39,9 @@ Component({ const { name, toolData } = this.data; // 将详细的结构化地址转换为经纬度坐标 if (name === "geocoder") { - console.log("toolData", toolData); const { content } = toolData; if (content[0].type === "text") { const contentData = JSON.parse(content[0].text); - console.log("geocoder data", contentData); const { result: { location: { lat, lng }, @@ -72,7 +70,6 @@ Component({ const { location } = this.data.toolParams; const locationInfo = location.split(","); const contentData = JSON.parse(content[0].text); - console.log("placeSearchNearby data", contentData); const { data } = contentData; this.setData({ latitude: locationInfo[0], @@ -91,14 +88,12 @@ Component({ } // 路线规划 if (name === "directionDriving") { - console.log("toolData", toolData); const { content } = toolData; if (content[0].type === "text") { const { from, to } = this.data.toolParams; const fromInfo = from.split(","); const toInfo = to.split(","); const contentData = JSON.parse(content[0].text); - console.log("directionDriving data", contentData); const { result: { routes }, } = contentData; @@ -107,7 +102,6 @@ Component({ const firstRoute = routes[0]; const { polyline, steps } = firstRoute; //TODO: 需解压转化为经纬度坐标对数组 const transformPolyline = this.transformRawPolyline(polyline); - console.log("transformPolyline", transformPolyline); const startAndEndPair = [ { id: 1, diff --git a/apps/miniprogram-agent-ui/miniprogram/components/toolCard/weather/index.js b/apps/miniprogram-agent-ui/miniprogram/components/toolCard/weather/index.js index 3a15949..4778af9 100644 --- a/apps/miniprogram-agent-ui/miniprogram/components/toolCard/weather/index.js +++ b/apps/miniprogram-agent-ui/miniprogram/components/toolCard/weather/index.js @@ -34,14 +34,12 @@ Component({ // 根据 name 区分处理不同 tool 调用情况 const { name, toolData } = this.data; if (name === "weather") { - console.log("toolData", toolData); const { content } = toolData; if (content[0].type === "text") { const contentData = JSON.parse(content[0].text); const { result: { forecast }, } = contentData; - console.log("forecast", forecast); const isDay = this.checkIsDay(); if (forecast.length) { const todayForecast = forecast[0]; @@ -118,11 +116,13 @@ Component({ 雨: "rainy", 雪: "snowy", 雷阵雨: "thunderstorm", + 阵雨: "rainy", 大雨: "rainy", 中雨: "rainy", 小雨: "rainy", 晴间多云: "sunnyovercast", }; + return weatherMap[weather] || "sunny"; }, }, diff --git a/apps/miniprogram-agent-ui/miniprogram/components/toolCard/weather/index.wxml b/apps/miniprogram-agent-ui/miniprogram/components/toolCard/weather/index.wxml index 1ee903a..ded12a5 100644 --- a/apps/miniprogram-agent-ui/miniprogram/components/toolCard/weather/index.wxml +++ b/apps/miniprogram-agent-ui/miniprogram/components/toolCard/weather/index.wxml @@ -3,7 +3,7 @@ - + {{isDay ? today.dayweather : today.nightweather}} diff --git a/apps/miniprogram-agent-ui/miniprogram/pages/chatBot/chatBot.js b/apps/miniprogram-agent-ui/miniprogram/pages/chatBot/chatBot.js index 57d8573..98c07f7 100644 --- a/apps/miniprogram-agent-ui/miniprogram/pages/chatBot/chatBot.js +++ b/apps/miniprogram-agent-ui/miniprogram/pages/chatBot/chatBot.js @@ -14,7 +14,7 @@ Page({ // resourceEnv: "chriscc-demo-7ghlpjf846d46d2d", // }, agentConfig: { - botId: "bot-db3cab4a", // agent id, + botId: "bot-c5167aab", // agent id, allowWebSearch: true, // 允许客户端选择启用联网搜索 allowUploadFile: true, // 允许上传文件 allowPullRefresh: true, // 允许下拉刷新 diff --git a/components/agent-ui/index.js b/components/agent-ui/index.js index 04b1193..2ff30c7 100644 --- a/components/agent-ui/index.js +++ b/components/agent-ui/index.js @@ -172,7 +172,6 @@ Component({ allowMultiConversation, allowVoice, } = this.data.agentConfig; - console.log("allowWebSearch", allowWebSearch); allowWebSearch = allowWebSearch === undefined ? true : allowWebSearch; allowUploadFile = allowUploadFile === undefined ? true : allowUploadFile; allowPullRefresh = allowPullRefresh === undefined ? true : allowPullRefresh; @@ -439,7 +438,6 @@ Component({ const res = await this.fetchConversationList(true, this.data.bot.botId); if (res) { const { data } = res; - console.log("default conversation", data); if (data && !data.code) { // 区分旧的默认会话结构与新的默认会话结构 if (data.data) { @@ -487,7 +485,6 @@ Component({ method: "GET", header: {}, success: (res) => { - console.log("conversation list res", res); resolve(res); }, fail(e) { @@ -517,7 +514,6 @@ Component({ }, method: "POST", success: (res) => { - console.log("create conversation res", res); resolve(res); }, fail(e) { @@ -567,7 +563,6 @@ Component({ page: this.data.conversationPageOptions.page + 1, }, }); - console.log("conversationPageOptions", this.data.conversationPageOptions); // 调用分页接口查询更多 if (this.data.bot.botId) { const res = await this.fetchConversationList(false, this.data.bot.botId); @@ -598,7 +593,6 @@ Component({ try { if (this.data.bot.botId) { const res = await this.fetchConversationList(false, this.data.bot.botId); - console.log("res", res); if (res) { const { data } = res; if (data && !data.code) { @@ -606,11 +600,9 @@ Component({ const sortData = data.data.sort( (a, b) => new Date(b.createTime).getTime() - new Date(a.createTime).getTime() ); - console.log("sortData", sortData); const finalConData = this.data.defaultConversation ? sortData.concat(this.data.defaultConversation) : sortData; - console.log("finalConData", finalConData); this.setData({ conversations: finalConData, transformConversations: this.transformConversationList(finalConData), @@ -644,7 +636,6 @@ Component({ earlyCon.push(item); } } - console.log("todayCon curMonthCon earlyCon", todayCon, curMonthCon, earlyCon); return { todayCon, curMonthCon, @@ -718,10 +709,12 @@ Component({ const transformToolCallObj = { id: curParam.tool_call.id, name: this.transformToolName(curParam.tool_call.function.name), + rawParams: curParam.tool_call.function.arguments, callParams: "```json\n\n" + JSON.stringify(curParam.tool_call.function.arguments, null, 2) + "\n```", content: ((curContent && curContent.content) || "").replaceAll("\t", "").replaceAll("\n", "\n\n"), }; if (curResult) { + transformToolCallObj.rawResult = curResult.result; transformToolCallObj.callResult = "```json\n\n" + JSON.stringify(curResult.result, null, 2) + "\n```"; } if (curError) { @@ -1847,7 +1840,6 @@ Component({ }, method: "POST", success: (res) => { - console.log("create text-to-speech task res", res); resolve(res); }, fail(e) { @@ -1856,7 +1848,6 @@ Component({ }, }); }); - console.log("text-to-speech", res); const { data } = res; if (data && data.TaskId) { const taskId = data.TaskId; @@ -1873,7 +1864,6 @@ Component({ }, method: "GET", success: (res) => { - console.log("create text-to-speech task res", res); resolve(res); }, fail(e) { @@ -1882,7 +1872,6 @@ Component({ }, }); }); - console.log("query task res", res); const { data } = res; if (data.code || data.Status === 2) { loopQueryStatus = false; @@ -2033,7 +2022,6 @@ Component({ }, chooseSpeed(e) { const speed = e.currentTarget.dataset.speed; - console.log("choose speed", speed); const audioContext = this.data.audioContext; audioContext.showSpeedList = !this.data.audioContext.showSpeedList; audioContext.currentSpeed = Number(speed); @@ -2081,7 +2069,6 @@ Component({ }); return; } - console.log("touchMove"); if (!this.data.longPressTriggered) return; const { clientY } = e.touches[0]; const deltaY = clientY - this.data.startY; @@ -2147,7 +2134,6 @@ Component({ }, startRecord() { console.log("startRecord sendStatus", this.data.sendStatus); - console.log("recorderManager", this.data.recorderManager); if (this.data.recorderManager && this.data.sendStatus === 1) { console.log("开始录音"); this.data.recorderManager.start(this.data.recordOptions); diff --git a/components/agent-ui/index.wxss b/components/agent-ui/index.wxss index 9549f10..30e856e 100644 --- a/components/agent-ui/index.wxss +++ b/components/agent-ui/index.wxss @@ -107,6 +107,7 @@ padding: 0rpx !important; width: 64rpx !important; height: 64rpx; + border: none !important; } .avatar { diff --git a/package-lock.json b/package-lock.json index e1c2d7c..0cb720f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cloudbase-agent-ui", - "version": "1.12.1", + "version": "1.12.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "cloudbase-agent-ui", - "version": "1.12.1", + "version": "1.12.2", "license": "MIT", "dependencies": { "standard-version": "^9.5.0" diff --git a/package.json b/package.json index 61d5953..35359e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cloudbase-agent-ui", - "version": "1.12.1", + "version": "1.12.2", "description": "微信小程序 Agent UI组件", "main": "index.js", "directories": {