Class: Vellum::NormalizedLogProbs
- Inherits:
-
Object
- Object
- Vellum::NormalizedLogProbs
- Defined in:
- lib/vellum_ai/types/normalized_log_probs.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
- #likelihood ⇒ Float readonly
- #tokens ⇒ Array<Vellum::NormalizedTokenLogProbs> readonly
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(tokens:, likelihood: OMIT, additional_properties: nil) ⇒ Vellum::NormalizedLogProbs constructor
- #to_json ⇒ String
Constructor Details
#initialize(tokens:, likelihood: OMIT, additional_properties: nil) ⇒ Vellum::NormalizedLogProbs
24 25 26 27 28 29 30 31 |
# File 'lib/vellum_ai/types/normalized_log_probs.rb', line 24 def initialize(tokens:, likelihood: OMIT, additional_properties: nil) @tokens = tokens @likelihood = likelihood if likelihood != OMIT @additional_properties = additional_properties @_field_set = { "tokens": tokens, "likelihood": likelihood }.reject do | _k, v | v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
13 14 15 |
# File 'lib/vellum_ai/types/normalized_log_probs.rb', line 13 def additional_properties @additional_properties end |
#likelihood ⇒ Float (readonly)
11 12 13 |
# File 'lib/vellum_ai/types/normalized_log_probs.rb', line 11 def likelihood @likelihood end |
#tokens ⇒ Array<Vellum::NormalizedTokenLogProbs> (readonly)
9 10 11 |
# File 'lib/vellum_ai/types/normalized_log_probs.rb', line 9 def tokens @tokens end |
Class Method Details
.from_json(json_object:) ⇒ Vellum::NormalizedLogProbs
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/vellum_ai/types/normalized_log_probs.rb', line 36 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) tokens = parsed_json["tokens"]&.map do | item | item = item.to_json Vellum::NormalizedTokenLogProbs.from_json(json_object: item) end likelihood = parsed_json["likelihood"] new( tokens: tokens, likelihood: likelihood, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
62 63 64 65 |
# File 'lib/vellum_ai/types/normalized_log_probs.rb', line 62 def self.validate_raw(obj:) obj.tokens.is_a?(Array) != false || raise("Passed value for field obj.tokens is not the expected type, validation failed.") obj.likelihood&.is_a?(Float) != false || raise("Passed value for field obj.likelihood is not the expected type, validation failed.") end |
Instance Method Details
#to_json ⇒ String
53 54 55 |
# File 'lib/vellum_ai/types/normalized_log_probs.rb', line 53 def to_json @_field_set&.to_json end |