Class: Vellum::GenerateResult
- Inherits:
-
Object
- Object
- Vellum::GenerateResult
- Defined in:
- lib/vellum_ai/types/generate_result.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#data ⇒ Object
readonly
LLM provider experienced an error.
-
#error ⇒ Object
readonly
absent if the LLM provider did not experience an error.
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(data: OMIT, error: OMIT, additional_properties: nil) ⇒ Vellum::GenerateResult constructor
- #to_json ⇒ String
Constructor Details
#initialize(data: OMIT, error: OMIT, additional_properties: nil) ⇒ Vellum::GenerateResult
29 30 31 32 33 34 35 36 |
# File 'lib/vellum_ai/types/generate_result.rb', line 29 def initialize(data: OMIT, error: OMIT, additional_properties: nil) @data = data if data != OMIT @error = error if error != OMIT @additional_properties = additional_properties @_field_set = { "data": data, "error": error }.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/generate_result.rb', line 16 def additional_properties @additional_properties end |
#data ⇒ Object (readonly)
LLM provider experienced an error.
11 12 13 |
# File 'lib/vellum_ai/types/generate_result.rb', line 11 def data @data end |
#error ⇒ Object (readonly)
absent if the LLM provider did not experience an error.
14 15 16 |
# File 'lib/vellum_ai/types/generate_result.rb', line 14 def error @error end |
Class Method Details
.from_json(json_object:) ⇒ Vellum::GenerateResult
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/vellum_ai/types/generate_result.rb', line 41 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) unless parsed_json["data"].nil? data = parsed_json["data"].to_json data = Vellum::GenerateResultData.from_json(json_object: data) else data = nil end unless parsed_json["error"].nil? error = parsed_json["error"].to_json error = Vellum::GenerateResultError.from_json(json_object: error) else error = nil end new( data: data, error: error, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
74 75 76 77 |
# File 'lib/vellum_ai/types/generate_result.rb', line 74 def self.validate_raw(obj:) obj.data.nil? || Vellum::GenerateResultData.validate_raw(obj: obj.data) obj.error.nil? || Vellum::GenerateResultError.validate_raw(obj: obj.error) end |
Instance Method Details
#to_json ⇒ String
65 66 67 |
# File 'lib/vellum_ai/types/generate_result.rb', line 65 def to_json @_field_set&.to_json end |