Skip to content

Commit ca62a1b

Browse files
authored
Merge pull request #68 from TencentCloudBase/dev
Dev
2 parents db10293 + 280e006 commit ca62a1b

File tree

7 files changed

+39
-7
lines changed

7 files changed

+39
-7
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
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.13.2](https://github.com/TencentCloudBase/cloudbase-agent-ui/compare/v1.13.1...v1.13.2) (2025-05-29)
6+
7+
8+
### Bug Fixes
9+
10+
* 添加输出token超限报错 ([26e7d47](https://github.com/TencentCloudBase/cloudbase-agent-ui/commit/26e7d47aef38a1d59aec7b729e2844995e947d96))
11+
* 修复agent-ui 联网查询无结果展示问题 ([5bb2958](https://github.com/TencentCloudBase/cloudbase-agent-ui/commit/5bb2958578d498d3095b4c848d3b04f8e5b77816))
12+
* 修复token数超限问题 ([20d40bb](https://github.com/TencentCloudBase/cloudbase-agent-ui/commit/20d40bbf5a6399c7866cd67e695ca0e5c5a7584e))
13+
* fix error handle logic ([189b9fe](https://github.com/TencentCloudBase/cloudbase-agent-ui/commit/189b9fe059eb58a2b30fad71e280d5e65b85c850))
14+
515
### [1.13.1](https://github.com/TencentCloudBase/cloudbase-agent-ui/compare/v1.13.0...v1.13.1) (2025-05-21)
616

717

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1408,6 +1408,7 @@ Component({
14081408
finish_reason,
14091409
search_results,
14101410
error,
1411+
usage,
14111412
} = dataJson;
14121413
const newValue = [...this.data.chatRecords];
14131414
// 取最后一条消息更新
@@ -1416,7 +1417,7 @@ Component({
14161417
lastValue.role = role || "assistant";
14171418
lastValue.record_id = record_id;
14181419
// 优先处理错误,直接中断
1419-
if (finish_reason === "error" || finish_reason === "content_filter") {
1420+
if (finish_reason === "error" || finish_reason === "content_filter" || error) {
14201421
lastValue.search_info = null;
14211422
lastValue.reasoning_content = "";
14221423
lastValue.knowledge_meta = [];
@@ -1569,6 +1570,16 @@ Component({
15691570
}
15701571
}
15711572
}
1573+
// 超出token数限制
1574+
if (type === "finish" && finish_reason === "length") {
1575+
const completionTokens = usage?.completionTokens || 0;
1576+
lastValue.error = completionTokens
1577+
? `当前输出token长度为 ${completionTokens},已超过最大限制,请重新提问`
1578+
: "已超过最大限制,请重新提问";
1579+
this.setData({
1580+
[`chatRecords[${lastValueIndex}].error`]: lastValue.error,
1581+
});
1582+
}
15721583
} catch (e) {
15731584
console.log("err", event, e);
15741585
break;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
已匹配 {{item.db_len}} 张数据表
8787
</view>
8888
<!-- 联网搜索 -->
89-
<FoldedCard wx:if="{{item.search_info}}" initStatus="{{false}}" showBgColor="{{true}}">
89+
<FoldedCard wx:if="{{item.search_info && item.search_info.search_results}}" initStatus="{{false}}" showBgColor="{{true}}">
9090
<view slot="title" style="opacity: 0.7;font-size: 14px;display: flex; align-items: center; gap: 8px;">
9191
<image src="./imgs/search.svg" mode="aspectFill" style="width: 36rpx;height: 36rpx;" />
9292
<text>已参考 {{item.search_info.search_results.length}} 个网页</text>

components/agent-ui/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1408,6 +1408,7 @@ Component({
14081408
finish_reason,
14091409
search_results,
14101410
error,
1411+
usage,
14111412
} = dataJson;
14121413
const newValue = [...this.data.chatRecords];
14131414
// 取最后一条消息更新
@@ -1416,7 +1417,7 @@ Component({
14161417
lastValue.role = role || "assistant";
14171418
lastValue.record_id = record_id;
14181419
// 优先处理错误,直接中断
1419-
if (finish_reason === "error" || finish_reason === "content_filter") {
1420+
if (finish_reason === "error" || finish_reason === "content_filter" || error) {
14201421
lastValue.search_info = null;
14211422
lastValue.reasoning_content = "";
14221423
lastValue.knowledge_meta = [];
@@ -1569,6 +1570,16 @@ Component({
15691570
}
15701571
}
15711572
}
1573+
// 超出token数限制
1574+
if (type === "finish" && finish_reason === "length") {
1575+
const completionTokens = usage?.completionTokens || 0;
1576+
lastValue.error = completionTokens
1577+
? `当前输出token长度为 ${completionTokens},已超过最大限制,请重新提问`
1578+
: "已超过最大限制,请重新提问";
1579+
this.setData({
1580+
[`chatRecords[${lastValueIndex}].error`]: lastValue.error,
1581+
});
1582+
}
15721583
} catch (e) {
15731584
console.log("err", event, e);
15741585
break;

components/agent-ui/index.wxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
已匹配 {{item.db_len}} 张数据表
8787
</view>
8888
<!-- 联网搜索 -->
89-
<FoldedCard wx:if="{{item.search_info}}" initStatus="{{false}}" showBgColor="{{true}}">
89+
<FoldedCard wx:if="{{item.search_info && item.search_info.search_results}}" initStatus="{{false}}" showBgColor="{{true}}">
9090
<view slot="title" style="opacity: 0.7;font-size: 14px;display: flex; align-items: center; gap: 8px;">
9191
<image src="./imgs/search.svg" mode="aspectFill" style="width: 36rpx;height: 36rpx;" />
9292
<text>已参考 {{item.search_info.search_results.length}} 个网页</text>

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cloudbase-agent-ui",
3-
"version": "1.13.1",
3+
"version": "1.13.2",
44
"description": "微信小程序 Agent UI组件",
55
"main": "index.js",
66
"directories": {

0 commit comments

Comments
 (0)