Class: Vellum::NormalizedTokenLogProbs
- Inherits:
-
Object
- Object
- Vellum::NormalizedTokenLogProbs
- Defined in:
- lib/vellum_ai/types/normalized_token_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.
- #logprob ⇒ Float readonly
- #text_offset ⇒ Integer readonly
- #token ⇒ String readonly
- #top_logprobs ⇒ Hash{String => Float} readonly
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(token:, logprob: OMIT, top_logprobs: OMIT, text_offset:, additional_properties: nil) ⇒ Vellum::NormalizedTokenLogProbs constructor
- #to_json ⇒ String
Constructor Details
#initialize(token:, logprob: OMIT, top_logprobs: OMIT, text_offset:, additional_properties: nil) ⇒ Vellum::NormalizedTokenLogProbs
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/vellum_ai/types/normalized_token_log_probs.rb', line 29 def initialize(token:, logprob: OMIT, top_logprobs: OMIT, text_offset:, additional_properties: nil) @token = token @logprob = logprob if logprob != OMIT @top_logprobs = top_logprobs if top_logprobs != OMIT @text_offset = text_offset @additional_properties = additional_properties @_field_set = { "token": token, "logprob": logprob, "top_logprobs": top_logprobs, "text_offset": text_offset }.reject do | _k, v | v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
16 17 18 |
# File 'lib/vellum_ai/types/normalized_token_log_probs.rb', line 16 def additional_properties @additional_properties end |
#logprob ⇒ Float (readonly)
10 11 12 |
# File 'lib/vellum_ai/types/normalized_token_log_probs.rb', line 10 def logprob @logprob end |
#text_offset ⇒ Integer (readonly)
14 15 16 |
# File 'lib/vellum_ai/types/normalized_token_log_probs.rb', line 14 def text_offset @text_offset end |
#token ⇒ String (readonly)
8 9 10 |
# File 'lib/vellum_ai/types/normalized_token_log_probs.rb', line 8 def token @token end |
#top_logprobs ⇒ Hash{String => Float} (readonly)
12 13 14 |
# File 'lib/vellum_ai/types/normalized_token_log_probs.rb', line 12 def top_logprobs @top_logprobs end |
Class Method Details
.from_json(json_object:) ⇒ Vellum::NormalizedTokenLogProbs
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/vellum_ai/types/normalized_token_log_probs.rb', line 43 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) token = parsed_json["token"] logprob = parsed_json["logprob"] top_logprobs = parsed_json["top_logprobs"] text_offset = parsed_json["text_offset"] new( token: token, logprob: logprob, top_logprobs: top_logprobs, text_offset: text_offset, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
70 71 72 73 74 75 |
# File 'lib/vellum_ai/types/normalized_token_log_probs.rb', line 70 def self.validate_raw(obj:) obj.token.is_a?(String) != false || raise("Passed value for field obj.token is not the expected type, validation failed.") obj.logprob&.is_a?(Float) != false || raise("Passed value for field obj.logprob is not the expected type, validation failed.") obj.top_logprobs&.is_a?(Hash) != false || raise("Passed value for field obj.top_logprobs is not the expected type, validation failed.") obj.text_offset.is_a?(Integer) != false || raise("Passed value for field obj.text_offset is not the expected type, validation failed.") end |
Instance Method Details
#to_json ⇒ String
61 62 63 |
# File 'lib/vellum_ai/types/normalized_token_log_probs.rb', line 61 def to_json @_field_set&.to_json end |