Class: Vellum::SearchRequestOptionsRequest

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(limit: nil, weights: nil, result_merging: nil, filters: nil, additional_properties: nil) ⇒ SearchRequestOptionsRequest

Parameters:

  • limit (Integer) (defaults to: nil)

    The maximum number of results to return.

  • weights (SearchWeightsRequest) (defaults to: nil)

    The weights to use for the search. Must add up to 1.0.

  • result_merging (SearchResultMergingRequest) (defaults to: nil)

    The configuration for merging results.

  • filters (SearchFiltersRequest) (defaults to: nil)

    The filters to apply to the search.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/vellum_ai/types/search_request_options_request.rb', line 18

def initialize(limit: nil, weights: nil, result_merging: nil, filters: nil, additional_properties: nil)
  # @type [Integer] The maximum number of results to return.
  @limit = limit
  # @type [SearchWeightsRequest] The weights to use for the search. Must add up to 1.0.
  @weights = weights
  # @type [SearchResultMergingRequest] The configuration for merging results.
  @result_merging = result_merging
  # @type [SearchFiltersRequest] The filters to apply to the search.
  @filters = filters
  # @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/search_request_options_request.rb', line 10

def additional_properties
  @additional_properties
end

#filtersObject (readonly)

Returns the value of attribute filters.



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

def filters
  @filters
end

#limitObject (readonly)

Returns the value of attribute limit.



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

def limit
  @limit
end

#result_mergingObject (readonly)

Returns the value of attribute result_merging.



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

def result_merging
  @result_merging
end

#weightsObject (readonly)

Returns the value of attribute weights.



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

def weights
  @weights
end

Class Method Details

.from_json(json_object:) ⇒ SearchRequestOptionsRequest

Deserialize a JSON object to an instance of SearchRequestOptionsRequest

Parameters:

  • json_object (JSON)

Returns:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/vellum_ai/types/search_request_options_request.rb', line 35

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  limit = struct.limit
  if parsed_json["weights"].nil?
    weights = nil
  else
    weights = parsed_json["weights"].to_json
    weights = SearchWeightsRequest.from_json(json_object: weights)
  end
  if parsed_json["result_merging"].nil?
    result_merging = nil
  else
    result_merging = parsed_json["result_merging"].to_json
    result_merging = SearchResultMergingRequest.from_json(json_object: result_merging)
  end
  if parsed_json["filters"].nil?
    filters = nil
  else
    filters = parsed_json["filters"].to_json
    filters = SearchFiltersRequest.from_json(json_object: filters)
  end
  new(limit: limit, weights: weights, result_merging: result_merging, filters: filters,
      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)


72
73
74
75
76
77
# File 'lib/vellum_ai/types/search_request_options_request.rb', line 72

def self.validate_raw(obj:)
  obj.limit&.is_a?(Integer) != false || raise("Passed value for field obj.limit is not the expected type, validation failed.")
  obj.weights.nil? || SearchWeightsRequest.validate_raw(obj: obj.weights)
  obj.result_merging.nil? || SearchResultMergingRequest.validate_raw(obj: obj.result_merging)
  obj.filters.nil? || SearchFiltersRequest.validate_raw(obj: obj.filters)
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of SearchRequestOptionsRequest to a JSON object

Returns:

  • (JSON)


64
65
66
# File 'lib/vellum_ai/types/search_request_options_request.rb', line 64

def to_json(*_args)
  { "limit": @limit, "weights": @weights, "result_merging": @result_merging, "filters": @filters }.to_json
end