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,330 @@
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 HnswConfiguration
18
+ attr_accessor :ef_construction
19
+
20
+ attr_accessor :ef_search
21
+
22
+ attr_accessor :max_neighbors
23
+
24
+ attr_accessor :resize_factor
25
+
26
+ attr_accessor :space
27
+
28
+ attr_accessor :sync_threshold
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'ef_construction' => :'ef_construction',
34
+ :'ef_search' => :'ef_search',
35
+ :'max_neighbors' => :'max_neighbors',
36
+ :'resize_factor' => :'resize_factor',
37
+ :'space' => :'space',
38
+ :'sync_threshold' => :'sync_threshold'
39
+ }
40
+ end
41
+
42
+ # Returns all the JSON keys this model knows about
43
+ def self.acceptable_attributes
44
+ attribute_map.values
45
+ end
46
+
47
+ # Attribute type mapping.
48
+ def self.openapi_types
49
+ {
50
+ :'ef_construction' => :'Object',
51
+ :'ef_search' => :'Object',
52
+ :'max_neighbors' => :'Object',
53
+ :'resize_factor' => :'Object',
54
+ :'space' => :'Object',
55
+ :'sync_threshold' => :'Object'
56
+ }
57
+ end
58
+
59
+ # List of attributes with nullable: true
60
+ def self.openapi_nullable
61
+ Set.new([
62
+ :'ef_construction',
63
+ :'ef_search',
64
+ :'max_neighbors',
65
+ :'resize_factor',
66
+ :'space',
67
+ :'sync_threshold'
68
+ ])
69
+ end
70
+
71
+ # Initializes the object
72
+ # @param [Hash] attributes Model attributes in the form of hash
73
+ def initialize(attributes = {})
74
+ if (!attributes.is_a?(Hash))
75
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Chromadb::HnswConfiguration` initialize method"
76
+ end
77
+
78
+ # check to see if the attribute exists and convert string to symbol for hash key
79
+ attributes = attributes.each_with_object({}) { |(k, v), h|
80
+ if (!self.class.attribute_map.key?(k.to_sym))
81
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Chromadb::HnswConfiguration`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
82
+ end
83
+ h[k.to_sym] = v
84
+ }
85
+
86
+ if attributes.key?(:'ef_construction')
87
+ self.ef_construction = attributes[:'ef_construction']
88
+ end
89
+
90
+ if attributes.key?(:'ef_search')
91
+ self.ef_search = attributes[:'ef_search']
92
+ end
93
+
94
+ if attributes.key?(:'max_neighbors')
95
+ self.max_neighbors = attributes[:'max_neighbors']
96
+ end
97
+
98
+ if attributes.key?(:'resize_factor')
99
+ self.resize_factor = attributes[:'resize_factor']
100
+ end
101
+
102
+ if attributes.key?(:'space')
103
+ self.space = attributes[:'space']
104
+ end
105
+
106
+ if attributes.key?(:'sync_threshold')
107
+ self.sync_threshold = attributes[:'sync_threshold']
108
+ end
109
+ end
110
+
111
+ # Show invalid properties with the reasons. Usually used together with valid?
112
+ # @return Array for valid properties with the reasons
113
+ def list_invalid_properties
114
+ invalid_properties = Array.new
115
+ if !@ef_construction.nil? && @ef_construction < 0
116
+ invalid_properties.push('invalid value for "ef_construction", must be greater than or equal to 0.')
117
+ end
118
+
119
+ if !@ef_search.nil? && @ef_search < 0
120
+ invalid_properties.push('invalid value for "ef_search", must be greater than or equal to 0.')
121
+ end
122
+
123
+ if !@max_neighbors.nil? && @max_neighbors < 0
124
+ invalid_properties.push('invalid value for "max_neighbors", must be greater than or equal to 0.')
125
+ end
126
+
127
+ if !@sync_threshold.nil? && @sync_threshold < 0
128
+ invalid_properties.push('invalid value for "sync_threshold", must be greater than or equal to 0.')
129
+ end
130
+
131
+ invalid_properties
132
+ end
133
+
134
+ # Check to see if the all the properties in the model are valid
135
+ # @return true if the model is valid
136
+ def valid?
137
+ return false if !@ef_construction.nil? && @ef_construction < 0
138
+ return false if !@ef_search.nil? && @ef_search < 0
139
+ return false if !@max_neighbors.nil? && @max_neighbors < 0
140
+ return false if !@sync_threshold.nil? && @sync_threshold < 0
141
+ true
142
+ end
143
+
144
+ # Custom attribute writer method with validation
145
+ # @param [Object] ef_construction Value to be assigned
146
+ def ef_construction=(ef_construction)
147
+ if !ef_construction.nil? && ef_construction < 0
148
+ fail ArgumentError, 'invalid value for "ef_construction", must be greater than or equal to 0.'
149
+ end
150
+
151
+ @ef_construction = ef_construction
152
+ end
153
+
154
+ # Custom attribute writer method with validation
155
+ # @param [Object] ef_search Value to be assigned
156
+ def ef_search=(ef_search)
157
+ if !ef_search.nil? && ef_search < 0
158
+ fail ArgumentError, 'invalid value for "ef_search", must be greater than or equal to 0.'
159
+ end
160
+
161
+ @ef_search = ef_search
162
+ end
163
+
164
+ # Custom attribute writer method with validation
165
+ # @param [Object] max_neighbors Value to be assigned
166
+ def max_neighbors=(max_neighbors)
167
+ if !max_neighbors.nil? && max_neighbors < 0
168
+ fail ArgumentError, 'invalid value for "max_neighbors", must be greater than or equal to 0.'
169
+ end
170
+
171
+ @max_neighbors = max_neighbors
172
+ end
173
+
174
+ # Custom attribute writer method with validation
175
+ # @param [Object] sync_threshold Value to be assigned
176
+ def sync_threshold=(sync_threshold)
177
+ if !sync_threshold.nil? && sync_threshold < 0
178
+ fail ArgumentError, 'invalid value for "sync_threshold", must be greater than or equal to 0.'
179
+ end
180
+
181
+ @sync_threshold = sync_threshold
182
+ end
183
+
184
+ # Checks equality by comparing each attribute.
185
+ # @param [Object] Object to be compared
186
+ def ==(o)
187
+ return true if self.equal?(o)
188
+ self.class == o.class &&
189
+ ef_construction == o.ef_construction &&
190
+ ef_search == o.ef_search &&
191
+ max_neighbors == o.max_neighbors &&
192
+ resize_factor == o.resize_factor &&
193
+ space == o.space &&
194
+ sync_threshold == o.sync_threshold
195
+ end
196
+
197
+ # @see the `==` method
198
+ # @param [Object] Object to be compared
199
+ def eql?(o)
200
+ self == o
201
+ end
202
+
203
+ # Calculates hash code according to all attributes.
204
+ # @return [Integer] Hash code
205
+ def hash
206
+ [ef_construction, ef_search, max_neighbors, resize_factor, space, sync_threshold].hash
207
+ end
208
+
209
+ # Builds the object from hash
210
+ # @param [Hash] attributes Model attributes in the form of hash
211
+ # @return [Object] Returns the model itself
212
+ def self.build_from_hash(attributes)
213
+ new.build_from_hash(attributes)
214
+ end
215
+
216
+ # Builds the object from hash
217
+ # @param [Hash] attributes Model attributes in the form of hash
218
+ # @return [Object] Returns the model itself
219
+ def build_from_hash(attributes)
220
+ return nil unless attributes.is_a?(Hash)
221
+ attributes = attributes.transform_keys(&:to_sym)
222
+ self.class.openapi_types.each_pair do |key, type|
223
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
224
+ self.send("#{key}=", nil)
225
+ elsif type =~ /\AArray<(.*)>/i
226
+ # check to ensure the input is an array given that the attribute
227
+ # is documented as an array but the input is not
228
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
229
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
230
+ end
231
+ elsif !attributes[self.class.attribute_map[key]].nil?
232
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
233
+ end
234
+ end
235
+
236
+ self
237
+ end
238
+
239
+ # Deserializes the data based on type
240
+ # @param string type Data type
241
+ # @param string value Value to be deserialized
242
+ # @return [Object] Deserialized data
243
+ def _deserialize(type, value)
244
+ case type.to_sym
245
+ when :Time
246
+ Time.parse(value)
247
+ when :Date
248
+ Date.parse(value)
249
+ when :String
250
+ value.to_s
251
+ when :Integer
252
+ value.to_i
253
+ when :Float
254
+ value.to_f
255
+ when :Boolean
256
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
257
+ true
258
+ else
259
+ false
260
+ end
261
+ when :Object
262
+ # generic object (usually a Hash), return directly
263
+ value
264
+ when /\AArray<(?<inner_type>.+)>\z/
265
+ inner_type = Regexp.last_match[:inner_type]
266
+ value.map { |v| _deserialize(inner_type, v) }
267
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
268
+ k_type = Regexp.last_match[:k_type]
269
+ v_type = Regexp.last_match[:v_type]
270
+ {}.tap do |hash|
271
+ value.each do |k, v|
272
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
273
+ end
274
+ end
275
+ else # model
276
+ # models (e.g. Pet) or oneOf
277
+ klass = Chromadb.const_get(type)
278
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
279
+ end
280
+ end
281
+
282
+ # Returns the string representation of the object
283
+ # @return [String] String presentation of the object
284
+ def to_s
285
+ to_hash.to_s
286
+ end
287
+
288
+ # to_body is an alias to to_hash (backward compatibility)
289
+ # @return [Hash] Returns the object in the form of hash
290
+ def to_body
291
+ to_hash
292
+ end
293
+
294
+ # Returns the object in the form of hash
295
+ # @return [Hash] Returns the object in the form of hash
296
+ def to_hash
297
+ hash = {}
298
+ self.class.attribute_map.each_pair do |attr, param|
299
+ value = self.send(attr)
300
+ if value.nil?
301
+ is_nullable = self.class.openapi_nullable.include?(attr)
302
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
303
+ end
304
+
305
+ hash[param] = _to_hash(value)
306
+ end
307
+ hash
308
+ end
309
+
310
+ # Outputs non-array value in the form of hash
311
+ # For object, use to_hash. Otherwise, just return the value
312
+ # @param [Object] value Any valid value
313
+ # @return [Hash] Returns the value in the form of hash
314
+ def _to_hash(value)
315
+ if value.is_a?(Array)
316
+ value.compact.map { |v| _to_hash(v) }
317
+ elsif value.is_a?(Hash)
318
+ {}.tap do |hash|
319
+ value.each { |k, v| hash[k] = _to_hash(v) }
320
+ end
321
+ elsif value.respond_to? :to_hash
322
+ value.to_hash
323
+ else
324
+ value
325
+ end
326
+ end
327
+
328
+ end
329
+
330
+ end
@@ -0,0 +1,371 @@
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
+ # Configuration for HNSW vector index algorithm parameters
18
+ class HnswIndexConfig
19
+ attr_accessor :batch_size
20
+
21
+ attr_accessor :ef_construction
22
+
23
+ attr_accessor :ef_search
24
+
25
+ attr_accessor :max_neighbors
26
+
27
+ attr_accessor :num_threads
28
+
29
+ attr_accessor :resize_factor
30
+
31
+ attr_accessor :sync_threshold
32
+
33
+ # Attribute mapping from ruby-style variable name to JSON key.
34
+ def self.attribute_map
35
+ {
36
+ :'batch_size' => :'batch_size',
37
+ :'ef_construction' => :'ef_construction',
38
+ :'ef_search' => :'ef_search',
39
+ :'max_neighbors' => :'max_neighbors',
40
+ :'num_threads' => :'num_threads',
41
+ :'resize_factor' => :'resize_factor',
42
+ :'sync_threshold' => :'sync_threshold'
43
+ }
44
+ end
45
+
46
+ # Returns all the JSON keys this model knows about
47
+ def self.acceptable_attributes
48
+ attribute_map.values
49
+ end
50
+
51
+ # Attribute type mapping.
52
+ def self.openapi_types
53
+ {
54
+ :'batch_size' => :'Object',
55
+ :'ef_construction' => :'Object',
56
+ :'ef_search' => :'Object',
57
+ :'max_neighbors' => :'Object',
58
+ :'num_threads' => :'Object',
59
+ :'resize_factor' => :'Object',
60
+ :'sync_threshold' => :'Object'
61
+ }
62
+ end
63
+
64
+ # List of attributes with nullable: true
65
+ def self.openapi_nullable
66
+ Set.new([
67
+ :'batch_size',
68
+ :'ef_construction',
69
+ :'ef_search',
70
+ :'max_neighbors',
71
+ :'num_threads',
72
+ :'resize_factor',
73
+ :'sync_threshold'
74
+ ])
75
+ end
76
+
77
+ # Initializes the object
78
+ # @param [Hash] attributes Model attributes in the form of hash
79
+ def initialize(attributes = {})
80
+ if (!attributes.is_a?(Hash))
81
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Chromadb::HnswIndexConfig` initialize method"
82
+ end
83
+
84
+ # check to see if the attribute exists and convert string to symbol for hash key
85
+ attributes = attributes.each_with_object({}) { |(k, v), h|
86
+ if (!self.class.attribute_map.key?(k.to_sym))
87
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Chromadb::HnswIndexConfig`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
88
+ end
89
+ h[k.to_sym] = v
90
+ }
91
+
92
+ if attributes.key?(:'batch_size')
93
+ self.batch_size = attributes[:'batch_size']
94
+ end
95
+
96
+ if attributes.key?(:'ef_construction')
97
+ self.ef_construction = attributes[:'ef_construction']
98
+ end
99
+
100
+ if attributes.key?(:'ef_search')
101
+ self.ef_search = attributes[:'ef_search']
102
+ end
103
+
104
+ if attributes.key?(:'max_neighbors')
105
+ self.max_neighbors = attributes[:'max_neighbors']
106
+ end
107
+
108
+ if attributes.key?(:'num_threads')
109
+ self.num_threads = attributes[:'num_threads']
110
+ end
111
+
112
+ if attributes.key?(:'resize_factor')
113
+ self.resize_factor = attributes[:'resize_factor']
114
+ end
115
+
116
+ if attributes.key?(:'sync_threshold')
117
+ self.sync_threshold = attributes[:'sync_threshold']
118
+ end
119
+ end
120
+
121
+ # Show invalid properties with the reasons. Usually used together with valid?
122
+ # @return Array for valid properties with the reasons
123
+ def list_invalid_properties
124
+ invalid_properties = Array.new
125
+ if !@batch_size.nil? && @batch_size < 0
126
+ invalid_properties.push('invalid value for "batch_size", must be greater than or equal to 0.')
127
+ end
128
+
129
+ if !@ef_construction.nil? && @ef_construction < 0
130
+ invalid_properties.push('invalid value for "ef_construction", must be greater than or equal to 0.')
131
+ end
132
+
133
+ if !@ef_search.nil? && @ef_search < 0
134
+ invalid_properties.push('invalid value for "ef_search", must be greater than or equal to 0.')
135
+ end
136
+
137
+ if !@max_neighbors.nil? && @max_neighbors < 0
138
+ invalid_properties.push('invalid value for "max_neighbors", must be greater than or equal to 0.')
139
+ end
140
+
141
+ if !@num_threads.nil? && @num_threads < 0
142
+ invalid_properties.push('invalid value for "num_threads", must be greater than or equal to 0.')
143
+ end
144
+
145
+ if !@sync_threshold.nil? && @sync_threshold < 0
146
+ invalid_properties.push('invalid value for "sync_threshold", must be greater than or equal to 0.')
147
+ end
148
+
149
+ invalid_properties
150
+ end
151
+
152
+ # Check to see if the all the properties in the model are valid
153
+ # @return true if the model is valid
154
+ def valid?
155
+ return false if !@batch_size.nil? && @batch_size < 0
156
+ return false if !@ef_construction.nil? && @ef_construction < 0
157
+ return false if !@ef_search.nil? && @ef_search < 0
158
+ return false if !@max_neighbors.nil? && @max_neighbors < 0
159
+ return false if !@num_threads.nil? && @num_threads < 0
160
+ return false if !@sync_threshold.nil? && @sync_threshold < 0
161
+ true
162
+ end
163
+
164
+ # Custom attribute writer method with validation
165
+ # @param [Object] batch_size Value to be assigned
166
+ def batch_size=(batch_size)
167
+ if !batch_size.nil? && batch_size < 0
168
+ fail ArgumentError, 'invalid value for "batch_size", must be greater than or equal to 0.'
169
+ end
170
+
171
+ @batch_size = batch_size
172
+ end
173
+
174
+ # Custom attribute writer method with validation
175
+ # @param [Object] ef_construction Value to be assigned
176
+ def ef_construction=(ef_construction)
177
+ if !ef_construction.nil? && ef_construction < 0
178
+ fail ArgumentError, 'invalid value for "ef_construction", must be greater than or equal to 0.'
179
+ end
180
+
181
+ @ef_construction = ef_construction
182
+ end
183
+
184
+ # Custom attribute writer method with validation
185
+ # @param [Object] ef_search Value to be assigned
186
+ def ef_search=(ef_search)
187
+ if !ef_search.nil? && ef_search < 0
188
+ fail ArgumentError, 'invalid value for "ef_search", must be greater than or equal to 0.'
189
+ end
190
+
191
+ @ef_search = ef_search
192
+ end
193
+
194
+ # Custom attribute writer method with validation
195
+ # @param [Object] max_neighbors Value to be assigned
196
+ def max_neighbors=(max_neighbors)
197
+ if !max_neighbors.nil? && max_neighbors < 0
198
+ fail ArgumentError, 'invalid value for "max_neighbors", must be greater than or equal to 0.'
199
+ end
200
+
201
+ @max_neighbors = max_neighbors
202
+ end
203
+
204
+ # Custom attribute writer method with validation
205
+ # @param [Object] num_threads Value to be assigned
206
+ def num_threads=(num_threads)
207
+ if !num_threads.nil? && num_threads < 0
208
+ fail ArgumentError, 'invalid value for "num_threads", must be greater than or equal to 0.'
209
+ end
210
+
211
+ @num_threads = num_threads
212
+ end
213
+
214
+ # Custom attribute writer method with validation
215
+ # @param [Object] sync_threshold Value to be assigned
216
+ def sync_threshold=(sync_threshold)
217
+ if !sync_threshold.nil? && sync_threshold < 0
218
+ fail ArgumentError, 'invalid value for "sync_threshold", must be greater than or equal to 0.'
219
+ end
220
+
221
+ @sync_threshold = sync_threshold
222
+ end
223
+
224
+ # Checks equality by comparing each attribute.
225
+ # @param [Object] Object to be compared
226
+ def ==(o)
227
+ return true if self.equal?(o)
228
+ self.class == o.class &&
229
+ batch_size == o.batch_size &&
230
+ ef_construction == o.ef_construction &&
231
+ ef_search == o.ef_search &&
232
+ max_neighbors == o.max_neighbors &&
233
+ num_threads == o.num_threads &&
234
+ resize_factor == o.resize_factor &&
235
+ sync_threshold == o.sync_threshold
236
+ end
237
+
238
+ # @see the `==` method
239
+ # @param [Object] Object to be compared
240
+ def eql?(o)
241
+ self == o
242
+ end
243
+
244
+ # Calculates hash code according to all attributes.
245
+ # @return [Integer] Hash code
246
+ def hash
247
+ [batch_size, ef_construction, ef_search, max_neighbors, num_threads, resize_factor, sync_threshold].hash
248
+ end
249
+
250
+ # Builds the object from hash
251
+ # @param [Hash] attributes Model attributes in the form of hash
252
+ # @return [Object] Returns the model itself
253
+ def self.build_from_hash(attributes)
254
+ new.build_from_hash(attributes)
255
+ end
256
+
257
+ # Builds the object from hash
258
+ # @param [Hash] attributes Model attributes in the form of hash
259
+ # @return [Object] Returns the model itself
260
+ def build_from_hash(attributes)
261
+ return nil unless attributes.is_a?(Hash)
262
+ attributes = attributes.transform_keys(&:to_sym)
263
+ self.class.openapi_types.each_pair do |key, type|
264
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
265
+ self.send("#{key}=", nil)
266
+ elsif type =~ /\AArray<(.*)>/i
267
+ # check to ensure the input is an array given that the attribute
268
+ # is documented as an array but the input is not
269
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
270
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
271
+ end
272
+ elsif !attributes[self.class.attribute_map[key]].nil?
273
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
274
+ end
275
+ end
276
+
277
+ self
278
+ end
279
+
280
+ # Deserializes the data based on type
281
+ # @param string type Data type
282
+ # @param string value Value to be deserialized
283
+ # @return [Object] Deserialized data
284
+ def _deserialize(type, value)
285
+ case type.to_sym
286
+ when :Time
287
+ Time.parse(value)
288
+ when :Date
289
+ Date.parse(value)
290
+ when :String
291
+ value.to_s
292
+ when :Integer
293
+ value.to_i
294
+ when :Float
295
+ value.to_f
296
+ when :Boolean
297
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
298
+ true
299
+ else
300
+ false
301
+ end
302
+ when :Object
303
+ # generic object (usually a Hash), return directly
304
+ value
305
+ when /\AArray<(?<inner_type>.+)>\z/
306
+ inner_type = Regexp.last_match[:inner_type]
307
+ value.map { |v| _deserialize(inner_type, v) }
308
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
309
+ k_type = Regexp.last_match[:k_type]
310
+ v_type = Regexp.last_match[:v_type]
311
+ {}.tap do |hash|
312
+ value.each do |k, v|
313
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
314
+ end
315
+ end
316
+ else # model
317
+ # models (e.g. Pet) or oneOf
318
+ klass = Chromadb.const_get(type)
319
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
320
+ end
321
+ end
322
+
323
+ # Returns the string representation of the object
324
+ # @return [String] String presentation of the object
325
+ def to_s
326
+ to_hash.to_s
327
+ end
328
+
329
+ # to_body is an alias to to_hash (backward compatibility)
330
+ # @return [Hash] Returns the object in the form of hash
331
+ def to_body
332
+ to_hash
333
+ end
334
+
335
+ # Returns the object in the form of hash
336
+ # @return [Hash] Returns the object in the form of hash
337
+ def to_hash
338
+ hash = {}
339
+ self.class.attribute_map.each_pair do |attr, param|
340
+ value = self.send(attr)
341
+ if value.nil?
342
+ is_nullable = self.class.openapi_nullable.include?(attr)
343
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
344
+ end
345
+
346
+ hash[param] = _to_hash(value)
347
+ end
348
+ hash
349
+ end
350
+
351
+ # Outputs non-array value in the form of hash
352
+ # For object, use to_hash. Otherwise, just return the value
353
+ # @param [Object] value Any valid value
354
+ # @return [Hash] Returns the value in the form of hash
355
+ def _to_hash(value)
356
+ if value.is_a?(Array)
357
+ value.compact.map { |v| _to_hash(v) }
358
+ elsif value.is_a?(Hash)
359
+ {}.tap do |hash|
360
+ value.each { |k, v| hash[k] = _to_hash(v) }
361
+ end
362
+ elsif value.respond_to? :to_hash
363
+ value.to_hash
364
+ else
365
+ value
366
+ end
367
+ end
368
+
369
+ end
370
+
371
+ end