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
|
||||
|
||||
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.runtime.config.AgentConfigManager
|
||||
import work.slhaf.partner.api.agent.runtime.interaction.flow.entity.RunningFlowContext
|
||||
@@ -11,26 +12,23 @@ import work.slhaf.partner.api.chat.pojo.Message
|
||||
/**
|
||||
* 模块基类
|
||||
*/
|
||||
@CapabilityHolder
|
||||
abstract class AbstractAgentModule {
|
||||
var moduleName: String = javaClass.simpleName
|
||||
|
||||
interface Running<T : RunningFlowContext> {
|
||||
fun execute(context: T)
|
||||
}
|
||||
|
||||
interface Sub<I, O> {
|
||||
fun execute(input: I): O
|
||||
}
|
||||
|
||||
interface Standalone
|
||||
|
||||
// TODO 后续于此处扩展生命周期内容
|
||||
}
|
||||
|
||||
data class Model(
|
||||
val chatClient: ChatClient,
|
||||
val chatMessages: MutableList<Message> = mutableListOf(),
|
||||
val baseMessages: MutableList<Message> = mutableListOf()
|
||||
)
|
||||
|
||||
interface RunningModule<T : RunningFlowContext> {
|
||||
fun execute(context: T)
|
||||
}
|
||||
|
||||
interface SubModule<I, O> {
|
||||
fun execute(input: I): O
|
||||
}
|
||||
|
||||
interface StandaloneModule
|
||||
|
||||
interface ActivateModel {
|
||||
|
||||
companion object {
|
||||
@@ -94,12 +92,17 @@ interface ActivateModel {
|
||||
}
|
||||
|
||||
/**
|
||||
* 对应调用的模型配置名称,默认配合[AbstractAgentModule.moduleName]使用
|
||||
* 对应调用的模型配置名称
|
||||
*/
|
||||
fun modelKey(): String {
|
||||
return (this as AbstractAgentModule).moduleName
|
||||
return javaClass.simpleName
|
||||
}
|
||||
|
||||
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.lang.reflect.InvocationTargetException;
|
||||
|
||||
public class AbstractAgentRunningModuleProxyTest {
|
||||
public class AbstractAgentRunningProxyTest {
|
||||
@Test
|
||||
public void test() throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException, IOException, ClassNotFoundException {
|
||||
Class<? extends AbstractAgentRunningModule> clazz = new ByteBuddy().subclass(MyAbstractAgentRunningAbstractAgentModule.class)
|
||||
@@ -18,7 +18,7 @@ public class AbstractAgentRunningModuleProxyTest {
|
||||
new MyModuleProxyInterceptor()
|
||||
))
|
||||
.make()
|
||||
.load(AbstractAgentRunningModuleProxyTest.class.getClassLoader())
|
||||
.load(AbstractAgentRunningProxyTest.class.getClassLoader())
|
||||
.getLoaded();
|
||||
clazz.getConstructor().newInstance().execute(null);
|
||||
}
|
||||
Reference in New Issue
Block a user