Class: Vellum::GenerateResponse
- Inherits:
-
Object
- Object
- Vellum::GenerateResponse
- Defined in:
- lib/vellum_ai/types/generate_response.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#results ⇒ Array<Vellum::GenerateResult>
readonly
The results of each generation request.
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(results:, additional_properties: nil) ⇒ Vellum::GenerateResponse constructor
- #to_json ⇒ String
Constructor Details
#initialize(results:, additional_properties: nil) ⇒ Vellum::GenerateResponse
21 22 23 24 25 |
# File 'lib/vellum_ai/types/generate_response.rb', line 21 def initialize(results:, additional_properties: nil) @results = results @additional_properties = additional_properties @_field_set = { "results": results } end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
11 12 13 |
# File 'lib/vellum_ai/types/generate_response.rb', line 11 def additional_properties @additional_properties end |
#results ⇒ Array<Vellum::GenerateResult> (readonly)
Returns The results of each generation request.
9 10 11 |
# File 'lib/vellum_ai/types/generate_response.rb', line 9 def results @results end |
Class Method Details
.from_json(json_object:) ⇒ Vellum::GenerateResponse
30 31 32 33 34 35 36 37 38 |
# File 'lib/vellum_ai/types/generate_response.rb', line 30 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) results = parsed_json["results"]&.map do | item | item = item.to_json Vellum::GenerateResult.from_json(json_object: item) end new(results: results, additional_properties: struct) end |
.validate_raw(obj:) ⇒ Void
51 52 53 |
# File 'lib/vellum_ai/types/generate_response.rb', line 51 def self.validate_raw(obj:) obj.results.is_a?(Array) != false || raise("Passed value for field obj.results is not the expected type, validation failed.") end |
Instance Method Details
#to_json ⇒ String
42 43 44 |
# File 'lib/vellum_ai/types/generate_response.rb', line 42 def to_json @_field_set&.to_json end |