提交 e9a1029d 作者: 洪东保

大模型配置

父级 6191cd02
...@@ -78,6 +78,9 @@ public class FileProcessTask { ...@@ -78,6 +78,9 @@ public class FileProcessTask {
private static final int MAX_RETRY = 3; private static final int MAX_RETRY = 3;
private String llmApiAddr; private String llmApiAddr;
private String llmModel;
private String llmToken;
private Integer llmMaxTokens;
private Boolean finalRetry; //表示是兜底重试机制 private Boolean finalRetry; //表示是兜底重试机制
private MeetingInfoMapper meetingInfoMapper; private MeetingInfoMapper meetingInfoMapper;
...@@ -314,55 +317,7 @@ public class FileProcessTask { ...@@ -314,55 +317,7 @@ public class FileProcessTask {
* 提供会议转录文件和会议主题,判断会议类型 * 提供会议转录文件和会议主题,判断会议类型
* *
* @param subject 会议主题 * @param subject 会议主题
* @return String token = "AKIAXFAXF62IWJXGLVEE.LnKInaahcMZG9zLsGMH3nTLOw3S3lK5Vcu0+ifnO"; * @return
* String apiAddr = llmApiAddr + "/llm/sse-invoke";
* String model = "arn:aws:bedrock:us-east-1:491822380689:inference-profile/us.anthropic.claude-3-7-sonnet-20250219-v1:0";
* int maxTokens = 5000;
* // String prompt = "请先对以下会议转写记录进行简要总结(不超过200字),然后根据会议主题以及总结内容判断该会议最可能属于哪种类型:\\n\\n会议主题: {0}\\n会议转写记录: {1}\\n\\n第一步:请简要总结会议的主要内容和目的(不超过200字)。\\n\\n第二步:根据上述总结和会议主题,将会议分类为以下类型之一:\\n1. 项目沟通会 - 与具体项目进展、问题讨论相关的会议\\n2. 重要会议 - 高层决策、战略规划等重要会议\\n3. 启动会 - 项目启动、活动筹备等初始会议\\n4. 其他 - 不符合以上任何分类\\n\\n分类权重判断规则:\\n- 基础权重分配:会议内容总结(70%)、会议主题(30%)\\n- 会议主题权重动态调整:\\n * 如果会议主题包含明确分类关键词(如\\\"启动会\\\"、\\\"项目沟通\\\"、\\\"战略决策\\\"等),则会议主题权重提升至60%,总结内容权重调整为40%\\n * 如果会议主题过于简单或模糊(如仅包含\\\"沟通\\\"、\\\"讨论\\\"、\\\"会议\\\"等通用词),则会议主题权重降低至15%,总结内容权重提升至85%\\n- 一致性判断:如果会议主题和总结内容指向不同分类,优先采用内容总结的分类,除非会议主题非常明确且规范\\n\\n输出格式:\\n请只返回分类名称(如\\\"项目沟通会\\\"),不要包含其他内容(如生成的会议总结等)。";
* String prompt = "## 角色定义\n" +
* "你是一位会议分类师,擅长对各种类型会议进行分类。\n" +
* "\n" +
* "请对以下会议转写记录进行全面而精炼的总结(尽量控制在500字以内,字数可以根据会议转写记录长度适当进行调整),然后根据会议主题以及总结内容判断该会议属于的类型:\n" +
* "\n" +
* "会议主题: {subject}\n" +
* "会议转写记录: {transcript}\n" +
* "\n" +
* "识别会议类型步骤如下:\n" +
* "第一步:识别会议名称/标题(如:项目例会,数据问题讨论);如果识别不出来,标注“暂无”;\n" +
* "第二步:根据识别出来的会议名称进行分类(如:数据问题讨论,讨论会)。如果会议名称如:快速会议,张三预定的会议,分类为“其他”。如果是暂无,则进入第三步:\n" +
* "第三步:总结会议的主要内容和目的(尽量控制在500字以内,字数可以根据会议转写记录长度适当进行调整)。确保涵盖所有关键讨论内容、重要决策和行动项,捕捉所有实质性内容。摘要应当完整反映会议的核心目的,不遗漏重要信息。\n" +
* "\n" +
* "第三步:根据上述内容和目的总结,将会议分类为以下类型之一:\n" +
* "1. 项目例会 - 会议有周期标签。要讨论很多件事情,每件事情讨论时间很短。\n" +
* "2. 启动会 - 项目启动、活动筹备等初始会议,各方代表发言。\n" +
* "3. 讨论会 - 只针对一到两个事件针对性讨论,可能是讨论方案。\n" +
* "4. 其他 - 不符合上面任意一类。\n" +
* "\n" +
* "\n" +
* "输出格式:\n" +
* "{{\n" +
* " \"classification\": 类型\n" +
* "}}\n" +
* "\n" +
* "注意:\n" +
* "1.请严格按照输出格式以JSON格式返回数据,所有字段都必须包含。\n" +
* "2.输出必须是严格有效的JSON格式,可以直接被解析。不要带有json标记,不要包含其他内容。";
* //占位符信息替换
* String formatPrompt = formatMessage(prompt, subject, transcript);
* List<Message> messages = new ArrayList<>();
* ChatMessage chatMessage = new ChatMessage(ChatMessageRole.USER.value(), formatPrompt);
* messages.add(chatMessage);
* <p>
* // 调用Claude API处理文件
* String response = call_llm(apiAddr, model, token, messages, maxTokens);
* JSONObject object = JSONObject.parseObject(response);
* String retStr = "通用会议";
* if (object != null) {
* String classification = object.getString("classification");
* if (StrUtil.isNotBlank(classification)) {
* retStr = classification;
* }
* }
*/ */
private Long choiceTemplateType(String subject) { private Long choiceTemplateType(String subject) {
Long type = 1L; Long type = 1L;
...@@ -397,30 +352,10 @@ public class FileProcessTask { ...@@ -397,30 +352,10 @@ public class FileProcessTask {
* @return * @return
*/ */
private String processWithClaude(String textContent, String meetingDate, String participantNames, String prompt) { private String processWithClaude(String textContent, String meetingDate, String participantNames, String prompt) {
// //将文件传送给大模型处理 LLMConfig baseLLM = new LLMConfig(llmModel,
// String token = "AKIAXFAXF62IWJXGLVEE.LnKInaahcMZG9zLsGMH3nTLOw3S3lK5Vcu0+ifnO"; llmApiAddr,
// String apiAddr = llmApiAddr + "/llm/sse-invoke"; "Bearer " + llmToken,
// String model = "anthropic.claude-3-5-sonnet-20240620-v1:0"; llmMaxTokens);
// int maxTokens = 5000;
// List<Message> messages = new ArrayList<>();
//
// ChatMessage chatMessage = new ChatMessage(ChatMessageRole.USER.value(), prompt.replaceAll("\\{transcript\\}",textContent).replaceAll("\\{meetingDate\\}",meetingDate));
// messages.add(chatMessage);
//// chatMessage = new ChatMessage(ChatMessageRole.ASSISTANT.value(), "好的请提供会议记录");
//// messages.add(chatMessage);
//// chatMessage = new ChatMessage(ChatMessageRole.USER.value(), textContent);
//
// messages.add(chatMessage);
//
// // 调用Claude API处理文件
// String ret = call_llm(apiAddr, model, token, messages, maxTokens);
// String model = "arn:aws:bedrock:us-east-1:491822380689:inference-profile/us.anthropic.claude-3-7-sonnet-20250219-v1:0";
String model = "arn:aws:bedrock:us-east-1:491822380689:inference-profile/us.anthropic.claude-3-7-sonnet-20250219-v1:0";
LLMConfig baseLLM = new LLMConfig(model,
llmApiAddr + "/llm/sse-invoke",
"Bearer AKIAXFAXF62IWJXGLVEE.LnKInaahcMZG9zLsGMH3nTLOw3S3lK5Vcu0+ifnO",
20000);
LLMResult llmResult = MeetingProcess.processMeeting(prompt, textContent, meetingDate, participantNames, baseLLM, new ArrayList<>()); LLMResult llmResult = MeetingProcess.processMeeting(prompt, textContent, meetingDate, participantNames, baseLLM, new ArrayList<>());
// DebugOutputTool.println(llmResult.respond); // DebugOutputTool.println(llmResult.respond);
return llmResult.respond; return llmResult.respond;
...@@ -664,7 +599,7 @@ public class FileProcessTask { ...@@ -664,7 +599,7 @@ public class FileProcessTask {
public FileProcessTask(List<String> recordFileIdList, String meetingId, String subMeetingId, String savePath, Map<String, Object> metadata, public FileProcessTask(List<String> recordFileIdList, String meetingId, String subMeetingId, String savePath, Map<String, Object> metadata,
MeetingInfoMapper meetingInfoMapper, MinioUtils minioUtils, RedisUtils redisUtils, EmailSender emailSender, MeetingInfoMapper meetingInfoMapper, MinioUtils minioUtils, RedisUtils redisUtils, EmailSender emailSender,
MeetingRecordTemplateMapper meetingRecordTemplateMapper, MeetingRecordTemplateService meetingRecordTemplateService, MeetTypeService meetTypeService, UserIdMapper userIdMapper, MeetingRecordTemplateMapper meetingRecordTemplateMapper, MeetingRecordTemplateService meetingRecordTemplateService, MeetTypeService meetTypeService, UserIdMapper userIdMapper,
String llmApiAddr, Boolean finalRetry, ProcessLogService processLogService, List<UserDTO.TemplateAuthorizedUserDTO> authorizedUsers, Map<String, String> tidWidRelations, String llmApiAddr, String llmModel, String llmToken, Integer llmMaxTokens, Boolean finalRetry, ProcessLogService processLogService, List<UserDTO.TemplateAuthorizedUserDTO> authorizedUsers, Map<String, String> tidWidRelations,
UserAdminConfig userAdminConfig, String applicationId, String fileDownloadPath, String permTenantId, UserAdminConfig userAdminConfig, String applicationId, String fileDownloadPath, String permTenantId,
String aesKey) { String aesKey) {
this.recordFileIdList = recordFileIdList; this.recordFileIdList = recordFileIdList;
...@@ -681,6 +616,9 @@ public class FileProcessTask { ...@@ -681,6 +616,9 @@ public class FileProcessTask {
this.meetTypeService = meetTypeService; this.meetTypeService = meetTypeService;
this.userIdMapper = userIdMapper; this.userIdMapper = userIdMapper;
this.llmApiAddr = llmApiAddr; this.llmApiAddr = llmApiAddr;
this.llmModel = llmModel;
this.llmToken = llmToken;
this.llmMaxTokens = llmMaxTokens;
this.finalRetry = finalRetry; this.finalRetry = finalRetry;
this.processLogService = processLogService; this.processLogService = processLogService;
this.authorizedUsers = authorizedUsers; this.authorizedUsers = authorizedUsers;
......
...@@ -40,6 +40,12 @@ public class FileProcessProducer { ...@@ -40,6 +40,12 @@ public class FileProcessProducer {
private FileProcessCallbackHandler callbackHandler; private FileProcessCallbackHandler callbackHandler;
@Value(value = "${llm.api-addr}") @Value(value = "${llm.api-addr}")
private String llmApiAddr; private String llmApiAddr;
@Value(value = "${llm.api-model}")
private String llmModel;
@Value(value = "${llm.api-token}")
private String llmToken;
@Value(value = "${llm.api-max-tokens}")
private Integer llmMaxTokens;
@Value(value = "${tencent.base-save-path}") @Value(value = "${tencent.base-save-path}")
private String baseSavePath; private String baseSavePath;
@Value("${permission.applicationId}") @Value("${permission.applicationId}")
...@@ -99,6 +105,9 @@ public class FileProcessProducer { ...@@ -99,6 +105,9 @@ public class FileProcessProducer {
meetTypeService, meetTypeService,
userIdMapper, userIdMapper,
llmApiAddr, llmApiAddr,
llmModel,
llmToken,
llmMaxTokens,
finalRetry, finalRetry,
processLogService, processLogService,
authorizedUsers, authorizedUsers,
......
...@@ -84,6 +84,12 @@ public class MeetingInfoServiceImpl extends ServiceImpl<MeetingInfoMapper, Meeti ...@@ -84,6 +84,12 @@ public class MeetingInfoServiceImpl extends ServiceImpl<MeetingInfoMapper, Meeti
private MinioUtils minioUtils; private MinioUtils minioUtils;
@Value(value = "${llm.api-addr}") @Value(value = "${llm.api-addr}")
private String llmApiAddr; private String llmApiAddr;
@Value(value = "${llm.api-model}")
private String llmModel;
@Value(value = "${llm.api-token}")
private String llmToken;
@Value(value = "${llm.api-max-tokens}")
private Integer llmMaxTokens;
@Value("${permission.tenantId}") @Value("${permission.tenantId}")
public String permissionTenantId; public String permissionTenantId;
@Resource @Resource
...@@ -466,17 +472,14 @@ public class MeetingInfoServiceImpl extends ServiceImpl<MeetingInfoMapper, Meeti ...@@ -466,17 +472,14 @@ public class MeetingInfoServiceImpl extends ServiceImpl<MeetingInfoMapper, Meeti
*/ */
private String processWithClaude(String textContent, String meetingDate, String prompt,String meetingId, String subMeetingId) { private String processWithClaude(String textContent, String meetingDate, String prompt,String meetingId, String subMeetingId) {
//将文件传送给大模型处理 //将文件传送给大模型处理
String token = "AKIAXFAXF62IWJXGLVEE.LnKInaahcMZG9zLsGMH3nTLOw3S3lK5Vcu0+ifnO"; String token = llmToken;
String apiAddr = llmApiAddr + "/llm/sse-invoke"; String apiAddr = llmApiAddr;
String model = "arn:aws:bedrock:us-east-1:491822380689:inference-profile/us.anthropic.claude-3-7-sonnet-20250219-v1:0"; String model = llmModel;
int maxTokens = 5000; int maxTokens = llmMaxTokens;
List<Message> messages = new ArrayList<>(); List<Message> messages = new ArrayList<>();
ChatMessage chatMessage = new ChatMessage(ChatMessageRole.USER.value(), prompt.replaceAll("\\{transcript\\}",textContent).replaceAll("\\{meetingDate\\}",meetingDate)); ChatMessage chatMessage = new ChatMessage(ChatMessageRole.USER.value(), prompt.replaceAll("\\{transcript\\}",textContent).replaceAll("\\{meetingDate\\}",meetingDate));
messages.add(chatMessage); messages.add(chatMessage);
// chatMessage = new ChatMessage(ChatMessageRole.ASSISTANT.value(), "好的请提供会议记录");
// messages.add(chatMessage);
// chatMessage = new ChatMessage(ChatMessageRole.USER.value(), textContent);
messages.add(chatMessage); messages.add(chatMessage);
......
...@@ -66,8 +66,12 @@ public class RecordTemplatePermissionServiceImpl extends ServiceImpl<RecordTempl ...@@ -66,8 +66,12 @@ public class RecordTemplatePermissionServiceImpl extends ServiceImpl<RecordTempl
private MinioUtils minioUtils; private MinioUtils minioUtils;
@Value(value = "${llm.api-addr}") @Value(value = "${llm.api-addr}")
private String llmApiAddr; private String llmApiAddr;
@Value(value = "${llm.api-model}")
private String llmModel;
@Value(value = "${llm.api-token}") @Value(value = "${llm.api-token}")
private String llmApiToken; private String llmToken;
@Value(value = "${llm.api-max-tokens}")
private Integer llmMaxTokens;
@Value("${aec.key}") @Value("${aec.key}")
public String aesKey; public String aesKey;
...@@ -186,11 +190,10 @@ public class RecordTemplatePermissionServiceImpl extends ServiceImpl<RecordTempl ...@@ -186,11 +190,10 @@ public class RecordTemplatePermissionServiceImpl extends ServiceImpl<RecordTempl
} }
} }
String model = "arn:aws:bedrock:us-east-1:491822380689:inference-profile/us.anthropic.claude-3-7-sonnet-20250219-v1:0"; LLMConfig baseLLM = new LLMConfig(llmModel,
LLMConfig baseLLM = new LLMConfig(model, llmApiAddr,
llmApiAddr + "/llm/sse-invoke", "Bearer " + llmToken,
"Bearer " + llmApiToken, llmMaxTokens);
20000);
LLMResult llmResult = MeetingProcess.processMeeting(prompt, textContent, meetingDate, participantNames, baseLLM, new ArrayList<>()); LLMResult llmResult = MeetingProcess.processMeeting(prompt, textContent, meetingDate, participantNames, baseLLM, new ArrayList<>());
DebugOutputTool.println(llmResult.respond); DebugOutputTool.println(llmResult.respond);
......
...@@ -13,8 +13,10 @@ REDIS_PASS: standard123 ...@@ -13,8 +13,10 @@ REDIS_PASS: standard123
REDIS_DATABASE: 3 REDIS_DATABASE: 3
############################################################## llm ############################################################## llm
# local # local
LLM_API_ADDR: https://bedrock.chatbot.cn LLM_API_ADDR: https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions
LLM_API_TOKEN: AKIAXFAXF62IWJXGLVEE.LnKInaahcMZG9zLsGMH3nTLOw3S3lK5Vcu0+ifnO LLM_API_MODEL: qwen-plus
LLM_API_TOKEN: sk-58046ac63cae4317b65fb151965169d1
LLM_API_MAX_TOKENS: 16000
# prod # prod
TENCENT_APPID: 210468336 TENCENT_APPID: 210468336
...@@ -114,7 +116,9 @@ email: ...@@ -114,7 +116,9 @@ email:
llm: llm:
api-addr: ${LLM_API_ADDR} api-addr: ${LLM_API_ADDR}
api-model: ${LLM_API_MODEL}
api-token: ${LLM_API_TOKEN} api-token: ${LLM_API_TOKEN}
api-max-tokens: ${LLM_API_MAX_TOKENS}
#解密key #解密key
aec: aec:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论