> **Experimental**
>
> `@aws-cdk/aws-bedrock-alpha` is an [**experimental**](/stability) (alpha) package: its API may change in any release, without a major version bump.
# PromptPreProcessingConfigCustomParser

Configuration for the pre-processing step.

Extends: [PromptStepConfigBase](/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.PromptStepConfigBase.html)

- Stability: [Experimental](/cdk/api/stability.html)
- Source: [`bedrock/agents/prompt-override.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/@aws-cdk/aws-bedrock-alpha/bedrock/agents/prompt-override.ts#L149)

## Example

TypeScript:

```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:

```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:

```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();
```

C# / .NET:

```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
        }
    })
});
```

Golang:

```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

- `customPromptTemplate`: string — The custom prompt template to be used.

  **Default:** The default prompt template will be used.

- `inferenceConfig`: [InferenceConfiguration](/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.InferenceConfiguration.html) — The inference configuration parameters to use.

  **Default:** undefined - Default inference configuration will be used

- `stepEnabled`: boolean — Whether to enable or skip this step in the agent sequence.

  **Default:** The default state for each step type is as follows. PRE_PROCESSING – ENABLED ORCHESTRATION – ENABLED KNOWLEDGE_BASE_RESPONSE_GENERATION – ENABLED POST_PROCESSING – DISABLED

- `stepType`: [AgentStepType](/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.AgentStepType.html) (required) — The type of step this configuration applies to.

- `useCustomParser`: boolean = false — Whether to use the custom Lambda parser defined for the sequence.
