mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 08:43:02 +08:00
进行 框架-主题 的适配测试,发现了一些问题并进行了修复
框架: - 去除了 ActivateModel 中 modelKey() 方法的默认实现,对于特殊的 AgentModule 继承者(CoreModule)而言,直接获取注解信息不可行,如果保持,则需要另加判断逻辑。这是没有必要的 - 发现 Agent 启动流程中,由于 Gateway 的启动可能依赖配置文件的加载,故将 AgentConfigManager 与 AgentGateway 的指定替换为类型指定,在合适的时机通过反射进行实例化 - 在 AgentUtil 中新增了链式判断指定类的注解链上是否存在指定注解的方法,目前用于 CapabilityHolder 的持有实例判定 - 发现 CapabilityFactoryContext 中 cores、capabilities 未赋值导致空指针异常,已修复 - 将 AgentConfigManager 中的检验逻辑进行抽离,放到了 ConfigLoaderFactory 中,避免职责混淆 - 发现 CoreModule 的注解使用错误,`@Retention(RetentionPolicy.RUNTIME)`元注解可以使得注解在代码运行时能够被反射扫描 - 在 ModuleCheckFactory 中添加了对于 Module 与 SubModule 的注解、继承使用是否匹配的检验 - 发现对于一个类来说,无法直接通过一层反射获取到‘注解的注解’,故在 ModuleRegisterFactory 中针对 CoreModule 的注册做了特殊处理 主体: - 发现一些类缺少必要注解,已修复 - 发现存在有些必要的类未公开化无参构造函数,已修复,并在框架部分增加校验逻辑 其他: - 由于项目的启动流程与完整的配置文件密不可分,所以开始尝试编写启动说明,目前只写了开头
This commit is contained in:
@@ -8,9 +8,9 @@ import work.slhaf.partner.runtime.interaction.WebSocketGateway;
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Agent.newAgent(Main.class)
|
||||
.setGateway(WebSocketGateway.initialize())
|
||||
.setAgentConfigManager(new PartnerAgentConfigManager())
|
||||
.setAgentExceptionCallback(new PartnerExceptionCallback())
|
||||
.setAgentConfigManager(PartnerAgentConfigManager.class)
|
||||
.setGateway(WebSocketGateway.class)
|
||||
.setAgentExceptionCallback(PartnerExceptionCallback.class)
|
||||
.launch();
|
||||
}
|
||||
}
|
||||
@@ -44,10 +44,6 @@ public class CoordinatedManager implements Serializable {
|
||||
private PerceiveCore perceiveCore;
|
||||
private DispatchCore dispatchCore;
|
||||
|
||||
private CoordinatedManager() {
|
||||
}
|
||||
|
||||
|
||||
public static CoordinatedManager getInstance() throws IOException, ClassNotFoundException {
|
||||
if (coordinatedManager == null) {
|
||||
synchronized (CoordinatedManager.class) {
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.nio.file.StandardCopyOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@@ -185,5 +186,10 @@ public class CognationCore extends PersistableObject {
|
||||
public List<EvaluatedSlice> getActivatedSlices(String userId) {
|
||||
return activeData.getActivatedSlices().get(userId);
|
||||
}
|
||||
|
||||
@CapabilityMethod
|
||||
public Lock getMessageLock() {
|
||||
return messageLock;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,11 @@ public class CoreModel extends CoreRunningModule implements ActivateModel {
|
||||
chatClient().setTop_p(0.7);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelKey() {
|
||||
return "core_model";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean withBasicPrompt() {
|
||||
return true;
|
||||
|
||||
@@ -6,6 +6,7 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import work.slhaf.partner.api.agent.factory.capability.annotation.InjectCapability;
|
||||
import work.slhaf.partner.api.agent.factory.module.annotation.AgentSubModule;
|
||||
import work.slhaf.partner.api.agent.factory.module.annotation.Init;
|
||||
import work.slhaf.partner.api.agent.runtime.interaction.flow.abstracts.ActivateModel;
|
||||
import work.slhaf.partner.api.agent.runtime.interaction.flow.abstracts.AgentRunningSubModule;
|
||||
@@ -31,6 +32,7 @@ import static work.slhaf.partner.common.util.ExtractUtil.fixTopicPath;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Slf4j
|
||||
@AgentSubModule
|
||||
public class MemorySelectExtractor extends AgentRunningSubModule<PartnerRunningFlowContext, ExtractorResult>
|
||||
implements ActivateModel {
|
||||
|
||||
|
||||
@@ -25,10 +25,6 @@ import static work.slhaf.partner.common.util.ExtractUtil.fixTopicPath;
|
||||
@AgentSubModule
|
||||
public class MultiSummarizer extends AgentRunningSubModule<SummarizeInput, SummarizeResult> implements ActivateModel {
|
||||
|
||||
private MultiSummarizer() {
|
||||
modelSettings();
|
||||
}
|
||||
|
||||
@Init
|
||||
public void init() {
|
||||
updateChatClientSettings();
|
||||
|
||||
@@ -32,9 +32,8 @@ public class WebSocketGateway extends WebSocketServer implements AgentGateway<Pa
|
||||
// 记录最后一次收到Pong的时间
|
||||
private final ConcurrentHashMap<WebSocket, Long> lastPongTimes = new ConcurrentHashMap<>();
|
||||
|
||||
public static WebSocketGateway initialize() {
|
||||
PartnerAgentConfigManager configManager = (PartnerAgentConfigManager) AgentConfigManager.INSTANCE;
|
||||
return new WebSocketGateway(configManager.getConfig().getPort());
|
||||
public WebSocketGateway() {
|
||||
this(((PartnerAgentConfigManager) AgentConfigManager.INSTANCE).getConfig().getPort());
|
||||
}
|
||||
|
||||
private WebSocketGateway(int port) {
|
||||
|
||||
Reference in New Issue
Block a user