Experimental
@aws-cdk/aws-bedrock-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
AgentActionGroup Class
**************************************************************************** DEF - Action Group Class ***************************************************************************.
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);
python
bucket = s3.Bucket.from_bucket_name(self, "ExistingBucket", "my-schema-bucket")
s3_schema = bedrock.ApiSchema.from_s3_file(bucket, "schemas/action-group.yaml")
action_group_function = lambda_.Function(self, "ActionGroupFunction",
runtime=lambda_.Runtime.PYTHON_3_12,
handler="index.handler",
code=lambda_.Code.from_asset(path.join(__dirname, "../lambda/action-group"))
)
action_group = bedrock.AgentActionGroup(
name="query-library",
description="Use these functions to get information about the books in the library.",
executor=bedrock.ActionGroupExecutor.from_lambda(action_group_function),
enabled=True,
api_schema=s3_schema
)
agent = bedrock.Agent(self, "Agent",
foundation_model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_HAIKU_V1_0,
instruction="You are a helpful and friendly agent that answers questions about literature."
)
agent.add_action_group(action_group)
java
IBucket bucket = Bucket.fromBucketName(this, "ExistingBucket", "my-schema-bucket");
S3ApiSchema s3Schema = ApiSchema.fromS3File(bucket, "schemas/action-group.yaml");
Function actionGroupFunction = Function.Builder.create(this, "ActionGroupFunction")
.runtime(Runtime.PYTHON_3_12)
.handler("index.handler")
.code(Code.fromAsset(join(__dirname, "../lambda/action-group")))
.build();
AgentActionGroup actionGroup = AgentActionGroup.Builder.create()
.name("query-library")
.description("Use these functions to get information about the books in the library.")
.executor(ActionGroupExecutor.fromLambda(actionGroupFunction))
.enabled(true)
.apiSchema(s3Schema)
.build();
Agent agent = Agent.Builder.create(this, "Agent")
.foundationModel(BedrockFoundationModel.ANTHROPIC_CLAUDE_HAIKU_V1_0)
.instruction("You are a helpful and friendly agent that answers questions about literature.")
.build();
agent.addActionGroup(actionGroup);
csharp
// Install: dotnet add package Amazon.CDK.AWS.Bedrock.Alpha
var bucket = Bucket.FromBucketName(this, "ExistingBucket", "my-schema-bucket");
var s3Schema = ApiSchema.FromS3File(bucket, "schemas/action-group.yaml");
var actionGroupFunction = new Function(this, "ActionGroupFunction", new FunctionProps {
Runtime = Runtime.PYTHON_3_12,
Handler = "index.handler",
Code = Code.FromAsset(Join(__dirname, "../lambda/action-group"))
});
var actionGroup = new AgentActionGroup(new AgentActionGroupProps {
Name = "query-library",
Description = "Use these functions to get information about the books in the library.",
Executor = ActionGroupExecutor.FromLambda(actionGroupFunction),
Enabled = true,
ApiSchema = s3Schema
});
var agent = new Agent(this, "Agent", new AgentProps {
FoundationModel = BedrockFoundationModel.ANTHROPIC_CLAUDE_HAIKU_V1_0,
Instruction = "You are a helpful and friendly agent that answers questions about literature."
});
agent.AddActionGroup(actionGroup);
go
// Install: go get github.com/aws/aws-cdk-go/awsbedrockalpha/v2
bucket := s3.Bucket_FromBucketName(this, jsii.String("ExistingBucket"), jsii.String("my-schema-bucket"))
s3Schema := bedrock.ApiSchema_FromS3File(bucket, jsii.String("schemas/action-group.yaml"))
actionGroupFunction := lambda.NewFunction(this, jsii.String("ActionGroupFunction"), &FunctionProps{
Runtime: lambda.Runtime_PYTHON_3_12(),
Handler: jsii.String("index.handler"),
Code: lambda.Code_FromAsset(path.join(__dirname, jsii.String("../lambda/action-group"))),
})
actionGroup := bedrock.NewAgentActionGroup(&AgentActionGroupProps{
Name: jsii.String("query-library"),
Description: jsii.String("Use these functions to get information about the books in the library."),
Executor: bedrock.ActionGroupExecutor_FromLambda(actionGroupFunction),
Enabled: jsii.Boolean(true),
ApiSchema: s3Schema,
})
agent := bedrock.NewAgent(this, jsii.String("Agent"), &AgentProps{
FoundationModel: bedrock.BedrockFoundationModel_ANTHROPIC_CLAUDE_HAIKU_V1_0(),
Instruction: jsii.String("You are a helpful and friendly agent that answers questions about literature."),
})
agent.AddActionGroup(actionGroup)
Initializer
ts
new AgentActionGroup(props: AgentActionGroupProps)
python
AgentActionGroup(props: AgentActionGroupProps)
java
new AgentActionGroup(AgentActionGroupProps props)
csharp
new AgentActionGroup(AgentActionGroupProps props)
go
NewAgentActionGroup(Props AgentActionGroupProps)
Properties
apiSchemamay be undefinedApiSchemaapi_schemamay be undefinedApiSchemaapiSchemamay be undefinedApiSchemaApiSchemamay be undefinedApiSchemaApiSchemamay be undefinedApiSchema#The api schema for this action group (if defined).
descriptionmay be undefinedstringdescriptionmay be undefinedstrdescriptionmay be undefinedStringDescriptionmay be undefinedstringDescriptionmay be undefined*string#A description of the action group.
Whether this action group is available for the agent to invoke or not.
executormay be undefinedActionGroupExecutorexecutormay be undefinedActionGroupExecutorexecutormay be undefinedActionGroupExecutorExecutormay be undefinedActionGroupExecutorExecutormay be undefinedActionGroupExecutor#The action group executor for this action group (if defined).
forceDeletemay be undefinedbooleanforce_deletemay be undefinedboolforceDeletemay be undefinedBooleanForceDeletemay be undefinedboolForceDeletemay be undefined*bool#Whether to delete the resource even if it's in use.
functionSchemamay be undefinedFunctionSchemafunction_schemamay be undefinedFunctionSchemafunctionSchemamay be undefinedFunctionSchemaFunctionSchemamay be undefinedFunctionSchemaFunctionSchemamay be undefinedFunctionSchema#The function schema for this action group (if defined).
The name of the action group.
parentActionGroupSignaturemay be undefinedParentActionGroupSignatureparent_action_group_signaturemay be undefinedParentActionGroupSignatureparentActionGroupSignaturemay be undefinedParentActionGroupSignatureParentActionGroupSignaturemay be undefinedParentActionGroupSignatureParentActionGroupSignaturemay be undefinedParentActionGroupSignature#The AWS Defined signature (if defined).
Methods
codeInterpreter(enabled: boolean): AgentActionGroup // chainable@staticmethod def code_interpreter(enabled: bool) -> AgentActionGrouppublic static AgentActionGroup codeInterpreter(Boolean enabled)public static AgentActionGroup CodeInterpreter(bool enabled)func CodeInterpreter(Enabled *bool) AgentActionGroupstatic#Defines an action group that allows your agent to request the user for additional information when trying to complete a task.
1 parameter
Parameters
enabledenabledenabledenabledEnabled— Specifies whether the action group is available for the agent.
userInput(enabled: boolean): AgentActionGroup // chainable@staticmethod def user_input(enabled: bool) -> AgentActionGrouppublic static AgentActionGroup userInput(Boolean enabled)public static AgentActionGroup UserInput(bool enabled)func UserInput(Enabled *bool) AgentActionGroupstatic#Defines an action group that allows your agent to request the user for additional information when trying to complete a task.
1 parameter
Parameters
enabledenabledenabledenabledEnabled— Specifies whether the action group is available for the agent.