Skip to content

Commit d15972b

Browse files
authored
Merge pull request #48 from TencentCloudBase/dev
Dev
2 parents f8b3cc2 + 6f76b6c commit d15972b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1824
-28
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
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.
44

5+
## [1.10.0](https://github.com/TencentCloudBase/cloudbase-agent-ui/compare/v1.9.1...v1.10.0) (2025-04-23)
6+
7+
8+
### Features
9+
10+
* support tencentmap card ([5c4437b](https://github.com/TencentCloudBase/cloudbase-agent-ui/commit/5c4437b3be43aca84433d2ae75ccfb21f6912cf3))
11+
12+
13+
### Bug Fixes
14+
15+
* fix readme ([cee725d](https://github.com/TencentCloudBase/cloudbase-agent-ui/commit/cee725d566199b1865164e4687b5d45f8e6344c2))
16+
517
### [1.9.1](https://github.com/TencentCloudBase/cloudbase-agent-ui/compare/v1.9.0...v1.9.1) (2025-04-21)
618

719

README.md

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,39 @@ Agent UI 演示效果图
1818
- **企业级功能集成** 流式输出/联网搜索/深度思考/多轮会话 开箱即用
1919
- **多模型支持** 深度兼容 DeepSeek、Hunyuan 等主流大模型
2020
- **配置即开发** 通过配置快速接入组件能力,无需处理复杂通信逻辑
21+
- **支持 MCP Server 调用&自定义工具卡片** 对接云开发MCP Server能力,支持开发者定制工具卡片展示
2122

2223
## 📦 使用指南
2324

24-
### 1. 开通环境
25+
### 组件集成
26+
27+
#### 1. 开通环境
2528

2629
Agent UI 微信小程序组件依赖**微信云开发**服务,需先开通云开发环境
2730

28-
#### 1.1 开通微信云开发
31+
##### 1.1 开通微信云开发
2932

3033
开通方式,点击开发者工具顶部“云开发” 进行开通
3134

3235
![](https://qcloudimg.tencent-cloud.cn/raw/f06ca4761f54ecc8ed8d9644229c92f9.png)
3336

3437
如已开通微信云开发服务,请跳转至[云开发平台](https://tcb.cloud.tencent.com/dev)创建AI服务。
3538

36-
#### 1.2、创建AI服务
39+
##### 1.2、创建AI服务
3740

3841
- 方式一:直接使用agent智能体服务
3942
![](https://qcloudimg.tencent-cloud.cn/raw/97786aaaa15aa1f23e9bbd39a7a6762f.png)
4043
- 方式二:接入大模型
4144
![](https://qcloudimg.tencent-cloud.cn/raw/876d2238b5331a7bdcbd91a1b38b8248.png)
4245

43-
### 2. 获取组件
46+
#### 2. 获取组件
4447

4548
可通过以下两种方式获取组件包代码
4649

4750
1. **克隆仓库到本地,提取其中components/agent-ui 目录使用**
4851
2. **下载GitHub Release 包 agent-ui.zip,直接使用**
4952

50-
### 3. 微信小程序项目引入组件
53+
#### 3. 微信小程序项目引入组件
5154

5255
1. **配置云开发环境ID**
5356
打开 miniprogram/app.js 文件,配置云开发环境ID。
@@ -117,6 +120,54 @@ Page({
117120
})
118121
```
119122

123+
### 自定义 MCP 工具卡片
124+
125+
> 以下示例流程以结合腾讯地图 MCP Server 开发自定义工具卡片举例说明
126+
127+
#### 1. 开通 MCP 能力
128+
129+
- 进入云开发平台 AI+ MCP 页面,点击创建MCP Server
130+
131+
![](https://qcloudimg.tencent-cloud.cn/raw/bc2a7815b542b26f5931aa835514dc37.png)
132+
133+
- 若未开通过云托管服务,需先开通云托管
134+
135+
![](https://qcloudimg.tencent-cloud.cn/raw/084b50f265e0335201801c3fb741d04d.png)
136+
137+
#### 2. 配置 MCP Server
138+
139+
- 以腾讯地图 MCP Server 举例,选择模板进行安装(按照指引获取腾讯地图平台API KEY后,配置环境变量)
140+
141+
![](https://qcloudimg.tencent-cloud.cn/raw/a5b15af9bfff83008257a0c99d252b83.png)
142+
143+
#### 3. agent 绑定 MCP Server tools
144+
145+
- 在 agent 配置页点击添加MCP 服务,选择对应的MCP Server tools 使用 (此处腾讯地图示例可勾选 geocoder,placeSearchNearby, directionDriving, weather等工具)
146+
147+
![](https://qcloudimg.tencent-cloud.cn/raw/b45a95e06ec0df8dab5c9d9ec7707faa.png)
148+
149+
150+
#### 4. 开发自定义卡片组件
151+
152+
- 参照本工程中 apps/miniprogram-agent-ui/miniprogram/components/toolCard 目录内自定义工具卡片组件实现
153+
154+
![](https://qcloudimg.tencent-cloud.cn/raw/14a4a82810f0b45bde0c124cc8f3ed1c.png)
155+
156+
#### 5. 卡片组件引用配置
157+
158+
- 自定义卡片组件引用声明配置(可在用户小程序项目全局app.json中配置 或 agent-ui组件index.json中配置)
159+
160+
![](https://qcloudimg.tencent-cloud.cn/raw/cd1dc376a1e238f3186a2209e5875698.png)
161+
162+
- agent-ui 组件内 customCard/index.wxml 中添加自定义组件
163+
164+
![](https://qcloudimg.tencent-cloud.cn/raw/b4cd35ccaa3e72189934ed59d35f7ae5.png)
165+
166+
#### 6. 卡片效果
167+
168+
<img src="https://qcloudimg.tencent-cloud.cn/raw/82adcd08eec9443f8b8a336342a4fa23.png" width="375px">
169+
170+
120171
## 🏗 项目结构
121172

122173
```bash

apps/miniprogram-agent-ui/miniprogram/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ App({
1010
// env 参数决定接下来小程序发起的云开发调用(wx.cloud.xxx)会默认请求到哪个云环境的资源
1111
// 此处请填入环境 ID, 环境 ID 可打开云控制台查看
1212
// 如不填则使用默认环境(第一个创建的环境)
13-
env: "luke-agent-dev-7g1nc8tqc2ab76af",
13+
env: "luke-personal-test-new-8d0d90f5f",
1414
traceUser: true,
1515
});
1616
}

apps/miniprogram-agent-ui/miniprogram/app.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
{
2-
"pages": [
3-
"pages/index/index",
4-
"pages/chatBot/chatBot"
5-
],
2+
"pages": ["pages/index/index", "pages/chatBot/chatBot", "pages/foodBuy/foodBuy"],
3+
"usingComponents": {
4+
"custom-map": "/components/toolCard/map/index",
5+
"custom-weather": "/components/toolCard/weather/index",
6+
"custom-food-list": "/components/toolCard/food-list/index",
7+
"custom-business-list": "/components/toolCard/business-list/index"
8+
},
69
"window": {
710
"navigationBarBackgroundColor": "#ffffff",
811
"navigationBarTextStyle": "black",
@@ -20,4 +23,4 @@
2023
"uploadFile": 60000,
2124
"downloadFile": 60000
2225
}
23-
}
26+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Component({
2+
properties: {
3+
name: {
4+
type: String,
5+
value: "",
6+
},
7+
toolParams: {
8+
type: Object,
9+
value: {},
10+
},
11+
toolData: {
12+
type: Object,
13+
value: {},
14+
},
15+
},
16+
data: {},
17+
lifetimes: {},
18+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"component": true,
3+
"usingComponents": {}
4+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!--components/agent-ui-new/chatFIle/chatFile.wxml-->
2+
<!-- <text>components/agent-ui-new/chatFIle/chatFile.wxml</text> -->
3+
<!-- <block>
4+
<view wx:if="{{name === 'maps_geo' || name === 'maps_direction_driving'}}">
5+
<custom-map name="{{name}}" toolData="{{toolData}}"></custom-map>
6+
</view>
7+
<view wx:if="{{name === 'maps_weather'}}">
8+
<custom-weather name="{{name}}" toolData="{{toolData}}"></custom-weather>
9+
</view>
10+
<view wx:if="{{name === 'map_search_places'}}">
11+
<custom-business-list name="{{name}}" toolData="{{toolData}}"></custom-business-list>
12+
<custom-food-list name="{{name}}" toolData="{{toolData}}"></custom-food-list>
13+
</view>
14+
</block> -->
15+
16+
<block>
17+
<view class="customCard">
18+
<custom-map wx:if="{{name === 'geocoder' || name === 'placeSearchNearby' || 'directionDriving'}}" name="{{name}}" toolParams="{{toolParams}}" toolData="{{toolData}}"></custom-map>
19+
</view>
20+
<view class="customCard">
21+
<custom-weather wx:if="{{name === 'weather'}}" name="{{name}}" toolData="{{toolData}}"></custom-weather>
22+
</view>
23+
<view class="customCard" wx:if="{{name === 'placeSearchNearby'}}">
24+
<custom-business-list name="{{name}}" toolData="{{toolData}}"></custom-business-list>
25+
</view>
26+
<!-- 用户可类似添加自定义组件 -->
27+
</block>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.customCard {
2+
margin: 15px 0px;
3+
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,7 @@ Component({
12021202
let endTime = null; // 记录结束思考时间
12031203
let index = 0;
12041204
for await (let event of res.eventStream) {
1205+
// console.log("event", event);
12051206
const { chatStatus } = this.data;
12061207
if (chatStatus === 0) {
12071208
isManuallyPaused = true;
@@ -1360,6 +1361,7 @@ Component({
13601361
const callBody = {
13611362
id: tool_call.id,
13621363
name: this.transformToolName(tool_call.function.name),
1364+
rawParams: tool_call.function.arguments,
13631365
callParams: "```json\n" + JSON.stringify(tool_call.function.arguments, null, 2) + "\n```",
13641366
content: "",
13651367
};
@@ -1376,9 +1378,11 @@ Component({
13761378
// tool_call 场景,调用响应
13771379
if (type === "tool-result") {
13781380
const { toolCallId, result } = dataJson;
1381+
// console.log("tool-result", result);
13791382
if (lastValue.toolCallList && lastValue.toolCallList.length) {
13801383
const lastToolCallObj = lastValue.toolCallList.find((item) => item.id === toolCallId);
13811384
if (lastToolCallObj && !lastToolCallObj.callResult) {
1385+
lastToolCallObj.rawResult = result;
13821386
lastToolCallObj.callResult = "```json\n" + JSON.stringify(result, null, 2) + "\n```";
13831387
this.setData({
13841388
[`chatRecords[${lastValueIndex}].toolCallList`]: lastValue.toolCallList,
@@ -1405,6 +1409,7 @@ Component({
14051409
[`chatRecords[${lastValueIndex}].content`]: lastValue.content,
14061410
});
14071411
}
1412+
// console.log("this.data.chatRecords", this.data.chatRecords);
14081413
this.setData({
14091414
chatStatus: 0,
14101415
[`chatRecords[${lastValueIndex}].hiddenBtnGround`]: isManuallyPaused,
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"component": true,
33
"usingComponents": {
4-
"markdownPreview":"/components/agent-ui/wd-markdown/index",
5-
"FoldedCard":"/components/agent-ui/collapse/index",
4+
"markdownPreview": "/components/agent-ui/wd-markdown/index",
5+
"FoldedCard": "/components/agent-ui/collapse/index",
66
"chatFile": "/components/agent-ui/chatFile/index",
7-
"feedback":"/components/agent-ui/feedback/index"
7+
"feedback": "/components/agent-ui/feedback/index",
8+
"customCard": "/components/agent-ui/customCard/index"
89
}
9-
}
10+
}

0 commit comments

Comments
 (0)