提示词变量名变更

topo_dev
DESKTOP-DDTUS3E\yaxin 6 months ago
parent 86cc6ab8c9
commit 64b0191819

@ -21,6 +21,8 @@ import java.util.Map;
@Slf4j
@Service
public class LLMExtractServiceImpl implements LLMExtractService {
private static final String VAR_NAME_SOURCE_TEXT = "source_text";
private static final String VAR_NAME_ATTR_DEFINE = "attr_define";
@Autowired
private OllamaChatClient ollamaChatClient;
@ -37,7 +39,7 @@ public class LLMExtractServiceImpl implements LLMExtractService {
5.
{ocr_txt}
{source_text}
json{"title":"*****"},{"title":""}
json
@ -50,7 +52,7 @@ public class LLMExtractServiceImpl implements LLMExtractService {
// 遍历ocrExtractDtoList调用接口提取标题
LLMExtractDtoList.forEach(ocrExtractDto -> {
HashMap<String, String> paramMap = new HashMap<>();
paramMap.put("ocr_txt", ocrExtractDto.getText());
paramMap.put(VAR_NAME_SOURCE_TEXT, ocrExtractDto.getText());
String template = "提取下面文本中前40个字中明显的标题\n" +
"### 注意事项:\n" +
"1. 将结果以JSON格式返回。不需要进行解释。\n" +
@ -61,7 +63,7 @@ public class LLMExtractServiceImpl implements LLMExtractService {
"6. 有可能很大概率是没有标题的。\n" +
"\n" +
"文本原文:\n" +
"{ocr_txt}\n" +
"{source_text}\n" +
"输出json格式{{\"title\":\"*****\"}},如果没有明显标题:{{\"title\":\"\"}}。\n" +
"\n" +
"回溯你输出的结果确保你的输出结果符合json格式。";
@ -109,7 +111,7 @@ public class LLMExtractServiceImpl implements LLMExtractService {
}
{ocr_txt}
{source_text}
{attr_define}
@ -117,7 +119,7 @@ public class LLMExtractServiceImpl implements LLMExtractService {
###
1. JSON
2. ""
3. yyyy-MM-dd
3. yyyy-MM-dd
4. 使
5. 使
@ -143,8 +145,8 @@ public class LLMExtractServiceImpl implements LLMExtractService {
}
requirementBuilder.append("}");
String prompt = StrUtil.format(LLMExtractDto.getPrompt(), Map.of(
"attr_define", requirementBuilder.toString(),
"ocr_txt", LLMExtractDto.getText()
VAR_NAME_ATTR_DEFINE, requirementBuilder.toString(),
VAR_NAME_SOURCE_TEXT, LLMExtractDto.getText()
));
log.info("属性提取请求\n:{}", prompt);
ChatResponse call = ollamaChatClient.call(new Prompt(new UserMessage(prompt)));

Loading…
Cancel
Save