Experimental
@aws-cdk/aws-bedrock-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
CustomParserProps Struct
Properties for configuring a custom Lambda parser for prompt overrides.
| Stability | Experimental |
|---|---|
| Source | bedrock/agents/prompt-override.ts |
Example
ts
const parserFunction = new lambda.Function(this, 'ParserFunction', {
runtime: lambda.Runtime.PYTHON_3_10,
handler: 'index.handler',
code: lambda.Code.fromAsset('lambda'),
});
const agent = new bedrock.Agent(this, 'Agent', {
foundationModel: bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
instruction: 'You are a helpful assistant.',
promptOverrideConfiguration: bedrock.PromptOverrideConfiguration.withCustomParser({
parser: parserFunction,
preProcessingStep: {
stepType: bedrock.AgentStepType.PRE_PROCESSING,
useCustomParser: true
}
})
});
python
parser_function = lambda_.Function(self, "ParserFunction",
runtime=lambda_.Runtime.PYTHON_3_10,
handler="index.handler",
code=lambda_.Code.from_asset("lambda")
)
agent = bedrock.Agent(self, "Agent",
foundation_model=bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
instruction="You are a helpful assistant.",
prompt_override_configuration=bedrock.PromptOverrideConfiguration.with_custom_parser(
parser=parser_function,
pre_processing_step=bedrock.PromptPreProcessingConfigCustomParser(
step_type=bedrock.AgentStepType.PRE_PROCESSING,
use_custom_parser=True
)
)
)
java
Function parserFunction = Function.Builder.create(this, "ParserFunction")
.runtime(Runtime.PYTHON_3_10)
.handler("index.handler")
.code(Code.fromAsset("lambda"))
.build();
Agent agent = Agent.Builder.create(this, "Agent")
.foundationModel(BedrockFoundationModel.AMAZON_NOVA_LITE_V1)
.instruction("You are a helpful assistant.")
.promptOverrideConfiguration(PromptOverrideConfiguration.withCustomParser(CustomParserProps.builder()
.parser(parserFunction)
.preProcessingStep(PromptPreProcessingConfigCustomParser.builder()
.stepType(AgentStepType.PRE_PROCESSING)
.useCustomParser(true)
.build())
.build()))
.build();
csharp
// Install: dotnet add package Amazon.CDK.AWS.Bedrock.Alpha
var parserFunction = new Function(this, "ParserFunction", new FunctionProps {
Runtime = Runtime.PYTHON_3_10,
Handler = "index.handler",
Code = Code.FromAsset("lambda")
});
var agent = new Agent(this, "Agent", new AgentProps {
FoundationModel = BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
Instruction = "You are a helpful assistant.",
PromptOverrideConfiguration = PromptOverrideConfiguration.WithCustomParser(new CustomParserProps {
Parser = parserFunction,
PreProcessingStep = new PromptPreProcessingConfigCustomParser {
StepType = AgentStepType.PRE_PROCESSING,
UseCustomParser = true
}
})
});
go
// Install: go get github.com/aws/aws-cdk-go/awsbedrockalpha/v2
parserFunction := lambda.NewFunction(this, jsii.String("ParserFunction"), &FunctionProps{
Runtime: lambda.Runtime_PYTHON_3_10(),
Handler: jsii.String("index.handler"),
Code: lambda.Code_FromAsset(jsii.String("lambda")),
})
agent := bedrock.NewAgent(this, jsii.String("Agent"), &AgentProps{
FoundationModel: bedrock.BedrockFoundationModel_AMAZON_NOVA_LITE_V1(),
Instruction: jsii.String("You are a helpful assistant."),
PromptOverrideConfiguration: bedrock.PromptOverrideConfiguration_WithCustomParser(&CustomParserProps{
Parser: parserFunction,
PreProcessingStep: &PromptPreProcessingConfigCustomParser{
StepType: bedrock.AgentStepType_PRE_PROCESSING,
UseCustomParser: jsii.Boolean(true),
},
}),
})
Properties
knowledgeBaseResponseGenerationStepoptionalPromptKnowledgeBaseResponseGenerationConfigCustomParserknowledge_base_response_generation_stepoptionalPromptKnowledgeBaseResponseGenerationConfigCustomParserknowledgeBaseResponseGenerationStepoptionalPromptKnowledgeBaseResponseGenerationConfigCustomParserKnowledgeBaseResponseGenerationStepoptionalPromptKnowledgeBaseResponseGenerationConfigCustomParserKnowledgeBaseResponseGenerationStepoptionalPromptKnowledgeBaseResponseGenerationConfigCustomParser #Configuration for the knowledge base response generation step.
Default: undefined - No knowledge base response generation configuration
memorySummarizationStepoptionalPromptMemorySummarizationConfigCustomParsermemory_summarization_stepoptionalPromptMemorySummarizationConfigCustomParsermemorySummarizationStepoptionalPromptMemorySummarizationConfigCustomParserMemorySummarizationStepoptionalPromptMemorySummarizationConfigCustomParserMemorySummarizationStepoptionalPromptMemorySummarizationConfigCustomParser #Configuration for the memory summarization step.
Default: undefined - No memory summarization configuration
orchestrationStepoptionalPromptOrchestrationConfigCustomParserorchestration_stepoptionalPromptOrchestrationConfigCustomParserorchestrationStepoptionalPromptOrchestrationConfigCustomParserOrchestrationStepoptionalPromptOrchestrationConfigCustomParserOrchestrationStepoptionalPromptOrchestrationConfigCustomParser #Configuration for the orchestration step.
Default: undefined - No orchestration configuration
parseroptionalIFunctionparseroptionalIFunctionparseroptionalIFunctionParseroptionalIFunctionParseroptionalIFunction #Lambda function to use as custom parser.
Default: undefined - No custom parser is used
postProcessingStepoptionalPromptPostProcessingConfigCustomParserpost_processing_stepoptionalPromptPostProcessingConfigCustomParserpostProcessingStepoptionalPromptPostProcessingConfigCustomParserPostProcessingStepoptionalPromptPostProcessingConfigCustomParserPostProcessingStepoptionalPromptPostProcessingConfigCustomParser #Configuration for the post-processing step.
Default: undefined - No post-processing configuration
preProcessingStepoptionalPromptPreProcessingConfigCustomParserpre_processing_stepoptionalPromptPreProcessingConfigCustomParserpreProcessingStepoptionalPromptPreProcessingConfigCustomParserPreProcessingStepoptionalPromptPreProcessingConfigCustomParserPreProcessingStepoptionalPromptPreProcessingConfigCustomParser #Configuration for the pre-processing step.
Default: undefined - No pre-processing configuration
routingClassifierStepoptionalPromptRoutingClassifierConfigCustomParserrouting_classifier_stepoptionalPromptRoutingClassifierConfigCustomParserroutingClassifierStepoptionalPromptRoutingClassifierConfigCustomParserRoutingClassifierStepoptionalPromptRoutingClassifierConfigCustomParserRoutingClassifierStepoptionalPromptRoutingClassifierConfigCustomParser #Configuration for the routing classifier step.
Default: undefined - No routing classifier configuration