mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 16:53:04 +08:00
refactor(module): rename CoreModel into CommunicationProducer
This commit is contained in:
@@ -27,7 +27,7 @@ import static work.slhaf.partner.common.util.ExtractUtil.extractJson;
|
|||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
public class CoreModel extends AbstractAgentModule.Running<PartnerRunningFlowContext> implements ActivateModel {
|
public class CommunicationProducer extends AbstractAgentModule.Running<PartnerRunningFlowContext> implements ActivateModel {
|
||||||
|
|
||||||
@InjectCapability
|
@InjectCapability
|
||||||
private CognationCapability cognationCapability;
|
private CognationCapability cognationCapability;
|
||||||
@@ -39,7 +39,7 @@ public class CoreModel extends AbstractAgentModule.Running<PartnerRunningFlowCon
|
|||||||
this.getModel().getChatMessages().addAll(chatMessages);
|
this.getModel().getChatMessages().addAll(chatMessages);
|
||||||
|
|
||||||
updateChatClientSettings();
|
updateChatClientSettings();
|
||||||
log.info("[CoreModel] CoreModel注册完毕...");
|
log.info("CommunicationProducer 注册完毕...");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -51,7 +51,7 @@ public class CoreModel extends AbstractAgentModule.Running<PartnerRunningFlowCon
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String modelKey() {
|
public @NotNull String modelKey() {
|
||||||
return "core_model";
|
return "communication_producer";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -62,10 +62,10 @@ public class CoreModel extends AbstractAgentModule.Running<PartnerRunningFlowCon
|
|||||||
@Override
|
@Override
|
||||||
public void execute(PartnerRunningFlowContext runningFlowContext) {
|
public void execute(PartnerRunningFlowContext runningFlowContext) {
|
||||||
String userId = runningFlowContext.getSource();
|
String userId = runningFlowContext.getSource();
|
||||||
log.debug("[CoreModel] 主对话流程开始: {}", userId);
|
log.debug("[CommunicationProducer] 主对话流程开始: {}", userId);
|
||||||
beforeChat(runningFlowContext);
|
beforeChat(runningFlowContext);
|
||||||
executeChat(runningFlowContext);
|
executeChat(runningFlowContext);
|
||||||
log.debug("[CoreModel] 主对话流程({})结束...", userId);
|
log.debug("[CommunicationProducer] 主对话流程({})结束...", userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void beforeChat(PartnerRunningFlowContext runningFlowContext) {
|
private void beforeChat(PartnerRunningFlowContext runningFlowContext) {
|
||||||
@@ -73,8 +73,8 @@ public class CoreModel extends AbstractAgentModule.Running<PartnerRunningFlowCon
|
|||||||
activateModule(runningFlowContext);
|
activateModule(runningFlowContext);
|
||||||
setMessageCount(runningFlowContext);
|
setMessageCount(runningFlowContext);
|
||||||
|
|
||||||
log.debug("[CoreModel] 当前消息列表大小: {}", getModel().getChatMessages().size());
|
log.debug("[CommunicationProducer] 当前消息列表大小: {}", getModel().getChatMessages().size());
|
||||||
log.debug("[CoreModel] 当前核心prompt内容: {}", runningFlowContext.getCoreContext().toString());
|
log.debug("[CommunicationProducer] 当前核心prompt内容: {}", runningFlowContext.getCoreContext().toString());
|
||||||
|
|
||||||
setMessage(runningFlowContext.getCoreContext().toString());
|
setMessage(runningFlowContext.getCoreContext().toString());
|
||||||
}
|
}
|
||||||
@@ -100,12 +100,12 @@ public class CoreModel extends AbstractAgentModule.Running<PartnerRunningFlowCon
|
|||||||
log.warn("主模型回复格式出错, 将直接作为消息返回, 建议尝试更换主模型...");
|
log.warn("主模型回复格式出错, 将直接作为消息返回, 建议尝试更换主模型...");
|
||||||
handleExceptionResponse(response, chatResponse.getMessage());
|
handleExceptionResponse(response, chatResponse.getMessage());
|
||||||
}
|
}
|
||||||
log.debug("[CoreModel] CoreModel 响应内容: {}", response);
|
log.debug("[CommunicationProducer] CommunicationProducer 响应内容: {}", response);
|
||||||
updateModuleContextAndChatMessages(runningFlowContext, response.getString("text"), chatResponse);
|
updateModuleContextAndChatMessages(runningFlowContext, response.getString("text"), chatResponse);
|
||||||
break;
|
break;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
count++;
|
count++;
|
||||||
log.error("[CoreModel] CoreModel执行异常: {}", e.getLocalizedMessage());
|
log.error("[CommunicationProducer] CoreModel执行异常: {}", e.getLocalizedMessage());
|
||||||
if (count > 3) {
|
if (count > 3) {
|
||||||
handleExceptionResponse(response, "主模型交互出错: " + e.getLocalizedMessage());
|
handleExceptionResponse(response, "主模型交互出错: " + e.getLocalizedMessage());
|
||||||
getModel().getChatMessages().removeLast();
|
getModel().getChatMessages().removeLast();
|
||||||
@@ -114,7 +114,7 @@ public class CoreModel extends AbstractAgentModule.Running<PartnerRunningFlowCon
|
|||||||
} finally {
|
} finally {
|
||||||
updateCoreResponse(runningFlowContext, response);
|
updateCoreResponse(runningFlowContext, response);
|
||||||
resetAppendedMessages();
|
resetAppendedMessages();
|
||||||
log.debug("[CoreModel] 消息列表更新大小: {}", getModel().getChatMessages().size());
|
log.debug("[CommunicationProducer] 消息列表更新大小: {}", getModel().getChatMessages().size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user