Experimental
@aws-cdk/aws-bedrock-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
CustomOrchestrationExecutor Class
Contains details about the Lambda function containing the orchestration logic carried out upon invoking the custom orchestration.
| Stability | Experimental |
|---|---|
| Source | bedrock/agents/orchestration-executor.ts |
Example
ts
const orchestrationFunction = new lambda.Function(this, 'OrchestrationFunction', {
runtime: lambda.Runtime.PYTHON_3_10,
handler: 'index.handler',
code: lambda.Code.fromAsset('lambda/orchestration'),
});
const agent = new bedrock.Agent(this, 'CustomOrchestrationAgent', {
instruction: 'You are a helpful assistant with custom orchestration logic.',
foundationModel: bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
customOrchestrationExecutor: bedrock.CustomOrchestrationExecutor.fromLambda(orchestrationFunction),
});
python
orchestration_function = lambda_.Function(self, "OrchestrationFunction",
runtime=lambda_.Runtime.PYTHON_3_10,
handler="index.handler",
code=lambda_.Code.from_asset("lambda/orchestration")
)
agent = bedrock.Agent(self, "CustomOrchestrationAgent",
instruction="You are a helpful assistant with custom orchestration logic.",
foundation_model=bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
custom_orchestration_executor=bedrock.CustomOrchestrationExecutor.from_lambda(orchestration_function)
)
java
Function orchestrationFunction = Function.Builder.create(this, "OrchestrationFunction")
.runtime(Runtime.PYTHON_3_10)
.handler("index.handler")
.code(Code.fromAsset("lambda/orchestration"))
.build();
Agent agent = Agent.Builder.create(this, "CustomOrchestrationAgent")
.instruction("You are a helpful assistant with custom orchestration logic.")
.foundationModel(BedrockFoundationModel.AMAZON_NOVA_LITE_V1)
.customOrchestrationExecutor(CustomOrchestrationExecutor.fromLambda(orchestrationFunction))
.build();
csharp
// Install: dotnet add package Amazon.CDK.AWS.Bedrock.Alpha
var orchestrationFunction = new Function(this, "OrchestrationFunction", new FunctionProps {
Runtime = Runtime.PYTHON_3_10,
Handler = "index.handler",
Code = Code.FromAsset("lambda/orchestration")
});
var agent = new Agent(this, "CustomOrchestrationAgent", new AgentProps {
Instruction = "You are a helpful assistant with custom orchestration logic.",
FoundationModel = BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
CustomOrchestrationExecutor = CustomOrchestrationExecutor.FromLambda(orchestrationFunction)
});
go
// Install: go get github.com/aws/aws-cdk-go/awsbedrockalpha/v2
orchestrationFunction := lambda.NewFunction(this, jsii.String("OrchestrationFunction"), &FunctionProps{
Runtime: lambda.Runtime_PYTHON_3_10(),
Handler: jsii.String("index.handler"),
Code: lambda.Code_FromAsset(jsii.String("lambda/orchestration")),
})
agent := bedrock.NewAgent(this, jsii.String("CustomOrchestrationAgent"), &AgentProps{
Instruction: jsii.String("You are a helpful assistant with custom orchestration logic."),
FoundationModel: bedrock.BedrockFoundationModel_AMAZON_NOVA_LITE_V1(),
CustomOrchestrationExecutor: bedrock.CustomOrchestrationExecutor_FromLambda(orchestrationFunction),
})
Properties
lambdaFunctionIFunctionlambda_functionIFunctionlambdaFunctionIFunctionLambdaFunctionIFunctionLambdaFunctionIFunction #The Lambda function that contains the custom orchestration logic.
This function is called when the agent needs to make decisions about action execution.
typeOrchestrationTypetypeOrchestrationTypetypeOrchestrationTypeTypeOrchestrationTypeTypeOrchestrationType #The type of orchestration this executor performs.
Methods
fromLambda(lambdaFunction: IFunction): CustomOrchestrationExecutor // chainable@staticmethod def from_lambda(lambda_function: IFunction) -> CustomOrchestrationExecutorpublic static CustomOrchestrationExecutor fromLambda(IFunction lambdaFunction)public static CustomOrchestrationExecutor FromLambda(IFunction lambdaFunction)func FromLambda(LambdaFunction IFunction) CustomOrchestrationExecutor static #Defines an orchestration executor with a Lambda function containing the business logic.
1 parameter
Parameters
lambdaFunctionlambda_functionlambdaFunctionlambdaFunctionLambdaFunction— - Lambda function to be called by the orchestration.