Class: Langfuse::Evaluation
- Inherits:
-
Object
- Object
- Langfuse::Evaluation
- Defined in:
- lib/langfuse/evaluation.rb
Overview
Value object representing a single evaluation score
Returned by evaluator callables during experiment runs. Wraps a score name, value, and optional comment for persistence to the Langfuse API.
Instance Attribute Summary collapse
- #comment ⇒ String, ... readonly
- #config_id ⇒ String, ... readonly
- #data_type ⇒ String, ... readonly
- #metadata ⇒ String, ... readonly
- #name ⇒ String, ... readonly
- #value ⇒ String, ... readonly
Instance Method Summary collapse
-
#initialize(name:, value:, comment: nil, data_type: :numeric, config_id: nil, metadata: nil) ⇒ Evaluation
constructor
A new instance of Evaluation.
- #to_h ⇒ Hash{Symbol => Object}
Constructor Details
#initialize(name:, value:, comment: nil, data_type: :numeric, config_id: nil, metadata: nil) ⇒ Evaluation
Returns a new instance of Evaluation.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/langfuse/evaluation.rb', line 34 def initialize(name:, value:, comment: nil, data_type: :numeric, config_id: nil, metadata: nil) raise ArgumentError, "name is required" if name.to_s.empty? unless Types::SCORE_DATA_TYPES.key?(data_type) raise ArgumentError, "Invalid data_type: #{data_type}. Valid types: #{Types::VALID_SCORE_DATA_TYPES.join(', ')}" end validate_value!(value, data_type) @name = name @value = value @comment = comment @data_type = data_type @config_id = config_id @metadata = end |
Instance Attribute Details
#comment ⇒ String, ... (readonly)
24 25 26 |
# File 'lib/langfuse/evaluation.rb', line 24 def comment @comment end |
#config_id ⇒ String, ... (readonly)
24 25 26 |
# File 'lib/langfuse/evaluation.rb', line 24 def config_id @config_id end |
#data_type ⇒ String, ... (readonly)
24 25 26 |
# File 'lib/langfuse/evaluation.rb', line 24 def data_type @data_type end |
#metadata ⇒ String, ... (readonly)
24 25 26 |
# File 'lib/langfuse/evaluation.rb', line 24 def @metadata end |
#name ⇒ String, ... (readonly)
24 25 26 |
# File 'lib/langfuse/evaluation.rb', line 24 def name @name end |
#value ⇒ String, ... (readonly)
24 25 26 |
# File 'lib/langfuse/evaluation.rb', line 24 def value @value end |
Instance Method Details
#to_h ⇒ Hash{Symbol => Object}
53 54 55 56 |
# File 'lib/langfuse/evaluation.rb', line 53 def to_h { name: @name, value: @value, comment: @comment, data_type: @data_type, config_id: @config_id, metadata: @metadata }.compact end |