Class: Vellum::GenerateStreamResult
- Inherits:
-
Object
- Object
- Vellum::GenerateStreamResult
- Defined in:
- lib/vellum_ai/types/generate_stream_result.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#request_index ⇒ Object
readonly
Returns the value of attribute request_index.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ GenerateStreamResult
Deserialize a JSON object to an instance of GenerateStreamResult.
-
.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(request_index:, data: nil, error: nil, additional_properties: nil) ⇒ GenerateStreamResult constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of GenerateStreamResult to a JSON object.
Constructor Details
#initialize(request_index:, data: nil, error: nil, additional_properties: nil) ⇒ GenerateStreamResult
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/vellum_ai/types/generate_stream_result.rb', line 16 def initialize(request_index:, data: nil, error: nil, additional_properties: nil) # @type [Integer] @request_index = request_index # @type [GenerateStreamResultData] @data = data # @type [GenerateResultError] @error = error # @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.
9 10 11 |
# File 'lib/vellum_ai/types/generate_stream_result.rb', line 9 def additional_properties @additional_properties end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
9 10 11 |
# File 'lib/vellum_ai/types/generate_stream_result.rb', line 9 def data @data end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
9 10 11 |
# File 'lib/vellum_ai/types/generate_stream_result.rb', line 9 def error @error end |
#request_index ⇒ Object (readonly)
Returns the value of attribute request_index.
9 10 11 |
# File 'lib/vellum_ai/types/generate_stream_result.rb', line 9 def request_index @request_index end |
Class Method Details
.from_json(json_object:) ⇒ GenerateStreamResult
Deserialize a JSON object to an instance of GenerateStreamResult
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/vellum_ai/types/generate_stream_result.rb', line 31 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) request_index = struct.request_index if parsed_json["data"].nil? data = nil else data = parsed_json["data"].to_json data = GenerateStreamResultData.from_json(json_object: data) end if parsed_json["error"].nil? error = nil else error = parsed_json["error"].to_json error = GenerateResultError.from_json(json_object: error) end new(request_index: request_index, data: data, error: error, 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.
61 62 63 64 65 |
# File 'lib/vellum_ai/types/generate_stream_result.rb', line 61 def self.validate_raw(obj:) obj.request_index.is_a?(Integer) != false || raise("Passed value for field obj.request_index is not the expected type, validation failed.") obj.data.nil? || GenerateStreamResultData.validate_raw(obj: obj.data) obj.error.nil? || GenerateResultError.validate_raw(obj: obj.error) end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of GenerateStreamResult to a JSON object
53 54 55 |
# File 'lib/vellum_ai/types/generate_stream_result.rb', line 53 def to_json(*_args) { "request_index": @request_index, "data": @data, "error": @error }.to_json end |