Class: Vellum::CodeExecutionNodeResultOutput
- Inherits:
-
Object
- Object
- Vellum::CodeExecutionNodeResultOutput
- Defined in:
- lib/vellum_ai/types/code_execution_node_result_output.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
- .array(member:) ⇒ CodeExecutionNodeResultOutput
- .chat_history(member:) ⇒ CodeExecutionNodeResultOutput
- .error(member:) ⇒ CodeExecutionNodeResultOutput
-
.from_json(json_object:) ⇒ CodeExecutionNodeResultOutput
Deserialize a JSON object to an instance of CodeExecutionNodeResultOutput.
- .function_call(member:) ⇒ CodeExecutionNodeResultOutput
- .json(member:) ⇒ CodeExecutionNodeResultOutput
- .number(member:) ⇒ CodeExecutionNodeResultOutput
- .search_results(member:) ⇒ CodeExecutionNodeResultOutput
- .string(member:) ⇒ CodeExecutionNodeResultOutput
-
.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:) ⇒ CodeExecutionNodeResultOutput 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:) ⇒ CodeExecutionNodeResultOutput
22 23 24 25 26 27 |
# File 'lib/vellum_ai/types/code_execution_node_result_output.rb', line 22 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.
15 16 17 |
# File 'lib/vellum_ai/types/code_execution_node_result_output.rb', line 15 def discriminant @discriminant end |
#member ⇒ Object (readonly)
Returns the value of attribute member.
15 16 17 |
# File 'lib/vellum_ai/types/code_execution_node_result_output.rb', line 15 def member @member end |
Class Method Details
.array(member:) ⇒ CodeExecutionNodeResultOutput
158 159 160 |
# File 'lib/vellum_ai/types/code_execution_node_result_output.rb', line 158 def self.array(member:) new(member: member, discriminant: "ARRAY") end |
.chat_history(member:) ⇒ CodeExecutionNodeResultOutput
140 141 142 |
# File 'lib/vellum_ai/types/code_execution_node_result_output.rb', line 140 def self.chat_history(member:) new(member: member, discriminant: "CHAT_HISTORY") end |
.error(member:) ⇒ CodeExecutionNodeResultOutput
152 153 154 |
# File 'lib/vellum_ai/types/code_execution_node_result_output.rb', line 152 def self.error(member:) new(member: member, discriminant: "ERROR") end |
.from_json(json_object:) ⇒ CodeExecutionNodeResultOutput
Deserialize a JSON object to an instance of CodeExecutionNodeResultOutput
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/vellum_ai/types/code_execution_node_result_output.rb', line 33 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) member = case struct.type when "STRING" CodeExecutionNodeStringResult.from_json(json_object: json_object) when "NUMBER" CodeExecutionNodeNumberResult.from_json(json_object: json_object) when "JSON" CodeExecutionNodeJsonResult.from_json(json_object: json_object) when "CHAT_HISTORY" CodeExecutionNodeChatHistoryResult.from_json(json_object: json_object) when "SEARCH_RESULTS" CodeExecutionNodeSearchResultsResult.from_json(json_object: json_object) when "ERROR" CodeExecutionNodeErrorResult.from_json(json_object: json_object) when "ARRAY" CodeExecutionNodeArrayResult.from_json(json_object: json_object) when "FUNCTION_CALL" CodeExecutionNodeFunctionCallResult.from_json(json_object: json_object) else CodeExecutionNodeStringResult.from_json(json_object: json_object) end new(member: member, discriminant: struct.type) end |
.function_call(member:) ⇒ CodeExecutionNodeResultOutput
164 165 166 |
# File 'lib/vellum_ai/types/code_execution_node_result_output.rb', line 164 def self.function_call(member:) new(member: member, discriminant: "FUNCTION_CALL") end |
.json(member:) ⇒ CodeExecutionNodeResultOutput
134 135 136 |
# File 'lib/vellum_ai/types/code_execution_node_result_output.rb', line 134 def self.json(member:) new(member: member, discriminant: "JSON") end |
.number(member:) ⇒ CodeExecutionNodeResultOutput
128 129 130 |
# File 'lib/vellum_ai/types/code_execution_node_result_output.rb', line 128 def self.number(member:) new(member: member, discriminant: "NUMBER") end |
.search_results(member:) ⇒ CodeExecutionNodeResultOutput
146 147 148 |
# File 'lib/vellum_ai/types/code_execution_node_result_output.rb', line 146 def self.search_results(member:) new(member: member, discriminant: "SEARCH_RESULTS") end |
.string(member:) ⇒ CodeExecutionNodeResultOutput
122 123 124 |
# File 'lib/vellum_ai/types/code_execution_node_result_output.rb', line 122 def self.string(member:) new(member: member, discriminant: "STRING") 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.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/vellum_ai/types/code_execution_node_result_output.rb', line 89 def self.validate_raw(obj:) case obj.type when "STRING" CodeExecutionNodeStringResult.validate_raw(obj: obj) when "NUMBER" CodeExecutionNodeNumberResult.validate_raw(obj: obj) when "JSON" CodeExecutionNodeJsonResult.validate_raw(obj: obj) when "CHAT_HISTORY" CodeExecutionNodeChatHistoryResult.validate_raw(obj: obj) when "SEARCH_RESULTS" CodeExecutionNodeSearchResultsResult.validate_raw(obj: obj) when "ERROR" CodeExecutionNodeErrorResult.validate_raw(obj: obj) when "ARRAY" CodeExecutionNodeArrayResult.validate_raw(obj: obj) when "FUNCTION_CALL" CodeExecutionNodeFunctionCallResult.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.
116 117 118 |
# File 'lib/vellum_ai/types/code_execution_node_result_output.rb', line 116 def is_a?(obj) @member.is_a?(obj) end |
#kind_of? ⇒ Object
18 |
# File 'lib/vellum_ai/types/code_execution_node_result_output.rb', line 18 alias kind_of? is_a? |
#to_json(*_args) ⇒ JSON
For Union Types, to_json functionality is delegated to the wrapped member.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/vellum_ai/types/code_execution_node_result_output.rb', line 61 def to_json(*_args) case @discriminant when "STRING" { **@member.to_json, type: @discriminant }.to_json when "NUMBER" { **@member.to_json, type: @discriminant }.to_json when "JSON" { **@member.to_json, type: @discriminant }.to_json when "CHAT_HISTORY" { **@member.to_json, type: @discriminant }.to_json when "SEARCH_RESULTS" { **@member.to_json, type: @discriminant }.to_json when "ERROR" { **@member.to_json, type: @discriminant }.to_json when "ARRAY" { **@member.to_json, type: @discriminant }.to_json when "FUNCTION_CALL" { **@member.to_json, type: @discriminant }.to_json else { "type": @discriminant, value: @member }.to_json end @member.to_json end |