chromadb-experimental 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. checksums.yaml +7 -0
  2. data/lib/chromadb/admin_client.rb +6 -0
  3. data/lib/chromadb/client.rb +317 -0
  4. data/lib/chromadb/collection.rb +573 -0
  5. data/lib/chromadb/embedding_functions/chroma_bm25.rb +459 -0
  6. data/lib/chromadb/embedding_functions/chroma_cloud_qwen.rb +139 -0
  7. data/lib/chromadb/embedding_functions/chroma_cloud_splade.rb +121 -0
  8. data/lib/chromadb/embedding_functions.rb +121 -0
  9. data/lib/chromadb/errors.rb +120 -0
  10. data/lib/chromadb/http_client.rb +142 -0
  11. data/lib/chromadb/openapi/lib/chromadb/api/default_api.rb +2349 -0
  12. data/lib/chromadb/openapi/lib/chromadb/api_client.rb +392 -0
  13. data/lib/chromadb/openapi/lib/chromadb/api_error.rb +58 -0
  14. data/lib/chromadb/openapi/lib/chromadb/configuration.rb +295 -0
  15. data/lib/chromadb/openapi/lib/chromadb/models/add_collection_records_payload.rb +260 -0
  16. data/lib/chromadb/openapi/lib/chromadb/models/attach_function_request.rb +250 -0
  17. data/lib/chromadb/openapi/lib/chromadb/models/attach_function_response.rb +235 -0
  18. data/lib/chromadb/openapi/lib/chromadb/models/attached_function_api_response.rb +361 -0
  19. data/lib/chromadb/openapi/lib/chromadb/models/attached_function_info.rb +240 -0
  20. data/lib/chromadb/openapi/lib/chromadb/models/bool_inverted_index_type.rb +229 -0
  21. data/lib/chromadb/openapi/lib/chromadb/models/bool_value_type.rb +221 -0
  22. data/lib/chromadb/openapi/lib/chromadb/models/checklist_response.rb +245 -0
  23. data/lib/chromadb/openapi/lib/chromadb/models/collection.rb +315 -0
  24. data/lib/chromadb/openapi/lib/chromadb/models/collection_configuration.rb +240 -0
  25. data/lib/chromadb/openapi/lib/chromadb/models/create_collection_payload.rb +260 -0
  26. data/lib/chromadb/openapi/lib/chromadb/models/create_database_payload.rb +220 -0
  27. data/lib/chromadb/openapi/lib/chromadb/models/create_tenant_payload.rb +220 -0
  28. data/lib/chromadb/openapi/lib/chromadb/models/database.rb +240 -0
  29. data/lib/chromadb/openapi/lib/chromadb/models/detach_function_request.rb +221 -0
  30. data/lib/chromadb/openapi/lib/chromadb/models/detach_function_response.rb +220 -0
  31. data/lib/chromadb/openapi/lib/chromadb/models/embedding_function_new_configuration.rb +230 -0
  32. data/lib/chromadb/openapi/lib/chromadb/models/error_response.rb +230 -0
  33. data/lib/chromadb/openapi/lib/chromadb/models/float_inverted_index_type.rb +229 -0
  34. data/lib/chromadb/openapi/lib/chromadb/models/float_list_value_type.rb +221 -0
  35. data/lib/chromadb/openapi/lib/chromadb/models/float_value_type.rb +221 -0
  36. data/lib/chromadb/openapi/lib/chromadb/models/fork_collection_payload.rb +220 -0
  37. data/lib/chromadb/openapi/lib/chromadb/models/fts_index_type.rb +229 -0
  38. data/lib/chromadb/openapi/lib/chromadb/models/get_attached_function_response.rb +224 -0
  39. data/lib/chromadb/openapi/lib/chromadb/models/get_response.rb +270 -0
  40. data/lib/chromadb/openapi/lib/chromadb/models/get_tenant_response.rb +230 -0
  41. data/lib/chromadb/openapi/lib/chromadb/models/get_user_identity_response.rb +246 -0
  42. data/lib/chromadb/openapi/lib/chromadb/models/heartbeat_response.rb +235 -0
  43. data/lib/chromadb/openapi/lib/chromadb/models/hnsw_configuration.rb +330 -0
  44. data/lib/chromadb/openapi/lib/chromadb/models/hnsw_index_config.rb +371 -0
  45. data/lib/chromadb/openapi/lib/chromadb/models/include.rb +210 -0
  46. data/lib/chromadb/openapi/lib/chromadb/models/int_inverted_index_type.rb +229 -0
  47. data/lib/chromadb/openapi/lib/chromadb/models/int_value_type.rb +221 -0
  48. data/lib/chromadb/openapi/lib/chromadb/models/query_response.rb +280 -0
  49. data/lib/chromadb/openapi/lib/chromadb/models/raw_where_fields.rb +230 -0
  50. data/lib/chromadb/openapi/lib/chromadb/models/schema.rb +258 -0
  51. data/lib/chromadb/openapi/lib/chromadb/models/search_payload.rb +256 -0
  52. data/lib/chromadb/openapi/lib/chromadb/models/search_payload_filter.rb +230 -0
  53. data/lib/chromadb/openapi/lib/chromadb/models/search_payload_group_by.rb +230 -0
  54. data/lib/chromadb/openapi/lib/chromadb/models/search_payload_limit.rb +230 -0
  55. data/lib/chromadb/openapi/lib/chromadb/models/search_payload_select.rb +220 -0
  56. data/lib/chromadb/openapi/lib/chromadb/models/search_request_payload.rb +220 -0
  57. data/lib/chromadb/openapi/lib/chromadb/models/search_response.rb +270 -0
  58. data/lib/chromadb/openapi/lib/chromadb/models/space.rb +210 -0
  59. data/lib/chromadb/openapi/lib/chromadb/models/spann_configuration.rb +420 -0
  60. data/lib/chromadb/openapi/lib/chromadb/models/spann_index_config.rb +536 -0
  61. data/lib/chromadb/openapi/lib/chromadb/models/sparse_vector.rb +244 -0
  62. data/lib/chromadb/openapi/lib/chromadb/models/sparse_vector_index_config.rb +242 -0
  63. data/lib/chromadb/openapi/lib/chromadb/models/sparse_vector_index_type.rb +234 -0
  64. data/lib/chromadb/openapi/lib/chromadb/models/sparse_vector_value_type.rb +221 -0
  65. data/lib/chromadb/openapi/lib/chromadb/models/string_inverted_index_type.rb +229 -0
  66. data/lib/chromadb/openapi/lib/chromadb/models/string_value_type.rb +231 -0
  67. data/lib/chromadb/openapi/lib/chromadb/models/update_collection_configuration.rb +240 -0
  68. data/lib/chromadb/openapi/lib/chromadb/models/update_collection_payload.rb +240 -0
  69. data/lib/chromadb/openapi/lib/chromadb/models/update_collection_records_payload.rb +260 -0
  70. data/lib/chromadb/openapi/lib/chromadb/models/update_hnsw_configuration.rb +345 -0
  71. data/lib/chromadb/openapi/lib/chromadb/models/update_spann_configuration.rb +260 -0
  72. data/lib/chromadb/openapi/lib/chromadb/models/update_tenant_payload.rb +220 -0
  73. data/lib/chromadb/openapi/lib/chromadb/models/upsert_collection_records_payload.rb +260 -0
  74. data/lib/chromadb/openapi/lib/chromadb/models/value_types.rb +271 -0
  75. data/lib/chromadb/openapi/lib/chromadb/models/vector_index_config.rb +261 -0
  76. data/lib/chromadb/openapi/lib/chromadb/models/vector_index_type.rb +234 -0
  77. data/lib/chromadb/openapi/lib/chromadb/version.rb +15 -0
  78. data/lib/chromadb/openapi/lib/chromadb.rb +102 -0
  79. data/lib/chromadb/openapi.rb +6 -0
  80. data/lib/chromadb/schema.rb +744 -0
  81. data/lib/chromadb/schemas/chroma-cloud-qwen.json +61 -0
  82. data/lib/chromadb/schemas/chroma-cloud-splade.json +31 -0
  83. data/lib/chromadb/schemas/chroma_bm25.json +37 -0
  84. data/lib/chromadb/search/key.rb +94 -0
  85. data/lib/chromadb/search/limit.rb +41 -0
  86. data/lib/chromadb/search/rank.rb +425 -0
  87. data/lib/chromadb/search/search.rb +73 -0
  88. data/lib/chromadb/search/select.rb +54 -0
  89. data/lib/chromadb/search/where.rb +157 -0
  90. data/lib/chromadb/search.rb +8 -0
  91. data/lib/chromadb/types/results.rb +96 -0
  92. data/lib/chromadb/types/sparse_vector.rb +86 -0
  93. data/lib/chromadb/types/validation.rb +519 -0
  94. data/lib/chromadb/types.rb +13 -0
  95. data/lib/chromadb/version.rb +5 -0
  96. data/lib/chromadb.rb +15 -0
  97. metadata +233 -0
