mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 16:53:04 +08:00
refactor(framework): mark AbstractAgentModule as capability holder and consolidate module contracts within abstracts
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package work.slhaf.partner.api.agent.factory.module.abstracts
|
package work.slhaf.partner.api.agent.factory.module.abstracts
|
||||||
|
|
||||||
|
import work.slhaf.partner.api.agent.factory.capability.annotation.CapabilityHolder
|
||||||
import work.slhaf.partner.api.agent.factory.module.annotation.Init
|
import work.slhaf.partner.api.agent.factory.module.annotation.Init
|
||||||
import work.slhaf.partner.api.agent.runtime.config.AgentConfigManager
|
import work.slhaf.partner.api.agent.runtime.config.AgentConfigManager
|
||||||
import work.slhaf.partner.api.agent.runtime.interaction.flow.entity.RunningFlowContext
|
import work.slhaf.partner.api.agent.runtime.interaction.flow.entity.RunningFlowContext
|
||||||
@@ -11,25 +12,22 @@ import work.slhaf.partner.api.chat.pojo.Message
|
|||||||
/**
|
/**
|
||||||
* 模块基类
|
* 模块基类
|
||||||
*/
|
*/
|
||||||
|
@CapabilityHolder
|
||||||
abstract class AbstractAgentModule {
|
abstract class AbstractAgentModule {
|
||||||
var moduleName: String = javaClass.simpleName
|
var moduleName: String = javaClass.simpleName
|
||||||
}
|
|
||||||
|
|
||||||
data class Model(
|
interface Running<T : RunningFlowContext> {
|
||||||
val chatClient: ChatClient,
|
|
||||||
val chatMessages: MutableList<Message> = mutableListOf(),
|
|
||||||
val baseMessages: MutableList<Message> = mutableListOf()
|
|
||||||
)
|
|
||||||
|
|
||||||
interface RunningModule<T : RunningFlowContext> {
|
|
||||||
fun execute(context: T)
|
fun execute(context: T)
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SubModule<I, O> {
|
interface Sub<I, O> {
|
||||||
fun execute(input: I): O
|
fun execute(input: I): O
|
||||||
}
|
}
|
||||||
|
|
||||||
interface StandaloneModule
|
interface Standalone
|
||||||
|
|
||||||
|
// TODO 后续于此处扩展生命周期内容
|
||||||
|
}
|
||||||
|
|
||||||
interface ActivateModel {
|
interface ActivateModel {
|
||||||
|
|
||||||
@@ -94,12 +92,17 @@ interface ActivateModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对应调用的模型配置名称,默认配合[AbstractAgentModule.moduleName]使用
|
* 对应调用的模型配置名称
|
||||||
*/
|
*/
|
||||||
fun modelKey(): String {
|
fun modelKey(): String {
|
||||||
return (this as AbstractAgentModule).moduleName
|
return javaClass.simpleName
|
||||||
}
|
}
|
||||||
|
|
||||||
fun withBasicPrompt(): Boolean
|
fun withBasicPrompt(): Boolean
|
||||||
|
|
||||||
|
data class Model(
|
||||||
|
val chatClient: ChatClient,
|
||||||
|
val chatMessages: MutableList<Message> = mutableListOf(),
|
||||||
|
val baseMessages: MutableList<Message> = mutableListOf()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import work.slhaf.partner.api.agent.factory.module.abstracts.AbstractAgentRunnin
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
public class AbstractAgentRunningModuleProxyTest {
|
public class AbstractAgentRunningProxyTest {
|
||||||
@Test
|
@Test
|
||||||
public void test() throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException, IOException, ClassNotFoundException {
|
public void test() throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException, IOException, ClassNotFoundException {
|
||||||
Class<? extends AbstractAgentRunningModule> clazz = new ByteBuddy().subclass(MyAbstractAgentRunningAbstractAgentModule.class)
|
Class<? extends AbstractAgentRunningModule> clazz = new ByteBuddy().subclass(MyAbstractAgentRunningAbstractAgentModule.class)
|
||||||
@@ -18,7 +18,7 @@ public class AbstractAgentRunningModuleProxyTest {
|
|||||||
new MyModuleProxyInterceptor()
|
new MyModuleProxyInterceptor()
|
||||||
))
|
))
|
||||||
.make()
|
.make()
|
||||||
.load(AbstractAgentRunningModuleProxyTest.class.getClassLoader())
|
.load(AbstractAgentRunningProxyTest.class.getClassLoader())
|
||||||
.getLoaded();
|
.getLoaded();
|
||||||
clazz.getConstructor().newInstance().execute(null);
|
clazz.getConstructor().newInstance().execute(null);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user