Skip to content
Merged

Dev #60

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. 卡片效果

<img src="https://qcloudimg.tencent-cloud.cn/raw/82adcd08eec9443f8b8a336342a4fa23.png" width="375px">

Expand Down
2 changes: 1 addition & 1 deletion apps/miniprogram-agent-ui/miniprogram/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ App({
// env 参数决定接下来小程序发起的云开发调用(wx.cloud.xxx)会默认请求到哪个云环境的资源
// 此处请填入环境 ID, 环境 ID 可打开云控制台查看
// 如不填则使用默认环境(第一个创建的环境)
env: "luke-agent-dev-7g1nc8tqc2ab76af",
env: "luke-personal-test-new-8d0d90f5f",
traceUser: true,
});
}
Expand Down
18 changes: 2 additions & 16 deletions apps/miniprogram-agent-ui/miniprogram/components/agent-ui/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -487,7 +485,6 @@ Component({
method: "GET",
header: {},
success: (res) => {
console.log("conversation list res", res);
resolve(res);
},
fail(e) {
Expand Down Expand Up @@ -517,7 +514,6 @@ Component({
},
method: "POST",
success: (res) => {
console.log("create conversation res", res);
resolve(res);
},
fail(e) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -598,19 +593,16 @@ 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) {
// TODO: 临时倒序处理
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),
Expand Down Expand Up @@ -644,7 +636,6 @@ Component({
earlyCon.push(item);
}
}
console.log("todayCon curMonthCon earlyCon", todayCon, curMonthCon, earlyCon);
return {
todayCon,
curMonthCon,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -1847,7 +1840,6 @@ Component({
},
method: "POST",
success: (res) => {
console.log("create text-to-speech task res", res);
resolve(res);
},
fail(e) {
Expand All @@ -1856,7 +1848,6 @@ Component({
},
});
});
console.log("text-to-speech", res);
const { data } = res;
if (data && data.TaskId) {
const taskId = data.TaskId;
Expand All @@ -1873,7 +1864,6 @@ Component({
},
method: "GET",
success: (res) => {
console.log("create text-to-speech task res", res);
resolve(res);
},
fail(e) {
Expand All @@ -1882,7 +1872,6 @@ Component({
},
});
});
console.log("query task res", res);
const { data } = res;
if (data.code || data.Status === 2) {
loopQueryStatus = false;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
padding: 0rpx !important;
width: 64rpx !important;
height: 64rpx;
border: none !important;
}

.avatar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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],
Expand All @@ -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;
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -118,11 +116,13 @@ Component({
雨: "rainy",
雪: "snowy",
雷阵雨: "thunderstorm",
阵雨: "rainy",
大雨: "rainy",
中雨: "rainy",
小雨: "rainy",
晴间多云: "sunnyovercast",
};

return weatherMap[weather] || "sunny";
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<view class="temp-container">
<!-- <view class="temp-circle {{isDay ? 'day-circle' : 'night-circle'}}"></view> -->
<view style="display: flex;align-items: center;flex-direction: row;">
<image class="temp-circle" src="{{'./assets/' + (isDay ? today.dayweatherIcon : today.nightweatherIcon) + '.svg'}}" mode="aspectFit"></image>
<image wx:if="{{today.dayweatherIcon}}" class="temp-circle" src="{{'./assets/' + (isDay ? today.dayweatherIcon : today.nightweatherIcon) + '.svg'}}" mode="aspectFit"></image>
<text class="high-low-text">{{isDay ? today.dayweather : today.nightweather}}</text>
</view>
</view>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, // 允许下拉刷新
Expand Down
Loading
Loading