Class: Vellum::SearchNodeResultData

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(results_output_id:, results:, text_output_id:, text: nil, additional_properties: nil) ⇒ SearchNodeResultData

Parameters:

  • results_output_id (String)
  • results (Array<SearchResult>)

    The results of the search. Each result represents a chunk that matches the search query.

  • text_output_id (String)
  • text (String) (defaults to: nil)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/vellum_ai/types/search_node_result_data.rb', line 16

def initialize(results_output_id:, results:, text_output_id:, text: nil, additional_properties: nil)
  # @type [String]
  @results_output_id = results_output_id
  # @type [Array<SearchResult>] The results of the search. Each result represents a chunk that matches the search query.
  @results = results
  # @type [String]
  @text_output_id = text_output_id
  # @type [String]
  @text = text
  # @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.



8
9
10
# File 'lib/vellum_ai/types/search_node_result_data.rb', line 8

def additional_properties
  @additional_properties
end

#resultsObject (readonly)

Returns the value of attribute results.



8
9
10
# File 'lib/vellum_ai/types/search_node_result_data.rb', line 8

def results
  @results
end

#results_output_idObject (readonly)

Returns the value of attribute results_output_id.



8
9
10
# File 'lib/vellum_ai/types/search_node_result_data.rb', line 8

def results_output_id
  @results_output_id
end

#textObject (readonly)

Returns the value of attribute text.



8
9
10
# File 'lib/vellum_ai/types/search_node_result_data.rb', line 8

def text
  @text
end

#text_output_idObject (readonly)

Returns the value of attribute text_output_id.



8
9
10
# File 'lib/vellum_ai/types/search_node_result_data.rb', line 8

def text_output_id
  @text_output_id
end

Class Method Details

.from_json(json_object:) ⇒ SearchNodeResultData

Deserialize a JSON object to an instance of SearchNodeResultData

Parameters:

  • json_object (JSON)

Returns:



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/vellum_ai/types/search_node_result_data.rb', line 33

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  results_output_id = struct.results_output_id
  results = parsed_json["results"].map do |v|
    v = v.to_json
    SearchResult.from_json(json_object: v)
  end
  text_output_id = struct.text_output_id
  text = struct.text
  new(results_output_id: results_output_id, results: results, text_output_id: text_output_id, text: text,
      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)


63
64
65
66
67
68
# File 'lib/vellum_ai/types/search_node_result_data.rb', line 63

def self.validate_raw(obj:)
  obj.results_output_id.is_a?(String) != false || raise("Passed value for field obj.results_output_id is not the expected type, validation failed.")
  obj.results.is_a?(Array) != false || raise("Passed value for field obj.results is not the expected type, validation failed.")
  obj.text_output_id.is_a?(String) != false || raise("Passed value for field obj.text_output_id is not the expected type, validation failed.")
  obj.text&.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of SearchNodeResultData to a JSON object

Returns:

  • (JSON)


50
51
52
53
54
55
56
57
# File 'lib/vellum_ai/types/search_node_result_data.rb', line 50

def to_json(*_args)
  {
    "results_output_id": @results_output_id,
    "results": @results,
    "text_output_id": @text_output_id,
    "text": @text
  }.to_json
end