Class: Vellum::SearchRequestOptionsRequest
- Inherits:
-
Object
- Object
- Vellum::SearchRequestOptionsRequest
- Defined in:
- lib/vellum_ai/types/search_request_options_request.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#result_merging ⇒ Object
readonly
Returns the value of attribute result_merging.
-
#weights ⇒ Object
readonly
Returns the value of attribute weights.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ SearchRequestOptionsRequest
Deserialize a JSON object to an instance of SearchRequestOptionsRequest.
-
.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(limit: nil, weights: nil, result_merging: nil, filters: nil, additional_properties: nil) ⇒ SearchRequestOptionsRequest constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of SearchRequestOptionsRequest to a JSON object.
Constructor Details
#initialize(limit: nil, weights: nil, result_merging: nil, filters: nil, additional_properties: nil) ⇒ SearchRequestOptionsRequest
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_properties ⇒ Object (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 |
#filters ⇒ Object (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 |
#limit ⇒ Object (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_merging ⇒ Object (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 |
#weights ⇒ Object (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
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.
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
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 |