topo_dev
liu 10 months ago
parent f0e6ffbb0f
commit 17065eb9c9

@ -1,5 +1,6 @@
package com.supervision.police.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -61,6 +62,7 @@ public class RecordServiceImpl extends ServiceImpl<NoteRecordMapper, NoteRecord>
private MinioFileMapper minioFileMapper;
private final OllamaChatClient chatClient;
@Autowired
public RecordServiceImpl(OllamaChatClient chatClient) {
this.chatClient = chatClient;
@ -126,16 +128,23 @@ public class RecordServiceImpl extends ServiceImpl<NoteRecordMapper, NoteRecord>
noteRecord.setQuestion(qa.getQuestion());
noteRecord.setAnswer(qa.getAnswer());
noteRecord.setCreateTime(new Date());
String test = "分类任务: 对话笔记录文本分类。目标: 将给定的对话笔记录分配到预定义的类别中,这些类别包括但不限于: " + allTypes.toString() + "。";
String example = "说明: 提供一段对话笔记录文本,分类器应该识别出对话的主题,并将其归类到上述类别中的一个。" +
"示例输入: 文本: \"办案警官问你为了骗取更多的钱都做了哪些准备。裴金禄回答我刚开始我就是自己想了一些关于骗钱的点子后面为了更不容易让别人识破我为了更佳逼真我就从网上随便搜了一家租赁公司我就搜到了兰州胜利机械租赁有限公司我又想到了我管理的中铁北京局和中铁电气化局施工公司。我先是通过百度搜索了“办证”之后就在网页上面弹出了一个页面上面有一个QQ号我就加上了。加上之后我就将我的要求给他说了要求他给我刻两个假的公章一个是兰州胜利机械租赁有限公司合同专用章另一个是中铁北京局集团有限公司合同专用章。我还要求他给我伪造了一张兰州胜利机械租赁有限公司的营业执照\"" +
"预期输出: { type: '诈骗准备' }" +
"任务要求: " +
"1. 分类器应当准确地识别对话的主题。 " +
"2. 如果一段对话笔记录包含多个主题,请选择最相关的类别。" +
"3. 必须考虑上下文语境和专业术语来确定正确的分类。";
String end = "对话内容为:";
List<Message> messages = new ArrayList<>(List.of(new SystemMessage(test + example + end + qa.getQuestion() + qa.getAnswer())));
Map<String, String> paramMap = new HashMap<>();
paramMap.put("allTypes", allTypes.toString());
paramMap.put("question", qa.getQuestion());
paramMap.put("answer", qa.getAnswer());
String template = """
: : {allTypes}"
:
: :
便QQ
: { type: '' }
:
1.
2.
3.
{question} {answer}
""";
List<Message> messages = new ArrayList<>(List.of(new SystemMessage(StrUtil.format(template, paramMap))));
Prompt prompt = new Prompt(messages);
StopWatch stopWatch = new StopWatch();
stopWatch.start();
@ -143,8 +152,7 @@ public class RecordServiceImpl extends ServiceImpl<NoteRecordMapper, NoteRecord>
ChatResponse call = chatClient.call(prompt);
stopWatch.stop();
log.info("耗时:{}", stopWatch.getTotalTimeSeconds());
Generation result = call.getResult();
String content = result.getOutput().getContent();
String content = call.getResult().getOutput().getContent();
log.info("问:{}, 答:{}", qa.getQuestion(), qa.getAnswer());
log.info("分析的结果是:{}", content);
JSONObject jsonObject = new JSONObject(content);

Loading…
Cancel
Save