Commit 8d94fd24 authored by zhouwei's avatar zhouwei

修改提取紧急通知概要的提示词

parent 2cfaa25a
package com.nanyan.securitylink.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.nanyan.securitylink.dto.AIRequestDTO;
import com.nanyan.securitylink.service.AIService;
......@@ -48,6 +47,11 @@ public class AIController {
return Response.SUCCESS(aiService.extractUrgentNoticeSummary(AIRequestDTO));
}
@PostMapping("/urgent/notice/week/summary")
public Response<AIResponse<String>> extractUrgentNoticeWeekSummary(@RequestBody AIRequestDTO AIRequestDTO) {
return Response.SUCCESS(aiService.extractUrgentNoticeWeekSummary(AIRequestDTO));
}
@PostMapping("/news/country/city")
public Response<AIResponse<JSONObject>> collectNewsCountryAndCity(@RequestBody AIRequestDTO AIRequestDTO) {
return Response.SUCCESS(aiService.collectNewsCountryAndCity(AIRequestDTO));
......
......@@ -25,4 +25,6 @@ public interface AIService {
//提取紧急通知概要信息
AIResponse<JSONObject> extractUrgentNoticeSummary(AIRequestDTO aiRequestDTO);
AIResponse<String> extractUrgentNoticeWeekSummary(AIRequestDTO aiRequestDTO);
}
......@@ -397,7 +397,7 @@ public class AIServiceImpl implements AIService {
"- 仔细阅读输入的通知消息,确保理解所有关键信息。\n" +
"- 从通知中提取与主体事件直接相关的内容,包括时间、地点、事件描述等,但忽略使馆提醒部分。\n" +
"- 用简洁的语言总结注意事项,确保通俗易懂且不超过50字。\n" +
"- 根据事件性质判断事件类型(如自然灾害、政治事件、公共卫生事件等)。\n" +
"- 根据事件性质判断事件类型(如自然灾害、政治事件、公共卫生事件等),仅提取一件事件。\n" +
"- 将提取的信息整理为JSON格式,确保字段名与要求一致(summary、note、event)。\n" +
"- 输出时不要包含任何XML标签,仅提供纯JSON格式内容。\n" +
"\n" +
......@@ -417,47 +417,85 @@ public class AIServiceImpl implements AIService {
"}\n" +
"</output>\n" +
"</example>\n" +
"</examples>";
buildChatInputData(chatInputData, aiRequestDTO.getInputs().getMsg_info(), systemPrompt);
String apiKey = getModelApiKey();
ChatCompletionResponse chatCompletionResponse = aiRequest(chatInputData, apiKey);
if (CollectionUtils.isNotEmpty(chatCompletionResponse.getChoices())) {
AIResponse<JSONObject> aiResponse = new AIResponse<>();
String content = chatCompletionResponse.getChoices().get(0).getMessage().getContent();
aiResponse.setFinish_reason(chatCompletionResponse.getChoices().get(0).getFinish_reason());
if(StringUtils.isNotEmpty(content)){
content = content.replaceAll("```json","").replaceAll("```", "");
JSONObject jsonObject = JSONArray.parseObject(content, JSONObject.class);
ResultVO<JSONObject> outputs = new ResultVO<>();
List<JSONObject> jsonObjects = new ArrayList<>();
jsonObjects.add(jsonObject);
outputs.setResult(jsonObjects);
aiResponse.setOutputs(outputs);
}
return aiResponse;
}
return null;
}
@Override
public AIResponse<String> extractUrgentNoticeWeekSummary(AIRequestDTO aiRequestDTO) {
ChatInputData chatInputData = new ChatInputData();
String systemPrompt = "```xml\n" +
"<instruction>\n" +
"根据多条文旅部或外交部发布的紧急通知信息,生成一段简短的概括性安全提示。提示需涵盖保险责任相关内容,并以“Security Link在此提醒您”开头。具体要求如下:\n" +
"1. 内容需简洁明了,突出保险责任和风险规避建议。\n" +
"2. 语言风格需正式且具有警示性。\n" +
"3. 不得包含任何XML标签。\n" +
"4. 根据输入信息中的关键风险点(如示威游行、自然灾害等)生成对应的保险责任提示。\n" +
"5. 结尾需提供具体的行动建议(如“避开相关区域”或“联系保险公司”等)。\n" +
"\n" +
"生成步骤:\n" +
"1. 提取输入信息中的核心风险事件(如战争、罢工、自然灾害等)。\n" +
"2. 明确该风险事件在保险条款中的常见责任归属(如“除外责任”或“有限保障”)。\n" +
"3. 组合成标准句式:“Security Link在此提醒您,[风险事件]常被列为[保险责任说明],因此[行动建议]。”\n" +
"4. 检查语句通顺性和专业性,确保无歧义。\n" +
"</instruction>\n" +
"\n" +
"<examples>\n" +
"<example>\n" +
"<input>\n" +
"文旅部及外交部紧急通知:受台风影响,某岛国机场关闭至明日18时。使馆建议旅客暂缓行程并关注航班动态。\n" +
"外交部提醒:某国首都爆发大规模反政府示威,局部地区出现武装冲突\n" +
"</input>\n" +
"<output>\n" +
"{\n" +
" \"summary\": \"某岛国受台风影响,机场关闭至明日18时\",\n" +
" \"note\": \"暂缓行程并密切关注航班动态\",\n" +
" \"event\": \"自然灾害\"\n" +
"}\n" +
"Security Link在此提醒您,示威游行及武装冲突事件通常被列为旅行保险的除外责任,建议您暂勿前往相关区域,并确认保单中的战争条款保障范围。\n" +
"</output>\n" +
"</example>\n" +
"\n" +
"<example>\n" +
"<input>\n" +
"文旅部及外交部紧急通知:某地爆发不明原因呼吸道疾病,已造成多人感染。使馆提醒公民保持个人卫生并避免接触患者。\n" +
"文旅部通知:B国沿海地区遭遇百年一遇台风,多趟航班取消\n" +
"</input>\n" +
"<output>\n" +
"{\n" +
" \"summary\": \"某地爆发不明原因呼吸道疾病,已造成多人感染\",\n" +
" \"note\": \"保持个人卫生并避免接触患者\",\n" +
" \"event\": \"公共卫生事件\"\n" +
"}\n" +
"Security Link在此提醒您,自然灾害导致的行程中断可能需特定保险条款才予理赔,请立即联系保险公司报备,并保留所有交通票据作为理赔凭证。\n" +
"</output>\n" +
"</example";
"</example>\n" +
"<format_requirements>\n" +
"1. 严格采用“Security Link在此提醒您”作为开头\n" +
"2. 必须包含“保险”相关表述\n" +
"3. 风险描述需与输入信息完全匹配\n" +
"4. 行动建议需具体可行\n" +
"5. 总字数控制在50-80字之间\n";
buildChatInputData(chatInputData, aiRequestDTO.getInputs().getMsg_info(), systemPrompt);
String apiKey = getModelApiKey();
ChatCompletionResponse chatCompletionResponse = aiRequest(chatInputData, apiKey);
if (CollectionUtils.isNotEmpty(chatCompletionResponse.getChoices())) {
AIResponse<JSONObject> aiResponse = new AIResponse<>();
AIResponse<String> aiResponse = new AIResponse<>();
String content = chatCompletionResponse.getChoices().get(0).getMessage().getContent();
aiResponse.setFinish_reason(chatCompletionResponse.getChoices().get(0).getFinish_reason());
if(StringUtils.isNotEmpty(content)){
content = content.replaceAll("```json","").replaceAll("```", "");
JSONObject jsonObject = JSONArray.parseObject(content, JSONObject.class);
ResultVO<JSONObject> outputs = new ResultVO<>();
List<JSONObject> jsonObjects = new ArrayList<>();
jsonObjects.add(jsonObject);
outputs.setResult(jsonObjects);
ResultVO<String> outputs = new ResultVO<>();
List<String> contents = new ArrayList<>();
contents.add(content);
outputs.setResult(contents);
aiResponse.setOutputs(outputs);
}
return aiResponse;
......
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