Commit 75bca6fb authored by alex yao's avatar alex yao

fix[智能问数]: csv对话

parent 33fbbe6e
...@@ -286,26 +286,8 @@ public class AiBiServiceImpl implements AiBiService { ...@@ -286,26 +286,8 @@ public class AiBiServiceImpl implements AiBiService {
echartJSONObject.put("sql_result", dbChainResult.getSqlResult()); echartJSONObject.put("sql_result", dbChainResult.getSqlResult());
echartJSONObject.put("question", input); echartJSONObject.put("question", input);
AbstractFunctionResult<String> functionResult = eChartGenerateFunction.doFunction(echartJSONObject.toJSONString(), null, null, null); AbstractFunctionResult<String> functionResult = eChartGenerateFunction.doFunction(echartJSONObject.toJSONString(), null, null, null);
//输出EChart String eChartOption = functionResult.getFunctionResult();
if (functionResult != null && StringUtils.isNotBlank(functionResult.getFunctionResult())) { functionRecord = outputECharts(eChartOption, sseUtil, functionRecord);
JSONObject jsonObject = JSONObject.parseObject(functionResult.getFunctionResult());
if (!jsonObject.containsKey("skip")) {
ToolFunction toolFunction = new ToolFunction();
toolFunction.setName("echart_function");
toolFunction.setResult(functionResult.getFunctionResult());
toolFunction.setDisplayFormat("json");
toolFunction.setArguments(null);
result = new LargeModelDemandResult();
result.setCode("0");
result.setFunction(toolFunction);
result.setDbChainResult(null);
result.setKnowledgeContentResult(null);
String toolFunctionJson = JsonUtils.serialize(result);
sseUtil.send(toolFunctionJson);
functionRecord = toolFunctionJson;
}
}
} }
} else if (StringUtils.isNotBlank(fileUrl)) { } else if (StringUtils.isNotBlank(fileUrl)) {
CSVChainResponse csvChainResponse = new CSVChainResponse(); CSVChainResponse csvChainResponse = new CSVChainResponse();
...@@ -313,12 +295,13 @@ public class AiBiServiceImpl implements AiBiService { ...@@ -313,12 +295,13 @@ public class AiBiServiceImpl implements AiBiService {
csvChainResponse.setContext(null); csvChainResponse.setContext(null);
csvChainResponse.setFilePath(fileUrl); csvChainResponse.setFilePath(fileUrl);
csvChainResult = chainService.csvChain(csvChainResponse); csvChainResult = chainService.csvChain(csvChainResponse);
if (csvChainResult != null) { if (csvChainResult != null) {
String[] csvRes = JsonUtils.deSerialize(csvChainResult.getResult(), String[].class); if (StringUtils.isNotBlank(csvChainResult.getResult())) {
if (ArrayUtils.isNotEmpty(csvRes)) {
JSONObject echartJSONObject = new JSONObject(); JSONObject echartJSONObject = new JSONObject();
echartJSONObject.put("sql", null); echartJSONObject.put("sql", StringUtils.EMPTY);
echartJSONObject.put("sql_result", csvRes.toString()); echartJSONObject.put("sql_result", csvChainResult.getResult());
echartJSONObject.put("question", input); echartJSONObject.put("question", input);
AbstractFunctionResult<String> functionResult = eChartGenerateFunction.doFunction(echartJSONObject.toJSONString(), null, null, null); AbstractFunctionResult<String> functionResult = eChartGenerateFunction.doFunction(echartJSONObject.toJSONString(), null, null, null);
String eChartOption = functionResult.getFunctionResult(); String eChartOption = functionResult.getFunctionResult();
...@@ -367,9 +350,9 @@ public class AiBiServiceImpl implements AiBiService { ...@@ -367,9 +350,9 @@ public class AiBiServiceImpl implements AiBiService {
} }
private String outputECharts(String eChartOption, SSEUtil sseUtil, String functionRecord) throws IOException { private String outputECharts(String eChartOption, SSEUtil sseUtil, String functionRecord) throws IOException {
//输出EChart //输出EChart
if (eChartOption != null) { if (eChartOption != null && StringUtils.isNotBlank(eChartOption)) {
JSONObject jsonObject = JSONObject.parseObject(eChartOption); JSONObject jsonObject = JSONObject.parseObject(eChartOption);
if (!jsonObject.containsKey("skip")) { if (!jsonObject.containsKey("skip")) {
ToolFunction toolFunction = new ToolFunction(); ToolFunction toolFunction = new ToolFunction();
......
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