Class: Vellum::ExecutePromptResponse
- Inherits:
-
Object
- Object
- Vellum::ExecutePromptResponse
- Defined in:
- lib/vellum_ai/types/execute_prompt_response.rb
Instance Attribute Summary collapse
-
#discriminant ⇒ Object
readonly
Returns the value of attribute discriminant.
-
#member ⇒ Object
readonly
Returns the value of attribute member.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ ExecutePromptResponse
Deserialize a JSON object to an instance of ExecutePromptResponse.
- .fulfilled(member:) ⇒ ExecutePromptResponse
- .rejected(member:) ⇒ ExecutePromptResponse
-
.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(member:, discriminant:) ⇒ ExecutePromptResponse constructor
-
#is_a?(obj) ⇒ Boolean
For Union Types, is_a? functionality is delegated to the wrapped member.
- #kind_of? ⇒ Object
-
#to_json(*_args) ⇒ JSON
For Union Types, to_json functionality is delegated to the wrapped member.
Constructor Details
#initialize(member:, discriminant:) ⇒ ExecutePromptResponse
16 17 18 19 20 21 |
# File 'lib/vellum_ai/types/execute_prompt_response.rb', line 16 def initialize(member:, discriminant:) # @type [Object] @member = member # @type [String] @discriminant = discriminant end |
Instance Attribute Details
#discriminant ⇒ Object (readonly)
Returns the value of attribute discriminant.
9 10 11 |
# File 'lib/vellum_ai/types/execute_prompt_response.rb', line 9 def discriminant @discriminant end |
#member ⇒ Object (readonly)
Returns the value of attribute member.
9 10 11 |
# File 'lib/vellum_ai/types/execute_prompt_response.rb', line 9 def member @member end |
Class Method Details
.from_json(json_object:) ⇒ ExecutePromptResponse
Deserialize a JSON object to an instance of ExecutePromptResponse
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/vellum_ai/types/execute_prompt_response.rb', line 27 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) member = case struct.state when "FULFILLED" FulfilledExecutePromptResponse.from_json(json_object: json_object) when "REJECTED" RejectedExecutePromptResponse.from_json(json_object: json_object) else FulfilledExecutePromptResponse.from_json(json_object: json_object) end new(member: member, discriminant: struct.state) end |
.fulfilled(member:) ⇒ ExecutePromptResponse
80 81 82 |
# File 'lib/vellum_ai/types/execute_prompt_response.rb', line 80 def self.fulfilled(member:) new(member: member, discriminant: "FULFILLED") end |
.rejected(member:) ⇒ ExecutePromptResponse
86 87 88 |
# File 'lib/vellum_ai/types/execute_prompt_response.rb', line 86 def self.rejected(member:) new(member: member, discriminant: "REJECTED") 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.
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/vellum_ai/types/execute_prompt_response.rb', line 59 def self.validate_raw(obj:) case obj.state when "FULFILLED" FulfilledExecutePromptResponse.validate_raw(obj: obj) when "REJECTED" RejectedExecutePromptResponse.validate_raw(obj: obj) else raise("Passed value matched no type within the union, validation failed.") end end |
Instance Method Details
#is_a?(obj) ⇒ Boolean
For Union Types, is_a? functionality is delegated to the wrapped member.
74 75 76 |
# File 'lib/vellum_ai/types/execute_prompt_response.rb', line 74 def is_a?(obj) @member.is_a?(obj) end |
#kind_of? ⇒ Object
12 |
# File 'lib/vellum_ai/types/execute_prompt_response.rb', line 12 alias kind_of? is_a? |
#to_json(*_args) ⇒ JSON
For Union Types, to_json functionality is delegated to the wrapped member.
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/vellum_ai/types/execute_prompt_response.rb', line 43 def to_json(*_args) case @discriminant when "FULFILLED" { **@member.to_json, state: @discriminant }.to_json when "REJECTED" { **@member.to_json, state: @discriminant }.to_json else { "state": @discriminant, value: @member }.to_json end @member.to_json end |