Merge remote-tracking branch 'origin/main'
commit
8f23c91654
@ -0,0 +1,13 @@
|
|||||||
|
package com.supervision.ai.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ToolDTO {
|
||||||
|
|
||||||
|
private String type = "web_search";
|
||||||
|
|
||||||
|
private WebSearchDTO web_search;
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.supervision.ai.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class WebSearchDTO {
|
||||||
|
|
||||||
|
private Boolean enable = false;
|
||||||
|
|
||||||
|
}
|
@ -1,95 +0,0 @@
|
|||||||
package com.supervision;
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.io.FileUtil;
|
|
||||||
import cn.hutool.core.io.file.FileReader;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import cn.hutool.poi.excel.ExcelReader;
|
|
||||||
import cn.hutool.poi.excel.ExcelUtil;
|
|
||||||
import cn.hutool.poi.excel.ExcelWriter;
|
|
||||||
import com.supervision.service.AskService;
|
|
||||||
import com.supervision.vo.SingleTalkReqVO;
|
|
||||||
import com.supervision.vo.SingleTalkResVO;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
|
||||||
public class AskTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private AskService askService;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() throws IOException {
|
|
||||||
// 从excel中获取问题,开始循环调用
|
|
||||||
ExcelReader reader = ExcelUtil.getReader("/Users/flevance/Desktop/知识图谱/正常退休业务问题梳理_0422.xlsx", 1);
|
|
||||||
File file = FileUtil.file("/Users/flevance/Java/KBQA/test.log");
|
|
||||||
ExcelWriter writer = ExcelUtil.getWriter("/Users/flevance/Desktop/知识图谱/正常退休业务问题梳理_0422_output.xlsx", "Sheet2");
|
|
||||||
|
|
||||||
// 从第一行开始读取
|
|
||||||
List<List<Object>> readList = reader.read(1);
|
|
||||||
for (int i = 0; i < readList.size(); i++) {
|
|
||||||
List<Object> objects = readList.get(i);
|
|
||||||
SingleTalkReqVO singleTalkReqVO = new SingleTalkReqVO();
|
|
||||||
singleTalkReqVO.setUserTalk(String.valueOf(objects.get(1)));
|
|
||||||
SingleTalkResVO singleTalkResVO = null;
|
|
||||||
try {
|
|
||||||
singleTalkResVO = askService.singleTalk(singleTalkReqVO);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.info("出现异常,结束");
|
|
||||||
}
|
|
||||||
FileReader fileReader = new FileReader(file);
|
|
||||||
List<String> strings = fileReader.readLines();
|
|
||||||
int y = i + 1;
|
|
||||||
strings.stream().filter(e -> StrUtil.contains(e, "identifyIntent开始识别意图:")).findAny().ifPresent(e -> {
|
|
||||||
String s = StrUtil.subAfter(e, "identifyIntent开始识别意图:", true);
|
|
||||||
writer.writeCellValue(2, y, s);
|
|
||||||
});
|
|
||||||
strings.stream().filter(e -> StrUtil.contains(e, "identifyIntent意图识别结果为:")).findAny().ifPresent(e -> {
|
|
||||||
String s = StrUtil.subAfter(e, "identifyIntent意图识别结果为:", true);
|
|
||||||
writer.writeCellValue(3, y, s);
|
|
||||||
});
|
|
||||||
strings.stream().filter(e -> StrUtil.contains(e, "itemExtractByPossibleItemWithExample查询语句为:")).findAny().ifPresent(e -> {
|
|
||||||
String s = StrUtil.subAfter(e, "itemExtractByPossibleItemWithExample查询语句为:", true);
|
|
||||||
writer.writeCellValue(4, y, s);
|
|
||||||
});
|
|
||||||
strings.stream().filter(e -> StrUtil.contains(e, "itemExtractByPossibleItemWithExample结果为:")).findAny().ifPresent(e -> {
|
|
||||||
String s = StrUtil.subAfter(e, "itemExtractByPossibleItemWithExample结果为:", true);
|
|
||||||
writer.writeCellValue(5, y, s);
|
|
||||||
});
|
|
||||||
strings.stream().filter(e -> StrUtil.contains(e, "answerQuestion的prompt是:")).findAny().ifPresent(e -> {
|
|
||||||
String s = StrUtil.subAfter(e, "answerQuestion的prompt是:", true);
|
|
||||||
writer.writeCellValue(6, y, s);
|
|
||||||
});
|
|
||||||
SingleTalkResVO finalSingleTalkResVO = singleTalkResVO;
|
|
||||||
strings.stream().filter(e -> StrUtil.contains(e, "answerQuestion的答案是:")).findAny().ifPresent(e -> {
|
|
||||||
String s = StrUtil.subAfter(e, "answerQuestion的答案是:", true);
|
|
||||||
if (ObjectUtil.isNotNull(finalSingleTalkResVO)) {
|
|
||||||
writer.writeCellValue(7, y, finalSingleTalkResVO.getAnswerText());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
writer.flush();
|
|
||||||
BufferedWriter writer1 = FileUtil.getWriter(file, Charset.defaultCharset(), false);
|
|
||||||
writer1.write("");
|
|
||||||
writer1.flush();
|
|
||||||
writer1.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue