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

fix[智能问数]: csv对话

parent 33fbbe6e
......@@ -286,26 +286,8 @@ 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);
//输出EChart
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(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;
}
}
String eChartOption = functionResult.getFunctionResult();
functionRecord = outputECharts(eChartOption, sseUtil, functionRecord);
}
} else if (StringUtils.isNotBlank(fileUrl)) {
CSVChainResponse csvChainResponse = new CSVChainResponse();
......@@ -313,12 +295,13 @@ public class AiBiServiceImpl implements AiBiService {
csvChainResponse.setContext(null);
csvChainResponse.setFilePath(fileUrl);
csvChainResult = chainService.csvChain(csvChainResponse);
if (csvChainResult != null) {
String[] csvRes = JsonUtils.deSerialize(csvChainResult.getResult(), String[].class);
if (ArrayUtils.isNotEmpty(csvRes)) {
if (StringUtils.isNotBlank(csvChainResult.getResult())) {
JSONObject echartJSONObject = new JSONObject();
echartJSONObject.put("sql", null);
echartJSONObject.put("sql_result", csvRes.toString());
echartJSONObject.put("sql", StringUtils.EMPTY);
echartJSONObject.put("sql_result", csvChainResult.getResult());
echartJSONObject.put("question", input);
AbstractFunctionResult<String> functionResult = eChartGenerateFunction.doFunction(echartJSONObject.toJSONString(), null, null, null);
String eChartOption = functionResult.getFunctionResult();
......@@ -369,7 +352,7 @@ public class AiBiServiceImpl implements AiBiService {
private String outputECharts(String eChartOption, SSEUtil sseUtil, String functionRecord) throws IOException {
//输出EChart
if (eChartOption != null) {
if (eChartOption != null && StringUtils.isNotBlank(eChartOption)) {
JSONObject jsonObject = JSONObject.parseObject(eChartOption);
if (!jsonObject.containsKey("skip")) {
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