Skip to content

Commit 57319ad

Browse files
wuayeewuayee
andauthored
[app-builder] 调用大模型生成智能体超时后,提示优化 (#504)
Co-authored-by: wuayee <wuayee@noreply.gitcode.com>
1 parent bbc16a9 commit 57319ad

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

app-builder/plugins/aipp-plugin/src/main/java/modelengine/fit/jober/aipp/controller/AgentController.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import modelengine.jade.service.annotations.CarverSpan;
2828
import modelengine.jade.service.annotations.SpanAttr;
2929

30+
import java.net.SocketTimeoutException;
31+
3032
/**
3133
* 表示智能体信息获取接口集。
3234
*
@@ -74,9 +76,12 @@ public Rsp<AgentInfoEntity> generateAgentInfo(HttpClassicServerRequest request,
7476
entity.setTools(
7577
this.agentInfoGenerateService.selectTools(dto.getDescription(), context.getOperator(), context));
7678
} catch (ClientException e) {
77-
// 模型生成内容超时的情况下,提醒用户更换默认模型
7879
log.error("Failed to generate agent infos.", e);
79-
throw new AippException(AippErrCode.GENERATE_CONTENT_FAILED, "agent infos", e.getMessage());
80+
if (e.getCause() != null && e.getCause() instanceof SocketTimeoutException) {
81+
throw new AippException(AippErrCode.MODEL_INVOKE_TIMEOUT);
82+
} else {
83+
throw new AippException(AippErrCode.GENERATE_CONTENT_FAILED, "agent infos", e.getMessage());
84+
}
8085
}
8186
return Rsp.ok(entity);
8287
}

app-builder/plugins/aipp-plugin/src/main/resources/i18n/messages_en.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,5 @@
146146
90002142=Form not exist.
147147
90002143=No permission to operate this form.
148148
90002144=The app is not in guest mode.
149+
90002145=The large model call timed out. Please try changing the default model.
149150
90003000=The application template does not exist.

app-builder/plugins/aipp-plugin/src/main/resources/i18n/messages_zh.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,5 @@
147147
90002142=表单不存在。
148148
90002143=没有权限操作该表单。
149149
90002144=应用未打开游客模式。
150+
90002145=大模型调用超时,请尝试更换默认模型。
150151
90003000=应用模板不存在。

app-builder/services/aipp-service/src/main/java/modelengine/fit/jober/aipp/common/exception/AippErrCode.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,11 @@ public enum AippErrCode implements ErrorCode, RetCode {
781781
*/
782782
APP_NOT_IN_GUEST_MODE(90002144, "应用未打开游客模式。"),
783783

784+
/**
785+
* 大模型调用超时。
786+
*/
787+
MODEL_INVOKE_TIMEOUT(90002145, "大模型调用超时,请尝试更换默认模型。"),
788+
784789
/**
785790
* 应用模板不存在。
786791
*/

0 commit comments

Comments
 (0)