Class: Vellum::GenerateStreamResultData
- Inherits:
-
Object
- Object
- Vellum::GenerateStreamResultData
- Defined in:
- lib/vellum_ai/types/generate_stream_result_data.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#completion ⇒ Object
readonly
Returns the value of attribute completion.
-
#completion_index ⇒ Object
readonly
Returns the value of attribute completion_index.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ GenerateStreamResultData
Deserialize a JSON object to an instance of GenerateStreamResultData.
-
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
Instance Method Summary collapse
- #initialize(completion_index:, completion:, additional_properties: nil) ⇒ GenerateStreamResultData constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of GenerateStreamResultData to a JSON object.
Constructor Details
#initialize(completion_index:, completion:, additional_properties: nil) ⇒ GenerateStreamResultData
14 15 16 17 18 19 20 21 |
# File 'lib/vellum_ai/types/generate_stream_result_data.rb', line 14 def initialize(completion_index:, completion:, additional_properties: nil) # @type [Integer] @completion_index = completion_index # @type [EnrichedNormalizedCompletion] @completion = completion # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties end |
Instance Attribute Details
#additional_properties ⇒ Object (readonly)
Returns the value of attribute additional_properties.
8 9 10 |
# File 'lib/vellum_ai/types/generate_stream_result_data.rb', line 8 def additional_properties @additional_properties end |
#completion ⇒ Object (readonly)
Returns the value of attribute completion.
8 9 10 |
# File 'lib/vellum_ai/types/generate_stream_result_data.rb', line 8 def completion @completion end |
#completion_index ⇒ Object (readonly)
Returns the value of attribute completion_index.
8 9 10 |
# File 'lib/vellum_ai/types/generate_stream_result_data.rb', line 8 def completion_index @completion_index end |
Class Method Details
.from_json(json_object:) ⇒ GenerateStreamResultData
Deserialize a JSON object to an instance of GenerateStreamResultData
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/vellum_ai/types/generate_stream_result_data.rb', line 27 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) completion_index = struct.completion_index if parsed_json["completion"].nil? completion = nil else completion = parsed_json["completion"].to_json completion = EnrichedNormalizedCompletion.from_json(json_object: completion) end new(completion_index: completion_index, completion: completion, additional_properties: struct) end |
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
51 52 53 54 |
# File 'lib/vellum_ai/types/generate_stream_result_data.rb', line 51 def self.validate_raw(obj:) obj.completion_index.is_a?(Integer) != false || raise("Passed value for field obj.completion_index is not the expected type, validation failed.") EnrichedNormalizedCompletion.validate_raw(obj: obj.completion) end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of GenerateStreamResultData to a JSON object
43 44 45 |
# File 'lib/vellum_ai/types/generate_stream_result_data.rb', line 43 def to_json(*_args) { "completion_index": @completion_index, "completion": @completion }.to_json end |