Class: Vellum::WorkflowResultEventOutputDataNumber

Inherits:
Object
  • Object
show all
Defined in:
lib/vellum_ai/types/workflow_result_event_output_data_number.rb

Overview

A number output streamed from a Workflow execution.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, state:, node_id:, id: nil, delta: nil, value: nil, additional_properties: nil) ⇒ WorkflowResultEventOutputDataNumber

Parameters:

  • id (String) (defaults to: nil)
  • name (String)
  • state (WORKFLOW_NODE_RESULT_EVENT_STATE)
  • node_id (String)
  • delta (String) (defaults to: nil)

    The newly output string value. Only relevant for string outputs with a state of STREAMING.

  • value (Float) (defaults to: nil)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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_number.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 [Float]
  @value = value
  # @type [OpenStruct] Additional properties unmapped to the current class definition
  @additional_properties = additional_properties
end

Instance Attribute Details

#additional_propertiesObject (readonly)

Returns the value of attribute additional_properties.



9
10
11
# File 'lib/vellum_ai/types/workflow_result_event_output_data_number.rb', line 9

def additional_properties
  @additional_properties
end

#deltaObject (readonly)

Returns the value of attribute delta.



9
10
11
# File 'lib/vellum_ai/types/workflow_result_event_output_data_number.rb', line 9

def delta
  @delta
end

#idObject (readonly)

Returns the value of attribute id.



9
10
11
# File 'lib/vellum_ai/types/workflow_result_event_output_data_number.rb', line 9

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/vellum_ai/types/workflow_result_event_output_data_number.rb', line 9

def name
  @name
end

#node_idObject (readonly)

Returns the value of attribute node_id.



9
10
11
# File 'lib/vellum_ai/types/workflow_result_event_output_data_number.rb', line 9

def node_id
  @node_id
end

#stateObject (readonly)

Returns the value of attribute state.



9
10
11
# File 'lib/vellum_ai/types/workflow_result_event_output_data_number.rb', line 9

def state
  @state
end

#valueObject (readonly)

Returns the value of attribute value.



9
10
11
# File 'lib/vellum_ai/types/workflow_result_event_output_data_number.rb', line 9

def value
  @value
end

Class Method Details

.from_json(json_object:) ⇒ WorkflowResultEventOutputDataNumber

Deserialize a JSON object to an instance of WorkflowResultEventOutputDataNumber

Parameters:

  • json_object (JSON)

Returns:



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/vellum_ai/types/workflow_result_event_output_data_number.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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


70
71
72
73
74
75
76
77
# File 'lib/vellum_ai/types/workflow_result_event_output_data_number.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?(Float) != 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 WorkflowResultEventOutputDataNumber to a JSON object

Returns:

  • (JSON)


55
56
57
58
59
60
61
62
63
64
# File 'lib/vellum_ai/types/workflow_result_event_output_data_number.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