Module: Langfuse::ScoreValue Private

Defined in:
lib/langfuse/score_value.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Normalizes score values to the wire representation expected by Langfuse.

Class Method Summary collapse

Class Method Details

.normalize(value, data_type) ⇒ Numeric, String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns normalized score value.

Parameters:

  • value (Object)

    raw score value

  • data_type (Symbol)

    score data type

Returns:

  • (Numeric, String)

    normalized score value

Raises:

  • (ArgumentError)

    if the value does not match the data type



14
15
16
17
18
19
20
21
22
23
# File 'lib/langfuse/score_value.rb', line 14

def self.normalize(value, data_type)
  case data_type
  when :numeric then numeric(value)
  when :boolean then boolean(value)
  when :categorical then string(value, "Categorical")
  when :text then text(value)
  when :correction then string(value, "Correction")
  else raise ArgumentError, "Invalid data_type: #{data_type}"
  end
end