Method: Vellum::NormalizedLogProbs.from_json

Defined in:
lib/vellum_ai/types/normalized_log_probs.rb

.from_json(json_object:) ⇒ NormalizedLogProbs

Deserialize a JSON object to an instance of NormalizedLogProbs

Parameters:

  • json_object (JSON)

Returns:



27
28
29
30
31
32
33
34
35
36
# File 'lib/vellum_ai/types/normalized_log_probs.rb', line 27

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 |v|
    v = v.to_json
    NormalizedTokenLogProbs.from_json(json_object: v)
  end
  likelihood = struct.likelihood
  new(tokens: tokens, likelihood: likelihood, additional_properties: struct)
end