Package com.embabel.agent.api.common
Interface OperationContext
-
- All Implemented Interfaces:
-
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 interface OperationContext implements Blackboard, ToolGroupConsumer
Context for any operation. Exposes blackboard and process context.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classOperationContext.Companion
-
Method Summary
Modifier and Type Method Description AgentPlatformagentPlatform()Useruser()Convenient way to get the user on whose behalf this operation is being executed, if any. <T extends Any> CompletableFuture<T>fireAgent(Object obj, Class<T> resultType)Any agents known to the present platform that can handle the given object and return the given result type. Aiai()Get AI functionality for this context PromptRunnerpromptRunner(LlmOptions llm, Set<ToolGroupRequirement> toolGroups, List<ToolObject> toolObjects, List<PromptContributor> promptContributors, List<ContextualPromptElement> contextualPromptContributors, Boolean generateExamples)Create a prompt runner for this context. PromptRunnerpromptRunner()Create a prompt runner for this context that can be customized later. <T extends Any, R extends Any> List<R>parallelMap(Collection<T> items, Integer maxConcurrency, Function1<T, R> transform)Execute the operations in parallel. abstract ProcessContextgetProcessContext()AgentProcessgetAgentProcess()abstract OperationgetOperation()Action or operation that is being executed. -
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 com.embabel.agent.core.ToolGroupConsumer
getToolGroups -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
agentPlatform
AgentPlatform agentPlatform()
-
user
User user()
Convenient way to get the user on whose behalf this operation is being executed, if any.
-
fireAgent
<T extends Any> CompletableFuture<T> fireAgent(Object obj, Class<T> resultType)
Any agents known to the present platform that can handle the given object and return the given result type. It is not an error if there are no such agents
-
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
-
promptRunner
PromptRunner promptRunner()
Create a prompt runner for this context that can be customized later. Principally for use from Java.
-
parallelMap
<T extends Any, R extends Any> List<R> parallelMap(Collection<T> items, Integer maxConcurrency, Function1<T, R> transform)
Execute the operations in parallel.
- Parameters:
items- the collection of items to processmaxConcurrency- the maximum number of concurrent operations to runtransform- the transformation function to apply to each element
-
getProcessContext
abstract ProcessContext getProcessContext()
-
getAgentProcess
AgentProcess getAgentProcess()
-
getOperation
abstract Operation getOperation()
Action or operation that is being executed.
-
-
-
-