Class: Vellum::WorkflowResultEventOutputDataJson
- Inherits:
-
Object
- Object
- Vellum::WorkflowResultEventOutputDataJson
- Defined in:
- lib/vellum_ai/types/workflow_result_event_output_data_json.rb
Overview
A JSON output streamed from a Workflow execution.
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#delta ⇒ Object
readonly
Returns the value of attribute delta.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#node_id ⇒ Object
readonly
Returns the value of attribute node_id.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ WorkflowResultEventOutputDataJson
Deserialize a JSON object to an instance of WorkflowResultEventOutputDataJson.
-
.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(name:, state:, node_id:, id: nil, delta: nil, value: nil, additional_properties: nil) ⇒ WorkflowResultEventOutputDataJson constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of WorkflowResultEventOutputDataJson to a JSON object.
Constructor Details
#initialize(name:, state:, node_id:, id: nil, delta: nil, value: nil, additional_properties: nil) ⇒ WorkflowResultEventOutputDataJson
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/vellum_ai/types/workflow_result_event_output_data_json.rb', line 19 def initialize(name:, state:, node_id:, id: nil, delta: nil, value: nil, additional_properties: nil) # @type [String] @id = id # @type [String] @name = name # @type [WORKFLOW_NODE_RESULT_EVENT_STATE] @state = state # @type [String] @node_id = node_id # @type [String] The newly output string value. Only relevant for string outputs with a state of STREAMING. @delta = delta # @type [Hash{String => String}] @value = value # @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.
9 10 11 |
# File 'lib/vellum_ai/types/workflow_result_event_output_data_json.rb', line 9 def additional_properties @additional_properties end |
#delta ⇒ Object (readonly)
Returns the value of attribute delta.
9 10 11 |
# File 'lib/vellum_ai/types/workflow_result_event_output_data_json.rb', line 9 def delta @delta end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
9 10 11 |
# File 'lib/vellum_ai/types/workflow_result_event_output_data_json.rb', line 9 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/vellum_ai/types/workflow_result_event_output_data_json.rb', line 9 def name @name end |
#node_id ⇒ Object (readonly)
Returns the value of attribute node_id.
9 10 11 |
# File 'lib/vellum_ai/types/workflow_result_event_output_data_json.rb', line 9 def node_id @node_id end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
9 10 11 |
# File 'lib/vellum_ai/types/workflow_result_event_output_data_json.rb', line 9 def state @state end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
9 10 11 |
# File 'lib/vellum_ai/types/workflow_result_event_output_data_json.rb', line 9 def value @value end |
Class Method Details
.from_json(json_object:) ⇒ WorkflowResultEventOutputDataJson
Deserialize a JSON object to an instance of WorkflowResultEventOutputDataJson
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/vellum_ai/types/workflow_result_event_output_data_json.rb', line 40 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) id = struct.id name = struct.name state = WORKFLOW_NODE_RESULT_EVENT_STATE.key(parsed_json["state"]) || parsed_json["state"] node_id = struct.node_id delta = struct.delta value = struct.value new(id: id, name: name, state: state, node_id: node_id, delta: delta, value: value, 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.
70 71 72 73 74 75 76 77 |
# File 'lib/vellum_ai/types/workflow_result_event_output_data_json.rb', line 70 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.name.is_a?(String) != false || raise("Passed value for field obj.name 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.node_id.is_a?(String) != false || raise("Passed value for field obj.node_id is not the expected type, validation failed.") obj.delta&.is_a?(String) != false || raise("Passed value for field obj.delta is not the expected type, validation failed.") obj.value&.is_a?(Hash) != false || raise("Passed value for field obj.value is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of WorkflowResultEventOutputDataJson to a JSON object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/vellum_ai/types/workflow_result_event_output_data_json.rb', line 55 def to_json(*_args) { "id": @id, "name": @name, "state": WORKFLOW_NODE_RESULT_EVENT_STATE[@state] || @state, "node_id": @node_id, "delta": @delta, "value": @value }.to_json end |