Class: Vellum::WorkflowResultEvent
- Inherits:
-
Object
- Object
- Vellum::WorkflowResultEvent
- Defined in:
- lib/vellum_ai/types/workflow_result_event.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#inputs ⇒ Object
readonly
Returns the value of attribute inputs.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#outputs ⇒ Object
readonly
Returns the value of attribute outputs.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#ts ⇒ Object
readonly
Returns the value of attribute ts.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ WorkflowResultEvent
Deserialize a JSON object to an instance of WorkflowResultEvent.
-
.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(id:, state:, ts:, output: nil, error: nil, outputs: nil, inputs: nil, additional_properties: nil) ⇒ WorkflowResultEvent constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of WorkflowResultEvent to a JSON object.
Constructor Details
#initialize(id:, state:, ts:, output: nil, error: nil, outputs: nil, inputs: nil, additional_properties: nil) ⇒ WorkflowResultEvent
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/vellum_ai/types/workflow_result_event.rb', line 24 def initialize(id:, state:, ts:, output: nil, error: nil, outputs: nil, inputs: nil, additional_properties: nil) # @type [String] @id = id # @type [WORKFLOW_NODE_RESULT_EVENT_STATE] @state = state # @type [DateTime] @ts = ts # @type [WorkflowResultEventOutputData] @output = output # @type [WorkflowEventError] @error = error # @type [Array<WorkflowOutput>] @outputs = outputs # @type [Array<ExecutionVellumValue>] @inputs = inputs # @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.
13 14 15 |
# File 'lib/vellum_ai/types/workflow_result_event.rb', line 13 def additional_properties @additional_properties end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
13 14 15 |
# File 'lib/vellum_ai/types/workflow_result_event.rb', line 13 def error @error end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
13 14 15 |
# File 'lib/vellum_ai/types/workflow_result_event.rb', line 13 def id @id end |
#inputs ⇒ Object (readonly)
Returns the value of attribute inputs.
13 14 15 |
# File 'lib/vellum_ai/types/workflow_result_event.rb', line 13 def inputs @inputs end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
13 14 15 |
# File 'lib/vellum_ai/types/workflow_result_event.rb', line 13 def output @output end |
#outputs ⇒ Object (readonly)
Returns the value of attribute outputs.
13 14 15 |
# File 'lib/vellum_ai/types/workflow_result_event.rb', line 13 def outputs @outputs end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
13 14 15 |
# File 'lib/vellum_ai/types/workflow_result_event.rb', line 13 def state @state end |
#ts ⇒ Object (readonly)
Returns the value of attribute ts.
13 14 15 |
# File 'lib/vellum_ai/types/workflow_result_event.rb', line 13 def ts @ts end |
Class Method Details
.from_json(json_object:) ⇒ WorkflowResultEvent
Deserialize a JSON object to an instance of WorkflowResultEvent
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/vellum_ai/types/workflow_result_event.rb', line 47 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) id = struct.id state = WORKFLOW_NODE_RESULT_EVENT_STATE.key(parsed_json["state"]) || parsed_json["state"] ts = DateTime.parse(parsed_json["ts"]) if parsed_json["output"].nil? output = nil else output = parsed_json["output"].to_json output = WorkflowResultEventOutputData.from_json(json_object: output) end if parsed_json["error"].nil? error = nil else error = parsed_json["error"].to_json error = WorkflowEventError.from_json(json_object: error) end outputs = parsed_json["outputs"].map do |v| v = v.to_json WorkflowOutput.from_json(json_object: v) end inputs = parsed_json["inputs"].map do |v| v = v.to_json ExecutionVellumValue.from_json(json_object: v) end new(id: id, state: state, ts: ts, output: output, error: error, outputs: outputs, inputs: inputs, 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.
96 97 98 99 100 101 102 103 104 |
# File 'lib/vellum_ai/types/workflow_result_event.rb', line 96 def self.validate_raw(obj:) obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") obj.state.is_a?(WORKFLOW_NODE_RESULT_EVENT_STATE) != false || raise("Passed value for field obj.state is not the expected type, validation failed.") obj.ts.is_a?(DateTime) != false || raise("Passed value for field obj.ts is not the expected type, validation failed.") obj.output.nil? || WorkflowResultEventOutputData.validate_raw(obj: obj.output) obj.error.nil? || WorkflowEventError.validate_raw(obj: obj.error) obj.outputs&.is_a?(Array) != false || raise("Passed value for field obj.outputs is not the expected type, validation failed.") obj.inputs&.is_a?(Array) != false || raise("Passed value for field obj.inputs is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of WorkflowResultEvent to a JSON object
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/vellum_ai/types/workflow_result_event.rb', line 80 def to_json(*_args) { "id": @id, "state": WORKFLOW_NODE_RESULT_EVENT_STATE[@state] || @state, "ts": @ts, "output": @output, "error": @error, "outputs": @outputs, "inputs": @inputs }.to_json end |