Class AgentInvocationContextBuilderImpl
java.lang.Object
com.flowable.agent.engine.impl.cmd.AbstractNeedsAgentDefinitionCmd
com.flowable.agent.engine.impl.cmd.AbstractNeedsKnowledgeBaseDefinitionCmd
com.flowable.agent.engine.impl.runtime.invocation.AgentInvocationContextBuilderImpl
- All Implemented Interfaces:
AgentInvocationContextBuilder
public class AgentInvocationContextBuilderImpl
extends AbstractNeedsKnowledgeBaseDefinitionCmd
implements AgentInvocationContextBuilder
- Author:
- Filip Hrisafov
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final recordprotected static final record -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AgentDefinitionprotected AgentDefinitionModelprotected final AgentEngineConfigurationprotected AgentInstanceprotected Stringprotected final org.flowable.common.engine.impl.interceptor.CommandContextprotected Stringprotected List<org.flowable.content.api.ContentItem> protected booleanprotected Stringprotected booleanprotected org.apache.tika.config.TikaConfigstatic final Stringstatic final Stringprotected Stringprotected Collection<String> protected String -
Constructor Summary
ConstructorsConstructorDescriptionAgentInvocationContextBuilderImpl(AgentEngineConfiguration agentEngineConfiguration, org.flowable.common.engine.impl.interceptor.CommandContext commandContext) -
Method Summary
Modifier and TypeMethodDescriptionagentDefinition(AgentDefinition agentDefinition) The agent definition to be used.agentDefinitionModel(AgentDefinitionModel agentDefinitionModel) The agent definition model to be used.agentInstance(AgentInstance agentInstance) agentInvocationId(String agentInvocationId) create()protected AgentInvocationContextcreate(boolean nonTransactional) createOperationInfoData(String agentType, AgentDefinitionModel agentDefinitionModel, String parentDeploymentId, String tenantId) protected StringdetermineConstraintFailureMode(AgentDefinitionModel.AgentOperation operation, List<? extends AgentDefinitionModel.AgentParameter> parameters, GuardrailValidationResult result) protected ContentToImageConverterdetermineContentToImageConverter(AgentDefinitionModel agentDefinitionModel, org.flowable.content.api.ContentItem contentItem) protected ContentToMarkdownConverterdetermineContentToMarkdownConverter(AgentDefinitionModel agentDefinitionModel, org.flowable.content.api.ContentItem contentItem) protected StringformatViolations(List<GuardrailViolation> violations) protected CoreContentEngineConfigurationApigetEnabledContentToImageMimetypes(AgentDefinitionModel agentDefinitionModel) getEnabledContentToMarkdownMimetypes(AgentDefinitionModel agentDefinitionModel) protected org.flowable.form.api.FormEngineConfigurationApiprotected AgentInvocationEntitygetOrCreateAgentInvocationEntity(AgentInstance agentInstance, String operationKey, String userMessage, String systemMessage, String outputSchema) protected org.apache.tika.config.TikaConfigguardrailVariables(Map<String, Object> guardrailVariables) Set variables that are exclusively passed to guardrail agents during the invocation pipeline.operationKey(String operationKey) Add a parameter for expression evaluation.parameters(Map<String, Object> parameters) Add parameters for expression evaluation.protected voidprocessAndValidateInputParameter(AgentDefinition serviceDefinition, AgentDefinitionModel agentDefinitionModel, AgentDefinitionModel.AgentOperation operation, AgentDefinitionModel.AgentInputParameter inputParameter, Map<String, Object> serviceInvocationInputData, tools.jackson.databind.ObjectMapper objectMapper) Internal method to process a single input parameter by looking at its definition and checking its value.protected AgentDefinitionModelprotected StringresolveConstraintErrorCode(AgentDefinitionModel.AgentOperation operation, List<? extends AgentDefinitionModel.AgentParameter> parameters, GuardrailValidationResult result) protected List<org.flowable.content.api.ContentItem> resolveContentItems(Object value, CoreContentService contentService) resolveDocumentAssistantOperationInfo(AgentDefinitionModel agentDefinitionModel, String parentDeploymentId, String tenantId) resolveEvaluatorAgentOperationInfo(AgentDefinitionModel agentDefinitionModel, String parentDeploymentId, String tenantId) resolveEventCompletionData(AgentDefinitionModel agentDefinitionModel, org.flowable.common.engine.api.variable.VariableContainer variableContainer) resolveGuardrailAgentOperationInfo(AgentDefinitionModel agentDefinitionModel) protected KnowledgeBaseDefinitionresolveKnowledgeBaseDefinition(AgentDefinitionModel agentDefinitionModel) resolveOrchestratorAgentOperationInfo(AgentDefinitionModel agentDefinitionModel) protected StringresolveOutputSchema(AgentDefinitionModel.AgentOperation operation, AgentDefinitionModel agentDefinitionModel, String tenantId) protected StringskipEvaluators(boolean skipEvaluators) Suppress the automatic (async) evaluator dispatch for this invocation.userExchangePartType(String userExchangePartType) userGroupKeys(Collection<String> userGroupKeys) validateAndCompleteServiceInvocationInputDataMap(AgentDefinition agentDefinition, AgentDefinitionModel agentDefinitionModel, AgentInvocationContextBuilderImpl.OperationInfoData operationInfoData, tools.jackson.databind.ObjectMapper objectMapper) Creates, validates and completes the service invocation data according the input parameter definition of the service.protected voidvalidateFields(boolean nonTransactional) protected voidvalidateInputParameterConstraints(AgentDefinitionModel.AgentOperation operation, Map<String, Object> serviceData, BaseAgentInvocationContext context) Methods inherited from class AbstractNeedsKnowledgeBaseDefinitionCmd
resolveKnowledgeBaseDefinition, resolveKnowledgeBaseDefinitionMethods inherited from class AbstractNeedsAgentDefinitionCmd
resolveAgentDefinition, resolveAgentDefinitionById, resolveAgentDefinitionByKey
-
Field Details
-
USER_MESSAGE_MEDIA_ATTACHED
- See Also:
-
USER_MESSAGE_MARKDOWN_CONTENT
- See Also:
-
agentEngineConfiguration
-
commandContext
protected final org.flowable.common.engine.impl.interceptor.CommandContext commandContext -
agentDefinition
-
agentDefinitionModel
-
agentInstance
-
agentInvocationId
-
tenantId
-
tenantIdSet
protected boolean tenantIdSet -
operationKey
-
userExchangePartType
-
userId
-
userGroupKeys
-
serviceData
-
guardrailVariables
-
skipEvaluators
protected boolean skipEvaluators -
tikaConfig
protected org.apache.tika.config.TikaConfig tikaConfig -
resolvedContentItems
-
-
Constructor Details
-
AgentInvocationContextBuilderImpl
public AgentInvocationContextBuilderImpl(AgentEngineConfiguration agentEngineConfiguration, org.flowable.common.engine.impl.interceptor.CommandContext commandContext)
-
-
Method Details
-
agentDefinition
Description copied from interface:AgentInvocationContextBuilderThe agent definition to be used. If not provided thenAgentInvocationContextBuilder.agentDefinitionModel(AgentDefinitionModel)must be provided. Not allowed to be used together withAgentInvocationContextBuilder.agentDefinitionModel(AgentDefinitionModel).- Specified by:
agentDefinitionin interfaceAgentInvocationContextBuilder- Parameters:
agentDefinition- the agent definition to use
-
agentDefinitionModel
public AgentInvocationContextBuilder agentDefinitionModel(AgentDefinitionModel agentDefinitionModel) Description copied from interface:AgentInvocationContextBuilderThe agent definition model to be used. Not allowed to be used together withAgentInvocationContextBuilder.agentDefinition(AgentDefinition).- Specified by:
agentDefinitionModelin interfaceAgentInvocationContextBuilder- Parameters:
agentDefinitionModel- the agent definition model to use
-
agentInstance
- Specified by:
agentInstancein interfaceAgentInvocationContextBuilder
-
agentInvocationId
- Specified by:
agentInvocationIdin interfaceAgentInvocationContextBuilder
-
tenantId
- Specified by:
tenantIdin interfaceAgentInvocationContextBuilder
-
operationKey
- Specified by:
operationKeyin interfaceAgentInvocationContextBuilder
-
userExchangePartType
- Specified by:
userExchangePartTypein interfaceAgentInvocationContextBuilder
-
userId
- Specified by:
userIdin interfaceAgentInvocationContextBuilder
-
userGroupKeys
- Specified by:
userGroupKeysin interfaceAgentInvocationContextBuilder
-
parameters
Description copied from interface:AgentInvocationContextBuilderAdd parameters for expression evaluation. E.g., for the user / system messages.- Specified by:
parametersin interfaceAgentInvocationContextBuilder- Parameters:
parameters- the parameters to add
-
guardrailVariables
Description copied from interface:AgentInvocationContextBuilderSet variables that are exclusively passed to guardrail agents during the invocation pipeline.- Specified by:
guardrailVariablesin interfaceAgentInvocationContextBuilder
-
skipEvaluators
Description copied from interface:AgentInvocationContextBuilderSuppress the automatic (async) evaluator dispatch for this invocation. Defaults tofalse.- Specified by:
skipEvaluatorsin interfaceAgentInvocationContextBuilder
-
parameter
Description copied from interface:AgentInvocationContextBuilderAdd a parameter for expression evaluation. E.g., for the user / system messages.- Specified by:
parameterin interfaceAgentInvocationContextBuilder- Parameters:
name- the name of the parametervalue- the value of the parameter
-
create
- Specified by:
createin interfaceAgentInvocationContextBuilder
-
createNonTransactional
- Specified by:
createNonTransactionalin interfaceAgentInvocationContextBuilder
-
create
-
validateFields
protected void validateFields(boolean nonTransactional) -
resolveAgentDefinitionModel
-
getOrCreateAgentInvocationEntity
protected AgentInvocationEntity getOrCreateAgentInvocationEntity(AgentInstance agentInstance, String operationKey, String userMessage, String systemMessage, String outputSchema) -
createOperationInfoData
protected AgentInvocationContextBuilderImpl.OperationInfoData createOperationInfoData(String agentType, AgentDefinitionModel agentDefinitionModel, String parentDeploymentId, String tenantId) -
resolveOrchestratorAgentOperationInfo
protected AgentInvocationContextBuilderImpl.OperationInfoData resolveOrchestratorAgentOperationInfo(AgentDefinitionModel agentDefinitionModel) -
resolveGuardrailAgentOperationInfo
protected AgentInvocationContextBuilderImpl.OperationInfoData resolveGuardrailAgentOperationInfo(AgentDefinitionModel agentDefinitionModel) -
resolveEvaluatorAgentOperationInfo
protected AgentInvocationContextBuilderImpl.OperationInfoData resolveEvaluatorAgentOperationInfo(AgentDefinitionModel agentDefinitionModel, String parentDeploymentId, String tenantId) -
resolveDocumentAssistantOperationInfo
protected AgentInvocationContextBuilderImpl.OperationInfoData resolveDocumentAssistantOperationInfo(AgentDefinitionModel agentDefinitionModel, String parentDeploymentId, String tenantId) -
determineContentToImageConverter
protected ContentToImageConverter determineContentToImageConverter(AgentDefinitionModel agentDefinitionModel, org.flowable.content.api.ContentItem contentItem) -
getEnabledContentToImageMimetypes
-
determineContentToMarkdownConverter
protected ContentToMarkdownConverter determineContentToMarkdownConverter(AgentDefinitionModel agentDefinitionModel, org.flowable.content.api.ContentItem contentItem) -
getEnabledContentToMarkdownMimetypes
protected Set<String> getEnabledContentToMarkdownMimetypes(AgentDefinitionModel agentDefinitionModel) -
resolveEventCompletionData
protected AgentInvocationContextBuilderImpl.EventCompletionData resolveEventCompletionData(AgentDefinitionModel agentDefinitionModel, org.flowable.common.engine.api.variable.VariableContainer variableContainer) -
resolveKnowledgeBaseDefinition
protected KnowledgeBaseDefinition resolveKnowledgeBaseDefinition(AgentDefinitionModel agentDefinitionModel) -
resolveOutputSchema
protected String resolveOutputSchema(AgentDefinitionModel.AgentOperation operation, AgentDefinitionModel agentDefinitionModel, String tenantId) -
getContentEngineConfiguration
-
getFormEngineConfiguration
protected org.flowable.form.api.FormEngineConfigurationApi getFormEngineConfiguration() -
resolveParentDeploymentId
-
resolveContentItems
protected List<org.flowable.content.api.ContentItem> resolveContentItems(Object value, CoreContentService contentService) -
getTikaConfig
protected org.apache.tika.config.TikaConfig getTikaConfig() -
validateInputParameterConstraints
protected void validateInputParameterConstraints(AgentDefinitionModel.AgentOperation operation, Map<String, Object> serviceData, BaseAgentInvocationContext context) -
determineConstraintFailureMode
protected String determineConstraintFailureMode(AgentDefinitionModel.AgentOperation operation, List<? extends AgentDefinitionModel.AgentParameter> parameters, GuardrailValidationResult result) -
resolveConstraintErrorCode
protected String resolveConstraintErrorCode(AgentDefinitionModel.AgentOperation operation, List<? extends AgentDefinitionModel.AgentParameter> parameters, GuardrailValidationResult result) -
formatViolations
-
validateAndCompleteServiceInvocationInputDataMap
protected Map<String,Object> validateAndCompleteServiceInvocationInputDataMap(AgentDefinition agentDefinition, AgentDefinitionModel agentDefinitionModel, AgentInvocationContextBuilderImpl.OperationInfoData operationInfoData, tools.jackson.databind.ObjectMapper objectMapper) Creates, validates and completes the service invocation data according the input parameter definition of the service.- Parameters:
agentDefinition- the definition of the agent we want to invokeoperationInfoData- the service operation representing the service to be invokedobjectMapper- the object mapper used for creating and initializing variable values in JSON- Returns:
- the initialized and validated variable data map
- Throws:
org.flowable.common.engine.api.FlowableIllegalArgumentException- if the input parameter validation failed (e.g. a required parameter value was missing)
-
processAndValidateInputParameter
protected void processAndValidateInputParameter(AgentDefinition serviceDefinition, AgentDefinitionModel agentDefinitionModel, AgentDefinitionModel.AgentOperation operation, AgentDefinitionModel.AgentInputParameter inputParameter, Map<String, Object> serviceInvocationInputData, tools.jackson.databind.ObjectMapper objectMapper) Internal method to process a single input parameter by looking at its definition and checking its value. If a required input parameters value is missing and no default one is provided, it will throw an exception.- Parameters:
serviceDefinition- the agent service definitionagentDefinitionModel- the agent definition model the invocation is based onoperation- the agent operation the invocation is based oninputParameter- the input parameter to be processedserviceInvocationInputData- the agent service invocation input data map to be validated and completed for the given parameterobjectMapper- the object mapper used for creating and initializing variable values in JSON- Throws:
org.flowable.common.engine.api.FlowableIllegalArgumentException- if the input parameter validation failed (e.g. a required parameter value was missing)
-