mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2026-01-27 17:18:11 +00:00
--author:scott--date:20261026--for:优化异常处理,返回具体错误信息
This commit is contained in:
parent
360f5d779a
commit
a20cba0adf
@ -185,7 +185,7 @@ public class AiragModelController extends JeecgController<AiragModel, IAiragMode
|
||||
//update-end---author:wangshuai---date:2026-01-07---for:【QQYUN-12145】【AI】AI 绘画创作---
|
||||
}catch (Exception e){
|
||||
log.error("测试模型连接失败", e);
|
||||
return Result.error("测试模型连接失败,请检查模型配置是否正确!");
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
// 测试成功激活数据
|
||||
airagModel.setActivateFlag(1);
|
||||
|
||||
@ -3,6 +3,8 @@ package org.jeecg.modules.airag.llm.handler;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import dev.langchain4j.agent.tool.ToolSpecification;
|
||||
import dev.langchain4j.data.message.*;
|
||||
import dev.langchain4j.exception.InvalidRequestException;
|
||||
import dev.langchain4j.exception.ToolExecutionException;
|
||||
import dev.langchain4j.mcp.McpToolProvider;
|
||||
import dev.langchain4j.rag.query.router.QueryRouter;
|
||||
import dev.langchain4j.service.TokenStream;
|
||||
@ -116,6 +118,9 @@ public class AIChatHandler implements IAIChatHandler {
|
||||
String resp;
|
||||
try {
|
||||
resp = llmHandler.completions(messages, params);
|
||||
} catch (ToolExecutionException | InvalidRequestException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return "";
|
||||
} catch (Exception e) {
|
||||
// langchain4j 异常友好提示
|
||||
String errMsg = "调用大模型接口失败,详情请查看后台日志。";
|
||||
@ -133,7 +138,7 @@ public class AIChatHandler implements IAIChatHandler {
|
||||
for (Map.Entry<String, String> entry : MODEL_ERROR_MAP.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String value = entry.getValue();
|
||||
if (errMsg.contains(key)) {
|
||||
if (exceptionMsg.contains(key)) {
|
||||
errMsg = value;
|
||||
break;
|
||||
}
|
||||
@ -454,7 +459,7 @@ public class AIChatHandler implements IAIChatHandler {
|
||||
for (Map.Entry<String, String> entry : MODEL_ERROR_MAP.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String value = entry.getValue();
|
||||
if (errMsg.contains(key)) {
|
||||
if (e.getMessage().contains(key)) {
|
||||
errMsg = value;
|
||||
break;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user