Skip to content

Commit 5c4437b

Browse files
committed
feat: support tencentmap card
1 parent 75cdf8a commit 5c4437b

Some content is hidden

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

50 files changed

+1688
-15
lines changed

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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
</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+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
<image wx:if="{{bot.botId && showMultiConversation}}" class="con-icon" bind:tap="createNewConversation" src="./imgs/chat-bubble-add.svg" mode="aspectFill"/>
5656
</view>
5757
</view>
58-
<view style="height: 100%;overflow: auto;position: relative;">
58+
<view style="height: 100%;overflow: auto;position: relative;">
5959
<!-- 聊天对话区 -->
6060
<scroll-view bindwheel="onWheel" enhanced="{{true}}" bindscroll="onScroll" binddragstart="handleScrollStart" class="main" style="height: 100%;" scroll-y="{{true}}" scroll-top="{{viewTop}}" scroll-into-view="{{ scrollTo }}" lower-threshold="1" bindscrolltolower="handleScrollToLower" show-scrollbar="{{false}}" refresher-enabled="{{showPullRefresh && (bot.multiConversationEnable ? conversation : true)}}" refresher-threshold="{{80}}" bindrefresherrefresh="handleRefresh" refresher-triggered="{{triggered}}" bounces="{{false}}">
6161
<view class="contentBox" style="margin-bottom: 30px;">
@@ -141,6 +141,7 @@
141141
<markdownPreview markdown="{{subItem.callResult||''}}" fontSize="{{28}}"></markdownPreview>
142142
</view>
143143
</FoldedCard>
144+
<customCard wx:if="{{subItem.rawResult}}" name="{{subItem.name}}" toolParams="{{subItem.rawParams}}" toolData="{{subItem.rawResult}}"></customCard>
144145
</block>
145146
</view>
146147
<!-- 正文 -->
Lines changed: 5 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)