Skip to content
v2.274.0

Experimental

@aws-cdk/aws-bedrock-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.

ActionGroupExecutor Class ​

Defines how fulfillment of the action group is handled after the necessary information has been elicited from the user.

Valid executors are:

  • Lambda function
  • Return Control

Example ​

ts
const bucket = s3.Bucket.fromBucketName(this, 'ExistingBucket', 'my-schema-bucket');
const s3Schema = bedrock.ApiSchema.fromS3File(bucket, 'schemas/action-group.yaml');

const actionGroupFunction = new lambda.Function(this, 'ActionGroupFunction', {
  runtime: lambda.Runtime.PYTHON_3_12,
  handler: 'index.handler',
  code: lambda.Code.fromAsset(path.join(__dirname, '../lambda/action-group')),
});

const actionGroup = new bedrock.AgentActionGroup({
  name: 'query-library',
  description: 'Use these functions to get information about the books in the library.',
  executor: bedrock.ActionGroupExecutor.fromLambda(actionGroupFunction),
  enabled: true,
  apiSchema: s3Schema,
});

const agent = new bedrock.Agent(this, 'Agent', {
  foundationModel: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_HAIKU_V1_0,
  instruction: 'You are a helpful and friendly agent that answers questions about literature.',
});

agent.addActionGroup(actionGroup);

Properties ​

customControlmay be undefinedCustomControlcustom_controlmay be undefinedCustomControlcustomControlmay be undefinedCustomControlCustomControlmay be undefinedCustomControlCustomControlmay be undefinedCustomControl#
The custom control type for the action group executor.

Currently only supports 'RETURN_CONTROL' which returns results directly in the InvokeAgent response.

lambdaFunctionmay be undefinedIFunctionlambda_functionmay be undefinedIFunctionlambdaFunctionmay be undefinedIFunctionLambdaFunctionmay be undefinedIFunctionLambdaFunctionmay be undefinedIFunction#
The Lambda function that will be called by the action group.

Contains the business logic for handling the action group's invocation.

RETURN_CONTROLActionGroupExecutorreturn_controlActionGroupExecutorRETURN_CONTROLActionGroupExecutorRETURN_CONTROLActionGroupExecutorRETURN_CONTROLActionGroupExecutorrequiredstatic#
Returns the action group invocation results directly in the InvokeAgent response.

The information and parameters can be sent to your own systems to yield results.

Methods ​

fromLambda(lambdaFunction: IFunction): ActionGroupExecutor // chainable@staticmethod def from_lambda(lambda_function: IFunction) -> ActionGroupExecutorpublic static ActionGroupExecutor fromLambda(IFunction lambdaFunction)public static ActionGroupExecutor FromLambda(IFunction lambdaFunction)func FromLambda(LambdaFunction IFunction) ActionGroupExecutorstatic#
Defines an action group with a Lambda function containing the business logic.
1 parameter

Parameters

  • lambdaFunctionlambda_functionlambdaFunctionlambdaFunctionLambdaFunction — - Lambda function to be called by the action group.