Class: AWSCDK::BedrockAgentCore::EvaluatorConfig

Inherits:
Jsii::Object
  • Object
show all
Defined in:
bedrock_agent_core/evaluator_config.rb

Overview

Configuration for a custom evaluator.

Defines how an evaluator assesses agent performance. Supports two strategies:

  • LLM-as-a-Judge: Uses a foundation model with custom instructions and a rating scale.
  • Code-based: Uses a Lambda function for custom evaluation logic.

Examples:

# Code-based evaluator
my_eval_function = nil # AWSCDK::Lambda::IFunction
# LLM-as-a-Judge evaluator
llm_config = AWSCDK::BedrockAgentCore::EvaluatorConfig.llm_as_a_judge({
    instructions: "Evaluate whether the agent response is helpful.",
    model_id: "us.anthropic.claude-sonnet-4-6",
    rating_scale: AWSCDK::BedrockAgentCore::EvaluatorRatingScale.categorical([
        {label: "Good", definition: "The response is helpful."},
        {label: "Bad", definition: "The response is not helpful."},
    ]),
})
code_config = AWSCDK::BedrockAgentCore::EvaluatorConfig.code_based({
    lambda_function: my_eval_function,
})

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ EvaluatorConfig

Returns a new instance of EvaluatorConfig.

Raises:

  • (NoMethodError)


29
30
31
# File 'bedrock_agent_core/evaluator_config.rb', line 29

def initialize(*args)
  raise NoMethodError, "aws-cdk-lib.aws_bedrockagentcore.EvaluatorConfig does not have a visible constructor; use the provided factory methods"
end

Class Method Details

.code_based(options) ⇒ AWSCDK::BedrockAgentCore::EvaluatorConfig

Creates a code-based evaluator configuration using a Lambda function.

The Lambda function implements custom evaluation logic. The function will automatically be granted invoke permissions for the bedrock-agentcore service.

Parameters:

Returns:

  • (AWSCDK::BedrockAgentCore::EvaluatorConfig)


46
47
48
49
50
# File 'bedrock_agent_core/evaluator_config.rb', line 46

def self.code_based(options)
  options = options.is_a?(Hash) ? ::AWSCDK::BedrockAgentCore::CodeBasedOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYmVkcm9ja2FnZW50Y29yZS5Db2RlQmFzZWRPcHRpb25zIn0=")), "options")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_bedrockagentcore.EvaluatorConfig", "codeBased", [options])
end

.jsii_overridable_methodsObject



33
34
35
36
37
# File 'bedrock_agent_core/evaluator_config.rb', line 33

def self.jsii_overridable_methods
  {
    :lambda_function => { kind: :property, name: "lambdaFunction", is_optional: true },
  }
end

.llm_as_a_judge(options) ⇒ AWSCDK::BedrockAgentCore::EvaluatorConfig

Creates an LLM-as-a-Judge evaluator configuration.

Uses a foundation model to assess agent performance based on custom instructions and a rating scale.

Parameters:

Returns:

  • (AWSCDK::BedrockAgentCore::EvaluatorConfig)


59
60
61
62
63
# File 'bedrock_agent_core/evaluator_config.rb', line 59

def self.llm_as_a_judge(options)
  options = options.is_a?(Hash) ? ::AWSCDK::BedrockAgentCore::LlmAsAJudgeOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYmVkcm9ja2FnZW50Y29yZS5MbG1Bc0FKdWRnZU9wdGlvbnMifQ==")), "options")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_bedrockagentcore.EvaluatorConfig", "llmAsAJudge", [options])
end

Instance Method Details

#lambda_functionAWSCDK::Lambda::IFunction?

The Lambda function used for code-based evaluation, if applicable.

Returns:



68
69
70
# File 'bedrock_agent_core/evaluator_config.rb', line 68

def lambda_function()
  jsii_get_property("lambdaFunction")
end