Package com.embabel.agent.test.unit
Class FakeOperationContext
-
- All Implemented Interfaces:
-
com.embabel.agent.api.common.OperationContext,com.embabel.agent.core.Bindable,com.embabel.agent.core.Blackboard,com.embabel.agent.core.MayHaveLastResult,com.embabel.agent.core.ToolGroupConsumer,com.embabel.common.core.types.HasInfoString
public final class FakeOperationContext implements OperationContext, Blackboard
Pass into unit tests. Principally used to obtain a PromptRunner for testing purposes.
-
-
Field Summary
Fields Modifier and Type Field Description private final FakePromptRunnerpromptRunnerprivate final List<LlmInvocation>llmInvocationsprivate final Agentagentprivate final ProcessContextprocessContextprivate final Operationoperationprivate final Set<ToolGroupRequirement>toolGroupsprivate final AgentProcessagentProcessprivate final StringblackboardIdprivate final List<Object>objects
-
Constructor Summary
Constructors Constructor Description FakeOperationContext(Agent agent, ProcessContext processContext, Operation operation, Set<ToolGroupRequirement> toolGroups)
-
Method Summary
Modifier and Type Method Description final FakePromptRunnergetPromptRunner()final List<LlmInvocation>getLlmInvocations()final AgentgetAgent()ProcessContextgetProcessContext()OperationgetOperation()Action or operation that is being executed. Set<ToolGroupRequirement>getToolGroups()Tool groups exposed. final UnitexpectResponse(Object response)Add a response to the list of expected responses. PromptRunnerpromptRunner(LlmOptions llm, Set<ToolGroupRequirement> toolGroups, List<ToolObject> toolObjects, List<PromptContributor> promptContributors, List<ContextualPromptElement> contextualPromptContributors, Boolean generateExamples)Create a prompt runner for this context. final static FakeOperationContextcreate(Agent agent, ProcessContext processContext, Operation operation, Set<ToolGroupRequirement> toolGroups)final static FakeOperationContextcreate(Agent agent, ProcessContext processContext, Operation operation)final static FakeOperationContextcreate(Agent agent, ProcessContext processContext)final static FakeOperationContextcreate(Agent agent)final static FakeOperationContextcreate()-
Methods inherited from class com.embabel.agent.api.common.OperationContext
agentPlatform, ai, fireAgent, getAgentProcess, parallelMap, promptRunner, user -
Methods inherited from class com.embabel.agent.core.Blackboard
clear, count, expressionEvaluationModel, get, getBlackboardId, getCondition, getObjects, getOrPut, getValue, hasValue, hide, last, lastResult, objectsOfType, setCondition, spawn -
Methods inherited from class com.embabel.agent.core.Bindable
addAll, addObject, bind, bindAll, bindProtected, plusAssign, plusAssign, plusAssign, set -
Methods inherited from class com.embabel.common.core.types.HasInfoString
infoString -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
FakeOperationContext
FakeOperationContext(Agent agent, ProcessContext processContext, Operation operation, Set<ToolGroupRequirement> toolGroups)
-
-
Method Detail
-
getPromptRunner
final FakePromptRunner getPromptRunner()
-
getLlmInvocations
final List<LlmInvocation> getLlmInvocations()
-
getProcessContext
ProcessContext getProcessContext()
-
getOperation
Operation getOperation()
Action or operation that is being executed.
-
getToolGroups
Set<ToolGroupRequirement> getToolGroups()
Tool groups exposed. This will include directly registered tool groups and tool groups resolved from ToolGroups.
-
expectResponse
final Unit expectResponse(Object response)
Add a response to the list of expected responses. This is used to simulate responses from the LLM.
-
promptRunner
PromptRunner promptRunner(LlmOptions llm, Set<ToolGroupRequirement> toolGroups, List<ToolObject> toolObjects, List<PromptContributor> promptContributors, List<ContextualPromptElement> contextualPromptContributors, Boolean generateExamples)
Create a prompt runner for this context. Application code should always go through this method to run LLM operations.
- Parameters:
llm- the LLM options to usetoolGroups- extra local tool groups to use, in addition to those declared on the action if we're in an actionpromptContributors- extra prompt contributors to use, in addition to those declared on the action if we're in an action, or at agent level
-
create
@JvmOverloads() final static FakeOperationContext create(Agent agent, ProcessContext processContext, Operation operation, Set<ToolGroupRequirement> toolGroups)
-
create
@JvmOverloads() final static FakeOperationContext create(Agent agent, ProcessContext processContext, Operation operation)
-
create
@JvmOverloads() final static FakeOperationContext create(Agent agent, ProcessContext processContext)
-
create
@JvmOverloads() final static FakeOperationContext create(Agent agent)
-
create
@JvmOverloads() final static FakeOperationContext create()
-
-
-
-