Guardrail Class
Guradrail settings for BedrockInvokeModel.
Example
ts
import * as bedrock from 'aws-cdk-lib/aws-bedrock';
const model = bedrock.FoundationModel.fromFoundationModelId(
this,
'Model',
bedrock.FoundationModelIdentifier.AMAZON_TITAN_TEXT_G1_EXPRESS_V1,
);
const task = new tasks.BedrockInvokeModel(this, 'Prompt Model with guardrail', {
model,
body: sfn.TaskInput.fromObject(
{
inputText: 'Generate a list of five first names.',
textGenerationConfig: {
maxTokenCount: 100,
temperature: 1,
},
},
),
guardrail: tasks.Guardrail.enable('guardrailId', 1),
resultSelector: {
names: sfn.JsonPath.stringAt('$.Body.results[0].outputText'),
},
});
Properties
Methods
enable(identifier: string, version: number): Guardrail // chainable@staticmethod def enable(identifier: str, version: int | float) -> Guardrailpublic static Guardrail enable(String identifier, Number version)public static Guardrail Enable(string identifier, double version)func Enable(Identifier *string, Version *float64) Guardrailstatic#Enable guardrail.
2 parameters
Parameters
identifieridentifieridentifieridentifierIdentifier— The id or arn of the guardrail.versionversionversionversionVersion— The version of the guardrail.
enableDraft(identifier: string): Guardrail // chainable@staticmethod def enable_draft(identifier: str) -> Guardrailpublic static Guardrail enableDraft(String identifier)public static Guardrail EnableDraft(string identifier)func EnableDraft(Identifier *string) Guardrailstatic#Enable guardrail with DRAFT version.
1 parameter
Parameters
identifieridentifieridentifieridentifierIdentifier— The identifier of the guardrail.