package de.extio.lmlib.agent; import java.util.List; import java.util.function.Consumer; import java.util.function.Function; import de.extio.lmlib.agent.responsehandler.AgentResponseHandler; import de.extio.lmlib.profile.ModelCategory; import de.extio.lmlib.profile.ModelProfile; public record Agent(String name, AgentType agentType, ModelCategory modelCategory, ModelProfile modelProfile, String systemPrompt, String textTemplate, AgentResponseHandler responseHandler, Consumer preProcessor, Consumer postProcessor, Function, List> merger, Function chooseNext) implements BaseAgent { public Agent { if (name == null) { throw new IllegalArgumentException("Name cannot be null"); } if (agentType == null) { throw new IllegalArgumentException("Agent type cannot be null"); } } @Override public AgentType agentType(final AgentContext context) { if (agentType != null) { return agentType; } return BaseAgent.super.agentType(context); } @Override public ModelCategory modelCategory(final AgentContext context) { if (modelCategory != null) { return modelCategory; } return BaseAgent.super.modelCategory(context); } @Override public ModelProfile modelProfile(final AgentContext context) { if (modelProfile != null) { return modelProfile; } return BaseAgent.super.modelProfile(context); } @Override public void preProcess(final AgentContext context) { if (preProcessor != null) { preProcessor.accept(context); } BaseAgent.super.preProcess(context); } @Override public void postProcess(final AgentContext context) { if (postProcessor != null) { postProcessor.accept(context); } BaseAgent.super.postProcess(context); } @Override public List merge(final List contexts) { if (merger != null) { return merger.apply(contexts); } return BaseAgent.super.merge(contexts); } @Override public AgentNext chooseNextAgent(final AgentContext context) { if (chooseNext != null) { return chooseNext.apply(context); } return BaseAgent.super.chooseNextAgent(context); } }