Class: Vellum::WorkflowResultEventOutputDataSearchResults

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

Overview

A Search Results 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) ⇒ WorkflowResultEventOutputDataSearchResults

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 (Array<SearchResult>) (defaults to: nil)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/vellum_ai/types/workflow_result_event_output_data_search_results.rb', line 20

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 [Array<SearchResult>]
  @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.



10
11
12
# File 'lib/vellum_ai/types/workflow_result_event_output_data_search_results.rb', line 10

def additional_properties
  @additional_properties
end

#deltaObject (readonly)

Returns the value of attribute delta.



10
11
12
# File 'lib/vellum_ai/types/workflow_result_event_output_data_search_results.rb', line 10

def delta
  @delta
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/vellum_ai/types/workflow_result_event_output_data_search_results.rb', line 10

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/vellum_ai/types/workflow_result_event_output_data_search_results.rb', line 10

def name
  @name
end

#node_idObject (readonly)

Returns the value of attribute node_id.



10
11
12
# File 'lib/vellum_ai/types/workflow_result_event_output_data_search_results.rb', line 10

def node_id
  @node_id
end

#stateObject (readonly)

Returns the value of attribute state.



10
11
12
# File 'lib/vellum_ai/types/workflow_result_event_output_data_search_results.rb', line 10

def state
  @state
end

#valueObject (readonly)

Returns the value of attribute value.



10
11
12
# File 'lib/vellum_ai/types/workflow_result_event_output_data_search_results.rb', line 10

def value
  @value
end

Class Method Details

.from_json(json_object:) ⇒ WorkflowResultEventOutputDataSearchResults

Deserialize a JSON object to an instance of WorkflowResultEventOutputDataSearchResults

Parameters:

  • json_object (JSON)

Returns:



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/vellum_ai/types/workflow_result_event_output_data_search_results.rb', line 41

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 = parsed_json["value"].map do |v|
    v = v.to_json
    SearchResult.from_json(json_object: v)
  end
  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)


74
75
76
77
78
79
80
81
# File 'lib/vellum_ai/types/workflow_result_event_output_data_search_results.rb', line 74

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?(Array) != 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 WorkflowResultEventOutputDataSearchResults to a JSON object

Returns:

  • (JSON)


59
60
61
62
63
64
65
66
67
68
# File 'lib/vellum_ai/types/workflow_result_event_output_data_search_results.rb', line 59

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