@@ -0,0 +1,210 @@
1
+ =begin
2
+ #chroma-frontend
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.6.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Chromadb
17
+ class Space
18
+ # Attribute mapping from ruby-style variable name to JSON key.
19
+ def self.attribute_map
20
+ {
21
+ }
22
+ end
23
+
24
+ # Returns all the JSON keys this model knows about
25
+ def self.acceptable_attributes
26
+ attribute_map.values
27
+ end
28
+
29
+ # Attribute type mapping.
30
+ def self.openapi_types
31
+ {
32
+ }
33
+ end
34
+
35
+ # List of attributes with nullable: true
36
+ def self.openapi_nullable
37
+ Set.new([
38
+ ])
39
+ end
40
+
41
+ # Initializes the object
42
+ # @param [Hash] attributes Model attributes in the form of hash
43
+ def initialize(attributes = {})
44
+ if (!attributes.is_a?(Hash))
45
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Chromadb::Space` initialize method"
46
+ end
47
+
48
+ # check to see if the attribute exists and convert string to symbol for hash key
49
+ attributes = attributes.each_with_object({}) { |(k, v), h|
50
+ if (!self.class.attribute_map.key?(k.to_sym))
51
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Chromadb::Space`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
52
+ end
53
+ h[k.to_sym] = v
54
+ }
55
+ end
56
+
57
+ # Show invalid properties with the reasons. Usually used together with valid?
58
+ # @return Array for valid properties with the reasons
59
+ def list_invalid_properties
60
+ invalid_properties = Array.new
61
+ invalid_properties
62
+ end
63
+
64
+ # Check to see if the all the properties in the model are valid
65
+ # @return true if the model is valid
66
+ def valid?
67
+ true
68
+ end
69
+
70
+ # Checks equality by comparing each attribute.
71
+ # @param [Object] Object to be compared
72
+ def ==(o)
73
+ return true if self.equal?(o)
74
+ self.class == o.class
75
+ end
76
+
77
+ # @see the `==` method
78
+ # @param [Object] Object to be compared
79
+ def eql?(o)
80
+ self == o
81
+ end
82
+
83
+ # Calculates hash code according to all attributes.
84
+ # @return [Integer] Hash code
85
+ def hash
86
+ [].hash
87
+ end
88
+
89
+ # Builds the object from hash
90
+ # @param [Hash] attributes Model attributes in the form of hash
91
+ # @return [Object] Returns the model itself
92
+ def self.build_from_hash(attributes)
93
+ new.build_from_hash(attributes)
94
+ end
95
+
96
+ # Builds the object from hash
97
+ # @param [Hash] attributes Model attributes in the form of hash
98
+ # @return [Object] Returns the model itself
99
+ def build_from_hash(attributes)
100
+ return nil unless attributes.is_a?(Hash)
101
+ attributes = attributes.transform_keys(&:to_sym)
102
+ self.class.openapi_types.each_pair do |key, type|
103
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
104
+ self.send("#{key}=", nil)
105
+ elsif type =~ /\AArray<(.*)>/i
106
+ # check to ensure the input is an array given that the attribute
107
+ # is documented as an array but the input is not
108
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
109
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
110
+ end
111
+ elsif !attributes[self.class.attribute_map[key]].nil?
112
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
113
+ end
114
+ end
115
+
116
+ self
117
+ end
118
+
119
+ # Deserializes the data based on type
120
+ # @param string type Data type
121
+ # @param string value Value to be deserialized
122
+ # @return [Object] Deserialized data
123
+ def _deserialize(type, value)
124
+ case type.to_sym
125
+ when :Time
126
+ Time.parse(value)
127
+ when :Date
128
+ Date.parse(value)
129
+ when :String
130
+ value.to_s
131
+ when :Integer
132
+ value.to_i
133
+ when :Float
134
+ value.to_f
135
+ when :Boolean
136
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
137
+ true
138
+ else
139
+ false
140
+ end
141
+ when :Object
142
+ # generic object (usually a Hash), return directly
143
+ value
144
+ when /\AArray<(?<inner_type>.+)>\z/
145
+ inner_type = Regexp.last_match[:inner_type]
146
+ value.map { |v| _deserialize(inner_type, v) }
147
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
148
+ k_type = Regexp.last_match[:k_type]
149
+ v_type = Regexp.last_match[:v_type]
150
+ {}.tap do |hash|
151
+ value.each do |k, v|
152
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
153
+ end
154
+ end
155
+ else # model
156
+ # models (e.g. Pet) or oneOf
157
+ klass = Chromadb.const_get(type)
158
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
159
+ end
160
+ end
161
+
162
+ # Returns the string representation of the object
163
+ # @return [String] String presentation of the object
164
+ def to_s
165
+ to_hash.to_s
166
+ end
167
+
168
+ # to_body is an alias to to_hash (backward compatibility)
169
+ # @return [Hash] Returns the object in the form of hash
170
+ def to_body
171
+ to_hash
172
+ end
173
+
174
+ # Returns the object in the form of hash
175
+ # @return [Hash] Returns the object in the form of hash
176
+ def to_hash
177
+ hash = {}
178
+ self.class.attribute_map.each_pair do |attr, param|
179
+ value = self.send(attr)
180
+ if value.nil?
181
+ is_nullable = self.class.openapi_nullable.include?(attr)
182
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
183
+ end
184
+
185
+ hash[param] = _to_hash(value)
186
+ end
187
+ hash
188
+ end
189
+
190
+ # Outputs non-array value in the form of hash
191
+ # For object, use to_hash. Otherwise, just return the value
192
+ # @param [Object] value Any valid value
193
+ # @return [Hash] Returns the value in the form of hash
194
+ def _to_hash(value)
195
+ if value.is_a?(Array)
196
+ value.compact.map { |v| _to_hash(v) }
197
+ elsif value.is_a?(Hash)
198
+ {}.tap do |hash|
199
+ value.each { |k, v| hash[k] = _to_hash(v) }
200
+ end
201
+ elsif value.respond_to? :to_hash
202
+ value.to_hash
203
+ else
204
+ value
205
+ end
206
+ end
207
+
208
+ end
209
+
210
+ end
@@ -0,0 +1,420 @@
1
+ =begin
2
+ #chroma-frontend
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.6.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Chromadb
17
+ class SpannConfiguration
18
+ attr_accessor :ef_construction
19
+
20
+ attr_accessor :ef_search
21
+
22
+ attr_accessor :max_neighbors
23
+
24
+ attr_accessor :merge_threshold
25
+
26
+ attr_accessor :reassign_neighbor_count
27
+
28
+ attr_accessor :search_nprobe
29
+
30
+ attr_accessor :space
31
+
32
+ attr_accessor :split_threshold
33
+
34
+ attr_accessor :write_nprobe
35
+
36
+ # Attribute mapping from ruby-style variable name to JSON key.
37
+ def self.attribute_map
38
+ {
39
+ :'ef_construction' => :'ef_construction',
40
+ :'ef_search' => :'ef_search',
41
+ :'max_neighbors' => :'max_neighbors',
42
+ :'merge_threshold' => :'merge_threshold',
43
+ :'reassign_neighbor_count' => :'reassign_neighbor_count',
44
+ :'search_nprobe' => :'search_nprobe',
45
+ :'space' => :'space',
46
+ :'split_threshold' => :'split_threshold',
47
+ :'write_nprobe' => :'write_nprobe'
48
+ }
49
+ end
50
+
51
+ # Returns all the JSON keys this model knows about
52
+ def self.acceptable_attributes
53
+ attribute_map.values
54
+ end
55
+
56
+ # Attribute type mapping.
57
+ def self.openapi_types
58
+ {
59
+ :'ef_construction' => :'Object',
60
+ :'ef_search' => :'Object',
61
+ :'max_neighbors' => :'Object',
62
+ :'merge_threshold' => :'Object',
63
+ :'reassign_neighbor_count' => :'Object',
64
+ :'search_nprobe' => :'Object',
65
+ :'space' => :'Object',
66
+ :'split_threshold' => :'Object',
67
+ :'write_nprobe' => :'Object'
68
+ }
69
+ end
70
+
71
+ # List of attributes with nullable: true
72
+ def self.openapi_nullable
73
+ Set.new([
74
+ :'ef_construction',
75
+ :'ef_search',
76
+ :'max_neighbors',
77
+ :'merge_threshold',
78
+ :'reassign_neighbor_count',
79
+ :'search_nprobe',
80
+ :'space',
81
+ :'split_threshold',
82
+ :'write_nprobe'
83
+ ])
84
+ end
85
+
86
+ # Initializes the object
87
+ # @param [Hash] attributes Model attributes in the form of hash
88
+ def initialize(attributes = {})
89
+ if (!attributes.is_a?(Hash))
90
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Chromadb::SpannConfiguration` initialize method"
91
+ end
92
+
93
+ # check to see if the attribute exists and convert string to symbol for hash key
94
+ attributes = attributes.each_with_object({}) { |(k, v), h|
95
+ if (!self.class.attribute_map.key?(k.to_sym))
96
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Chromadb::SpannConfiguration`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
97
+ end
98
+ h[k.to_sym] = v
99
+ }
100
+
101
+ if attributes.key?(:'ef_construction')
102
+ self.ef_construction = attributes[:'ef_construction']
103
+ end
104
+
105
+ if attributes.key?(:'ef_search')
106
+ self.ef_search = attributes[:'ef_search']
107
+ end
108
+
109
+ if attributes.key?(:'max_neighbors')
110
+ self.max_neighbors = attributes[:'max_neighbors']
111
+ end
112
+
113
+ if attributes.key?(:'merge_threshold')
114
+ self.merge_threshold = attributes[:'merge_threshold']
115
+ end
116
+
117
+ if attributes.key?(:'reassign_neighbor_count')
118
+ self.reassign_neighbor_count = attributes[:'reassign_neighbor_count']
119
+ end
120
+
121
+ if attributes.key?(:'search_nprobe')
122
+ self.search_nprobe = attributes[:'search_nprobe']
123
+ end
124
+
125
+ if attributes.key?(:'space')
126
+ self.space = attributes[:'space']
127
+ end
128
+
129
+ if attributes.key?(:'split_threshold')
130
+ self.split_threshold = attributes[:'split_threshold']
131
+ end
132
+
133
+ if attributes.key?(:'write_nprobe')
134
+ self.write_nprobe = attributes[:'write_nprobe']
135
+ end
136
+ end
137
+
138
+ # Show invalid properties with the reasons. Usually used together with valid?
139
+ # @return Array for valid properties with the reasons
140
+ def list_invalid_properties
141
+ invalid_properties = Array.new
142
+ if !@ef_construction.nil? && @ef_construction < 0
143
+ invalid_properties.push('invalid value for "ef_construction", must be greater than or equal to 0.')
144
+ end
145
+
146
+ if !@ef_search.nil? && @ef_search < 0
147
+ invalid_properties.push('invalid value for "ef_search", must be greater than or equal to 0.')
148
+ end
149
+
150
+ if !@max_neighbors.nil? && @max_neighbors < 0
151
+ invalid_properties.push('invalid value for "max_neighbors", must be greater than or equal to 0.')
152
+ end
153
+
154
+ if !@merge_threshold.nil? && @merge_threshold < 0
155
+ invalid_properties.push('invalid value for "merge_threshold", must be greater than or equal to 0.')
156
+ end
157
+
158
+ if !@reassign_neighbor_count.nil? && @reassign_neighbor_count < 0
159
+ invalid_properties.push('invalid value for "reassign_neighbor_count", must be greater than or equal to 0.')
160
+ end
161
+
162
+ if !@search_nprobe.nil? && @search_nprobe < 0
163
+ invalid_properties.push('invalid value for "search_nprobe", must be greater than or equal to 0.')
164
+ end
165
+
166
+ if !@split_threshold.nil? && @split_threshold < 0
167
+ invalid_properties.push('invalid value for "split_threshold", must be greater than or equal to 0.')
168
+ end
169
+
170
+ if !@write_nprobe.nil? && @write_nprobe < 0
171
+ invalid_properties.push('invalid value for "write_nprobe", must be greater than or equal to 0.')
172
+ end
173
+
174
+ invalid_properties
175
+ end
176
+
177
+ # Check to see if the all the properties in the model are valid
178
+ # @return true if the model is valid
179
+ def valid?
180
+ return false if !@ef_construction.nil? && @ef_construction < 0
181
+ return false if !@ef_search.nil? && @ef_search < 0
182
+ return false if !@max_neighbors.nil? && @max_neighbors < 0
183
+ return false if !@merge_threshold.nil? && @merge_threshold < 0
184
+ return false if !@reassign_neighbor_count.nil? && @reassign_neighbor_count < 0
185
+ return false if !@search_nprobe.nil? && @search_nprobe < 0
186
+ return false if !@split_threshold.nil? && @split_threshold < 0
187
+ return false if !@write_nprobe.nil? && @write_nprobe < 0
188
+ true
189
+ end
190
+
191
+ # Custom attribute writer method with validation
192
+ # @param [Object] ef_construction Value to be assigned
193
+ def ef_construction=(ef_construction)
194
+ if !ef_construction.nil? && ef_construction < 0
195
+ fail ArgumentError, 'invalid value for "ef_construction", must be greater than or equal to 0.'
196
+ end
197
+
198
+ @ef_construction = ef_construction
199
+ end
200
+
201
+ # Custom attribute writer method with validation
202
+ # @param [Object] ef_search Value to be assigned
203
+ def ef_search=(ef_search)
204
+ if !ef_search.nil? && ef_search < 0
205
+ fail ArgumentError, 'invalid value for "ef_search", must be greater than or equal to 0.'
206
+ end
207
+
208
+ @ef_search = ef_search
209
+ end
210
+
211
+ # Custom attribute writer method with validation
212
+ # @param [Object] max_neighbors Value to be assigned
213
+ def max_neighbors=(max_neighbors)
214
+ if !max_neighbors.nil? && max_neighbors < 0
215
+ fail ArgumentError, 'invalid value for "max_neighbors", must be greater than or equal to 0.'
216
+ end
217
+
218
+ @max_neighbors = max_neighbors
219
+ end
220
+
221
+ # Custom attribute writer method with validation
222
+ # @param [Object] merge_threshold Value to be assigned
223
+ def merge_threshold=(merge_threshold)
224
+ if !merge_threshold.nil? && merge_threshold < 0
225
+ fail ArgumentError, 'invalid value for "merge_threshold", must be greater than or equal to 0.'
226
+ end
227
+
228
+ @merge_threshold = merge_threshold
229
+ end
230
+
231
+ # Custom attribute writer method with validation
232
+ # @param [Object] reassign_neighbor_count Value to be assigned
233
+ def reassign_neighbor_count=(reassign_neighbor_count)
234
+ if !reassign_neighbor_count.nil? && reassign_neighbor_count < 0
235
+ fail ArgumentError, 'invalid value for "reassign_neighbor_count", must be greater than or equal to 0.'
236
+ end
237
+
238
+ @reassign_neighbor_count = reassign_neighbor_count
239
+ end
240
+
241
+ # Custom attribute writer method with validation
242
+ # @param [Object] search_nprobe Value to be assigned
243
+ def search_nprobe=(search_nprobe)
244
+ if !search_nprobe.nil? && search_nprobe < 0
245
+ fail ArgumentError, 'invalid value for "search_nprobe", must be greater than or equal to 0.'
246
+ end
247
+
248
+ @search_nprobe = search_nprobe
249
+ end
250
+
251
+ # Custom attribute writer method with validation
252
+ # @param [Object] split_threshold Value to be assigned
253
+ def split_threshold=(split_threshold)
254
+ if !split_threshold.nil? && split_threshold < 0
255
+ fail ArgumentError, 'invalid value for "split_threshold", must be greater than or equal to 0.'
256
+ end
257
+
258
+ @split_threshold = split_threshold
259
+ end
260
+
261
+ # Custom attribute writer method with validation
262
+ # @param [Object] write_nprobe Value to be assigned
263
+ def write_nprobe=(write_nprobe)
264
+ if !write_nprobe.nil? && write_nprobe < 0
265
+ fail ArgumentError, 'invalid value for "write_nprobe", must be greater than or equal to 0.'
266
+ end
267
+
268
+ @write_nprobe = write_nprobe
269
+ end
270
+
271
+ # Checks equality by comparing each attribute.
272
+ # @param [Object] Object to be compared
273
+ def ==(o)
274
+ return true if self.equal?(o)
275
+ self.class == o.class &&
276
+ ef_construction == o.ef_construction &&
277
+ ef_search == o.ef_search &&
278
+ max_neighbors == o.max_neighbors &&
279
+ merge_threshold == o.merge_threshold &&
280
+ reassign_neighbor_count == o.reassign_neighbor_count &&
281
+ search_nprobe == o.search_nprobe &&
282
+ space == o.space &&
283
+ split_threshold == o.split_threshold &&
284
+ write_nprobe == o.write_nprobe
285
+ end
286
+
287
+ # @see the `==` method
288
+ # @param [Object] Object to be compared
289
+ def eql?(o)
290
+ self == o
291
+ end
292
+
293
+ # Calculates hash code according to all attributes.
294
+ # @return [Integer] Hash code
295
+ def hash
296
+ [ef_construction, ef_search, max_neighbors, merge_threshold, reassign_neighbor_count, search_nprobe, space, split_threshold, write_nprobe].hash
297
+ end
298
+
299
+ # Builds the object from hash
300
+ # @param [Hash] attributes Model attributes in the form of hash
301
+ # @return [Object] Returns the model itself
302
+ def self.build_from_hash(attributes)
303
+ new.build_from_hash(attributes)
304
+ end
305
+
306
+ # Builds the object from hash
307
+ # @param [Hash] attributes Model attributes in the form of hash
308
+ # @return [Object] Returns the model itself
309
+ def build_from_hash(attributes)
310
+ return nil unless attributes.is_a?(Hash)
311
+ attributes = attributes.transform_keys(&:to_sym)
312
+ self.class.openapi_types.each_pair do |key, type|
313
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
314
+ self.send("#{key}=", nil)
315
+ elsif type =~ /\AArray<(.*)>/i
316
+ # check to ensure the input is an array given that the attribute
317
+ # is documented as an array but the input is not
318
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
319
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
320
+ end
321
+ elsif !attributes[self.class.attribute_map[key]].nil?
322
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
323
+ end
324
+ end
325
+
326
+ self
327
+ end
328
+
329
+ # Deserializes the data based on type
330
+ # @param string type Data type
331
+ # @param string value Value to be deserialized
332
+ # @return [Object] Deserialized data
333
+ def _deserialize(type, value)
334
+ case type.to_sym
335
+ when :Time
336
+ Time.parse(value)
337
+ when :Date
338
+ Date.parse(value)
339
+ when :String
340
+ value.to_s
341
+ when :Integer
342
+ value.to_i
343
+ when :Float
344
+ value.to_f
345
+ when :Boolean
346
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
347
+ true
348
+ else
349
+ false
350
+ end
351
+ when :Object
352
+ # generic object (usually a Hash), return directly
353
+ value
354
+ when /\AArray<(?<inner_type>.+)>\z/
355
+ inner_type = Regexp.last_match[:inner_type]
356
+ value.map { |v| _deserialize(inner_type, v) }
357
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
358
+ k_type = Regexp.last_match[:k_type]
359
+ v_type = Regexp.last_match[:v_type]
360
+ {}.tap do |hash|
361
+ value.each do |k, v|
362
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
363
+ end
364
+ end
365
+ else # model
366
+ # models (e.g. Pet) or oneOf
367
+ klass = Chromadb.const_get(type)
368
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
369
+ end
370
+ end
371
+
372
+ # Returns the string representation of the object
373
+ # @return [String] String presentation of the object
374
+ def to_s
375
+ to_hash.to_s
376
+ end
377
+
378
+ # to_body is an alias to to_hash (backward compatibility)
379
+ # @return [Hash] Returns the object in the form of hash
380
+ def to_body
381
+ to_hash
382
+ end
383
+
384
+ # Returns the object in the form of hash
385
+ # @return [Hash] Returns the object in the form of hash
386
+ def to_hash
387
+ hash = {}
388
+ self.class.attribute_map.each_pair do |attr, param|
389
+ value = self.send(attr)
390
+ if value.nil?
391
+ is_nullable = self.class.openapi_nullable.include?(attr)
392
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
393
+ end
394
+
395
+ hash[param] = _to_hash(value)
396
+ end
397
+ hash
398
+ end
399
+
400
+ # Outputs non-array value in the form of hash
401
+ # For object, use to_hash. Otherwise, just return the value
402
+ # @param [Object] value Any valid value
403
+ # @return [Hash] Returns the value in the form of hash
404
+ def _to_hash(value)
405
+ if value.is_a?(Array)
406
+ value.compact.map { |v| _to_hash(v) }
407
+ elsif value.is_a?(Hash)
408
+ {}.tap do |hash|
409
+ value.each { |k, v| hash[k] = _to_hash(v) }
410
+ end
411
+ elsif value.respond_to? :to_hash
412
+ value.to_hash
413
+ else
414
+ value
415
+ end
416
+ end
417
+
418
+ end
419
+
420
+ end