Commit 64582e53 authored by alex yao's avatar alex yao

fix[智能问数]: 修复[数据库查询异常]断连问题

parent cf7758b9
......@@ -212,9 +212,10 @@ public class AiBiServiceImpl implements AiBiService {
@Override
public void callV2(String dialoguesId, String input, String fileUrl, Integer[] knowledgeIds, Integer[] databaseIds, Long userId) throws Exception {
public void callV2(String dialoguesId, String input, String fileUrl, Integer[] knowledgeIds, Integer[] databaseIds, Long userId) throws IOException {
SSEUtil sseUtil = new SSEUtil();
// 保存对话基础信息
try {
BizAiDialoguesEntity bizAiDialoguesEntity = new BizAiDialoguesEntity();
bizAiDialoguesEntity.setMemberId(userId);
bizAiDialoguesEntity.setDialoguesId(dialoguesId);
......@@ -236,7 +237,7 @@ public class AiBiServiceImpl implements AiBiService {
throw new BusinessException("仅支持单个数据库");
}
long inputTime = System.currentTimeMillis();
SSEUtil sseUtil = new SSEUtil();
CSVChainResult csvChainResult = new CSVChainResult();
List<DBChainResult> dbChainResults = new ArrayList<>();
String functionRecord = StringUtils.EMPTY;
......@@ -285,14 +286,13 @@ public class AiBiServiceImpl implements AiBiService {
echartJSONObject.put("sql_result", dbChainResult.getSqlResult());
echartJSONObject.put("question", input);
AbstractFunctionResult<String> functionResult = eChartGenerateFunction.doFunction(echartJSONObject.toJSONString(), null, null, null);
String eChartOption = functionResult.getFunctionResult();
//输出EChart
if (eChartOption != null) {
JSONObject jsonObject = JSONObject.parseObject(eChartOption);
if (functionResult != null && StringUtils.isNotBlank(functionResult.getFunctionResult())) {
JSONObject jsonObject = JSONObject.parseObject(functionResult.getFunctionResult());
if (!jsonObject.containsKey("skip")) {
ToolFunction toolFunction = new ToolFunction();
toolFunction.setName("echart_function");
toolFunction.setResult(eChartOption);
toolFunction.setResult(functionResult.getFunctionResult());
toolFunction.setDisplayFormat("json");
toolFunction.setArguments(null);
result = new LargeModelDemandResult();
......@@ -361,6 +361,9 @@ public class AiBiServiceImpl implements AiBiService {
bizAgentApplicationDialoguesRecordService.save(inputRecord);
bizAgentApplicationDialoguesRecordService.save(assistantRecord);
} catch (Exception e) {
sseUtil.completeByError(e.getMessage());
}
}
......
......@@ -33,6 +33,7 @@ public class ChainServiceImpl implements ChainService {
@Override
public DBChainResult dbChain(DBChainResponse response) {
logger.info("dbChain response : {}", response);
try {
DBChainResult dbChainResult = aiDialogueService.dbChain(response);
if (dbChainResult == null || dbChainResult.getStatus().equals("error")) {
logger.error("dbChain result error : {} , response:{}", dbChainResult, response);
......@@ -43,6 +44,10 @@ public class ChainServiceImpl implements ChainService {
return null;
}
return dbChainResult;
} catch (Exception e) {
logger.error("调用数据库失败:{}", e.getMessage());
return null;
}
}
@Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment