turbopuffer 1.5.0 → 1.7.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.
@@ -11,11 +11,35 @@ module Turbopuffer
11
11
  )
12
12
  end
13
13
 
14
- # Whether to create an approximate nearest neighbor index for the attribute.
15
- sig { returns(T.nilable(T::Boolean)) }
14
+ # The data type of the attribute. Valid values: string, int, uint, float, uuid,
15
+ # datetime, bool, []string, []int, []uint, []float, []uuid, []datetime, []bool,
16
+ # [DIMS]f16, [DIMS]f32.
17
+ sig { returns(String) }
18
+ attr_accessor :type
19
+
20
+ # Whether to create an approximate nearest neighbor index for the attribute. Can
21
+ # be a boolean or a detailed configuration object.
22
+ sig do
23
+ returns(
24
+ T.nilable(
25
+ T.any(
26
+ T::Boolean,
27
+ Turbopuffer::AttributeSchemaConfig::Ann::AnnConfig
28
+ )
29
+ )
30
+ )
31
+ end
16
32
  attr_reader :ann
17
33
 
18
- sig { params(ann: T::Boolean).void }
34
+ sig do
35
+ params(
36
+ ann:
37
+ T.any(
38
+ T::Boolean,
39
+ Turbopuffer::AttributeSchemaConfig::Ann::AnnConfig::OrHash
40
+ )
41
+ ).void
42
+ end
19
43
  attr_writer :ann
20
44
 
21
45
  # Whether or not the attributes can be used in filters.
@@ -48,28 +72,28 @@ module Turbopuffer
48
72
  sig { params(regex: T::Boolean).void }
49
73
  attr_writer :regex
50
74
 
51
- # The data type of the attribute. Valid values: string, int, uint, float, uuid,
52
- # datetime, bool, []string, []int, []uint, []float, []uuid, []datetime, []bool,
53
- # [DIMS]f16, [DIMS]f32.
54
- sig { returns(T.nilable(String)) }
55
- attr_reader :type
56
-
57
- sig { params(type: String).void }
58
- attr_writer :type
59
-
60
75
  # Detailed configuration for an attribute attached to a document.
61
76
  sig do
62
77
  params(
63
- ann: T::Boolean,
78
+ type: String,
79
+ ann:
80
+ T.any(
81
+ T::Boolean,
82
+ Turbopuffer::AttributeSchemaConfig::Ann::AnnConfig::OrHash
83
+ ),
64
84
  filterable: T::Boolean,
65
85
  full_text_search:
66
86
  T.any(T::Boolean, Turbopuffer::FullTextSearchConfig::OrHash),
67
- regex: T::Boolean,
68
- type: String
87
+ regex: T::Boolean
69
88
  ).returns(T.attached_class)
70
89
  end
71
90
  def self.new(
72
- # Whether to create an approximate nearest neighbor index for the attribute.
91
+ # The data type of the attribute. Valid values: string, int, uint, float, uuid,
92
+ # datetime, bool, []string, []int, []uint, []float, []uuid, []datetime, []bool,
93
+ # [DIMS]f16, [DIMS]f32.
94
+ type:,
95
+ # Whether to create an approximate nearest neighbor index for the attribute. Can
96
+ # be a boolean or a detailed configuration object.
73
97
  ann: nil,
74
98
  # Whether or not the attributes can be used in filters.
75
99
  filterable: nil,
@@ -78,28 +102,89 @@ module Turbopuffer
78
102
  # filterable. You can override this by setting `filterable: true`.
79
103
  full_text_search: nil,
80
104
  # Whether to enable Regex filters on this attribute.
81
- regex: nil,
82
- # The data type of the attribute. Valid values: string, int, uint, float, uuid,
83
- # datetime, bool, []string, []int, []uint, []float, []uuid, []datetime, []bool,
84
- # [DIMS]f16, [DIMS]f32.
85
- type: nil
105
+ regex: nil
86
106
  )
87
107
  end
88
108
 
89
109
  sig do
90
110
  override.returns(
91
111
  {
92
- ann: T::Boolean,
112
+ type: String,
113
+ ann:
114
+ T.any(
115
+ T::Boolean,
116
+ Turbopuffer::AttributeSchemaConfig::Ann::AnnConfig
117
+ ),
93
118
  filterable: T::Boolean,
94
119
  full_text_search:
95
120
  T.any(T::Boolean, Turbopuffer::FullTextSearchConfig),
96
- regex: T::Boolean,
97
- type: String
121
+ regex: T::Boolean
98
122
  }
99
123
  )
100
124
  end
101
125
  def to_hash
102
126
  end
127
+
128
+ # Whether to create an approximate nearest neighbor index for the attribute. Can
129
+ # be a boolean or a detailed configuration object.
130
+ module Ann
131
+ extend Turbopuffer::Internal::Type::Union
132
+
133
+ Variants =
134
+ T.type_alias do
135
+ T.any(
136
+ T::Boolean,
137
+ Turbopuffer::AttributeSchemaConfig::Ann::AnnConfig
138
+ )
139
+ end
140
+
141
+ class AnnConfig < Turbopuffer::Internal::Type::BaseModel
142
+ OrHash =
143
+ T.type_alias do
144
+ T.any(
145
+ Turbopuffer::AttributeSchemaConfig::Ann::AnnConfig,
146
+ Turbopuffer::Internal::AnyHash
147
+ )
148
+ end
149
+
150
+ # A function used to calculate vector similarity.
151
+ sig { returns(T.nilable(Turbopuffer::DistanceMetric::OrSymbol)) }
152
+ attr_reader :distance_metric
153
+
154
+ sig do
155
+ params(distance_metric: Turbopuffer::DistanceMetric::OrSymbol).void
156
+ end
157
+ attr_writer :distance_metric
158
+
159
+ # Configuration options for ANN (Approximate Nearest Neighbor) indexing.
160
+ sig do
161
+ params(
162
+ distance_metric: Turbopuffer::DistanceMetric::OrSymbol
163
+ ).returns(T.attached_class)
164
+ end
165
+ def self.new(
166
+ # A function used to calculate vector similarity.
167
+ distance_metric: nil
168
+ )
169
+ end
170
+
171
+ sig do
172
+ override.returns(
173
+ { distance_metric: Turbopuffer::DistanceMetric::OrSymbol }
174
+ )
175
+ end
176
+ def to_hash
177
+ end
178
+ end
179
+
180
+ sig do
181
+ override.returns(
182
+ T::Array[Turbopuffer::AttributeSchemaConfig::Ann::Variants]
183
+ )
184
+ end
185
+ def self.variants
186
+ end
187
+ end
103
188
  end
104
189
  end
105
190
  end
@@ -20,6 +20,14 @@ module Turbopuffer
20
20
  sig { returns(Time) }
21
21
  attr_accessor :created_at
22
22
 
23
+ # Indicates that the namespace is encrypted with a customer-managed encryption key
24
+ # (CMEK).
25
+ sig { returns(Turbopuffer::NamespaceMetadata::Encryption::Variants) }
26
+ attr_accessor :encryption
27
+
28
+ sig { returns(Turbopuffer::NamespaceMetadata::Index::Variants) }
29
+ attr_accessor :index
30
+
23
31
  # The schema of the namespace.
24
32
  sig { returns(T::Hash[Symbol, Turbopuffer::AttributeSchemaConfig]) }
25
33
  attr_accessor :schema
@@ -28,58 +36,24 @@ module Turbopuffer
28
36
  sig { returns(Time) }
29
37
  attr_accessor :updated_at
30
38
 
31
- # Indicates that the namespace is encrypted with a customer-managed encryption key
32
- # (CMEK).
33
- sig do
34
- returns(T.nilable(Turbopuffer::NamespaceMetadata::Encryption::Variants))
35
- end
36
- attr_reader :encryption
37
-
38
- sig do
39
- params(
40
- encryption:
41
- T.any(
42
- T::Boolean,
43
- Turbopuffer::NamespaceMetadata::Encryption::Cmek::OrHash
44
- )
45
- ).void
46
- end
47
- attr_writer :encryption
48
-
49
- sig do
50
- returns(T.nilable(Turbopuffer::NamespaceMetadata::Index::Variants))
51
- end
52
- attr_reader :index
53
-
54
- sig do
55
- params(
56
- index:
57
- T.any(
58
- Turbopuffer::NamespaceMetadata::Index::Status::OrHash,
59
- Turbopuffer::NamespaceMetadata::Index::UnionMember1::OrHash
60
- )
61
- ).void
62
- end
63
- attr_writer :index
64
-
65
39
  # Metadata about a namespace.
66
40
  sig do
67
41
  params(
68
42
  approx_logical_bytes: Integer,
69
43
  approx_row_count: Integer,
70
44
  created_at: Time,
71
- schema: T::Hash[Symbol, Turbopuffer::AttributeSchemaConfig::OrHash],
72
- updated_at: Time,
73
45
  encryption:
74
46
  T.any(
75
- T::Boolean,
47
+ Turbopuffer::NamespaceMetadata::Encryption::Sse::OrHash,
76
48
  Turbopuffer::NamespaceMetadata::Encryption::Cmek::OrHash
77
49
  ),
78
50
  index:
79
51
  T.any(
80
- Turbopuffer::NamespaceMetadata::Index::Status::OrHash,
81
- Turbopuffer::NamespaceMetadata::Index::UnionMember1::OrHash
82
- )
52
+ Turbopuffer::NamespaceMetadata::Index::IndexUpToDate::OrHash,
53
+ Turbopuffer::NamespaceMetadata::Index::IndexUpdating::OrHash
54
+ ),
55
+ schema: T::Hash[Symbol, Turbopuffer::AttributeSchemaConfig::OrHash],
56
+ updated_at: Time
83
57
  ).returns(T.attached_class)
84
58
  end
85
59
  def self.new(
@@ -89,14 +63,14 @@ module Turbopuffer
89
63
  approx_row_count:,
90
64
  # The timestamp when the namespace was created.
91
65
  created_at:,
66
+ # Indicates that the namespace is encrypted with a customer-managed encryption key
67
+ # (CMEK).
68
+ encryption:,
69
+ index:,
92
70
  # The schema of the namespace.
93
71
  schema:,
94
72
  # The timestamp when the namespace was last modified by a write operation.
95
- updated_at:,
96
- # Indicates that the namespace is encrypted with a customer-managed encryption key
97
- # (CMEK).
98
- encryption: nil,
99
- index: nil
73
+ updated_at:
100
74
  )
101
75
  end
102
76
 
@@ -106,10 +80,10 @@ module Turbopuffer
106
80
  approx_logical_bytes: Integer,
107
81
  approx_row_count: Integer,
108
82
  created_at: Time,
109
- schema: T::Hash[Symbol, Turbopuffer::AttributeSchemaConfig],
110
- updated_at: Time,
111
83
  encryption: Turbopuffer::NamespaceMetadata::Encryption::Variants,
112
- index: Turbopuffer::NamespaceMetadata::Index::Variants
84
+ index: Turbopuffer::NamespaceMetadata::Index::Variants,
85
+ schema: T::Hash[Symbol, Turbopuffer::AttributeSchemaConfig],
86
+ updated_at: Time
113
87
  }
114
88
  )
115
89
  end
@@ -123,9 +97,37 @@ module Turbopuffer
123
97
 
124
98
  Variants =
125
99
  T.type_alias do
126
- T.any(T::Boolean, Turbopuffer::NamespaceMetadata::Encryption::Cmek)
100
+ T.any(
101
+ Turbopuffer::NamespaceMetadata::Encryption::Sse,
102
+ Turbopuffer::NamespaceMetadata::Encryption::Cmek
103
+ )
104
+ end
105
+
106
+ class Sse < Turbopuffer::Internal::Type::BaseModel
107
+ OrHash =
108
+ T.type_alias do
109
+ T.any(
110
+ Turbopuffer::NamespaceMetadata::Encryption::Sse,
111
+ Turbopuffer::Internal::AnyHash
112
+ )
113
+ end
114
+
115
+ # Always true. Indicates that the namespace is encrypted with SSE.
116
+ sig { returns(T::Boolean) }
117
+ attr_accessor :sse
118
+
119
+ sig { params(sse: T::Boolean).returns(T.attached_class) }
120
+ def self.new(
121
+ # Always true. Indicates that the namespace is encrypted with SSE.
122
+ sse:
123
+ )
127
124
  end
128
125
 
126
+ sig { override.returns({ sse: T::Boolean }) }
127
+ def to_hash
128
+ end
129
+ end
130
+
129
131
  class Cmek < Turbopuffer::Internal::Type::BaseModel
130
132
  OrHash =
131
133
  T.type_alias do
@@ -136,9 +138,7 @@ module Turbopuffer
136
138
  end
137
139
 
138
140
  sig do
139
- returns(
140
- T.nilable(Turbopuffer::NamespaceMetadata::Encryption::Cmek::Cmek)
141
- )
141
+ returns(Turbopuffer::NamespaceMetadata::Encryption::Cmek::Cmek)
142
142
  end
143
143
  attr_reader :cmek
144
144
 
@@ -158,7 +158,7 @@ module Turbopuffer
158
158
  Turbopuffer::NamespaceMetadata::Encryption::Cmek::Cmek::OrHash
159
159
  ).returns(T.attached_class)
160
160
  end
161
- def self.new(cmek: nil)
161
+ def self.new(cmek:)
162
162
  end
163
163
 
164
164
  sig do
@@ -210,16 +210,16 @@ module Turbopuffer
210
210
  Variants =
211
211
  T.type_alias do
212
212
  T.any(
213
- Turbopuffer::NamespaceMetadata::Index::Status,
214
- Turbopuffer::NamespaceMetadata::Index::UnionMember1
213
+ Turbopuffer::NamespaceMetadata::Index::IndexUpToDate,
214
+ Turbopuffer::NamespaceMetadata::Index::IndexUpdating
215
215
  )
216
216
  end
217
217
 
218
- class Status < Turbopuffer::Internal::Type::BaseModel
218
+ class IndexUpToDate < Turbopuffer::Internal::Type::BaseModel
219
219
  OrHash =
220
220
  T.type_alias do
221
221
  T.any(
222
- Turbopuffer::NamespaceMetadata::Index::Status,
222
+ Turbopuffer::NamespaceMetadata::Index::IndexUpToDate,
223
223
  Turbopuffer::Internal::AnyHash
224
224
  )
225
225
  end
@@ -236,11 +236,11 @@ module Turbopuffer
236
236
  end
237
237
  end
238
238
 
239
- class UnionMember1 < Turbopuffer::Internal::Type::BaseModel
239
+ class IndexUpdating < Turbopuffer::Internal::Type::BaseModel
240
240
  OrHash =
241
241
  T.type_alias do
242
242
  T.any(
243
- Turbopuffer::NamespaceMetadata::Index::UnionMember1,
243
+ Turbopuffer::NamespaceMetadata::Index::IndexUpdating,
244
244
  Turbopuffer::Internal::AnyHash
245
245
  )
246
246
  end
@@ -21,10 +21,27 @@ module Turbopuffer
21
21
  attr_writer :namespace
22
22
 
23
23
  # The namespace to copy documents from.
24
- sig { returns(T.nilable(String)) }
24
+ sig do
25
+ returns(
26
+ T.nilable(
27
+ T.any(
28
+ String,
29
+ Turbopuffer::NamespaceWriteParams::CopyFromNamespace::CopyFromNamespaceConfig
30
+ )
31
+ )
32
+ )
33
+ end
25
34
  attr_reader :copy_from_namespace
26
35
 
27
- sig { params(copy_from_namespace: String).void }
36
+ sig do
37
+ params(
38
+ copy_from_namespace:
39
+ T.any(
40
+ String,
41
+ Turbopuffer::NamespaceWriteParams::CopyFromNamespace::CopyFromNamespaceConfig::OrHash
42
+ )
43
+ ).void
44
+ end
28
45
  attr_writer :copy_from_namespace
29
46
 
30
47
  # The filter specifying which documents to delete.
@@ -157,7 +174,11 @@ module Turbopuffer
157
174
  sig do
158
175
  params(
159
176
  namespace: String,
160
- copy_from_namespace: String,
177
+ copy_from_namespace:
178
+ T.any(
179
+ String,
180
+ Turbopuffer::NamespaceWriteParams::CopyFromNamespace::CopyFromNamespaceConfig::OrHash
181
+ ),
161
182
  delete_by_filter: T.anything,
162
183
  delete_condition: T.anything,
163
184
  deletes: T::Array[Turbopuffer::ID::Variants],
@@ -222,7 +243,11 @@ module Turbopuffer
222
243
  override.returns(
223
244
  {
224
245
  namespace: String,
225
- copy_from_namespace: String,
246
+ copy_from_namespace:
247
+ T.any(
248
+ String,
249
+ Turbopuffer::NamespaceWriteParams::CopyFromNamespace::CopyFromNamespaceConfig
250
+ ),
226
251
  delete_by_filter: T.anything,
227
252
  delete_condition: T.anything,
228
253
  deletes: T::Array[Turbopuffer::ID::Variants],
@@ -248,6 +273,68 @@ module Turbopuffer
248
273
  def to_hash
249
274
  end
250
275
 
276
+ # The namespace to copy documents from.
277
+ module CopyFromNamespace
278
+ extend Turbopuffer::Internal::Type::Union
279
+
280
+ Variants =
281
+ T.type_alias do
282
+ T.any(
283
+ String,
284
+ Turbopuffer::NamespaceWriteParams::CopyFromNamespace::CopyFromNamespaceConfig
285
+ )
286
+ end
287
+
288
+ class CopyFromNamespaceConfig < Turbopuffer::Internal::Type::BaseModel
289
+ OrHash =
290
+ T.type_alias do
291
+ T.any(
292
+ Turbopuffer::NamespaceWriteParams::CopyFromNamespace::CopyFromNamespaceConfig,
293
+ Turbopuffer::Internal::AnyHash
294
+ )
295
+ end
296
+
297
+ # An API key for the organization containing the source namespace
298
+ sig { returns(String) }
299
+ attr_accessor :source_api_key
300
+
301
+ # The namespace to copy documents from.
302
+ sig { returns(String) }
303
+ attr_accessor :source_namespace
304
+
305
+ sig do
306
+ params(source_api_key: String, source_namespace: String).returns(
307
+ T.attached_class
308
+ )
309
+ end
310
+ def self.new(
311
+ # An API key for the organization containing the source namespace
312
+ source_api_key:,
313
+ # The namespace to copy documents from.
314
+ source_namespace:
315
+ )
316
+ end
317
+
318
+ sig do
319
+ override.returns(
320
+ { source_api_key: String, source_namespace: String }
321
+ )
322
+ end
323
+ def to_hash
324
+ end
325
+ end
326
+
327
+ sig do
328
+ override.returns(
329
+ T::Array[
330
+ Turbopuffer::NamespaceWriteParams::CopyFromNamespace::Variants
331
+ ]
332
+ )
333
+ end
334
+ def self.variants
335
+ end
336
+ end
337
+
251
338
  class Encryption < Turbopuffer::Internal::Type::BaseModel
252
339
  OrHash =
253
340
  T.type_alias do
@@ -235,8 +235,12 @@ module Turbopuffer
235
235
  # Create, update, or delete documents.
236
236
  sig do
237
237
  params(
238
- namespace: T.nilable(String),
239
- copy_from_namespace: String,
238
+ namespace: String,
239
+ copy_from_namespace:
240
+ T.any(
241
+ String,
242
+ Turbopuffer::NamespaceWriteParams::CopyFromNamespace::CopyFromNamespaceConfig::OrHash
243
+ ),
240
244
  delete_by_filter: T.anything,
241
245
  delete_condition: T.anything,
242
246
  deletes: T::Array[Turbopuffer::ID::Variants],
@@ -87,6 +87,8 @@ module Turbopuffer
87
87
 
88
88
  private def auth_headers: -> ::Hash[String, String]
89
89
 
90
+ private def user_agent: -> String
91
+
90
92
  private def generate_idempotency_key: -> String
91
93
 
92
94
  private def build_request: (
@@ -17,7 +17,10 @@ module Turbopuffer
17
17
 
18
18
  DEFAULT_MAX_CONNECTIONS: Integer
19
19
 
20
- def self.connect: (URI::Generic url) -> top
20
+ def self.connect: (
21
+ cert_store: OpenSSL::X509::Store,
22
+ url: URI::Generic
23
+ ) -> top
21
24
 
22
25
  def self.calibrate_socket_timeout: (top conn, Float deadline) -> void
23
26
 
@@ -2,17 +2,21 @@ module Turbopuffer
2
2
  module Models
3
3
  type attribute_schema_config =
4
4
  {
5
- ann: bool,
5
+ type: String,
6
+ ann: Turbopuffer::Models::AttributeSchemaConfig::ann,
6
7
  filterable: bool,
7
8
  full_text_search: Turbopuffer::Models::full_text_search,
8
- regex: bool,
9
- type: String
9
+ regex: bool
10
10
  }
11
11
 
12
12
  class AttributeSchemaConfig < Turbopuffer::Internal::Type::BaseModel
13
- attr_reader ann: bool?
13
+ attr_accessor type: String
14
14
 
15
- def ann=: (bool) -> bool
15
+ attr_reader ann: Turbopuffer::Models::AttributeSchemaConfig::ann?
16
+
17
+ def ann=: (
18
+ Turbopuffer::Models::AttributeSchemaConfig::ann
19
+ ) -> Turbopuffer::Models::AttributeSchemaConfig::ann
16
20
 
17
21
  attr_reader filterable: bool?
18
22
 
@@ -28,25 +32,48 @@ module Turbopuffer
28
32
 
29
33
  def regex=: (bool) -> bool
30
34
 
31
- attr_reader type: String?
32
-
33
- def type=: (String) -> String
34
-
35
35
  def initialize: (
36
- ?ann: bool,
36
+ type: String,
37
+ ?ann: Turbopuffer::Models::AttributeSchemaConfig::ann,
37
38
  ?filterable: bool,
38
39
  ?full_text_search: Turbopuffer::Models::full_text_search,
39
- ?regex: bool,
40
- ?type: String
40
+ ?regex: bool
41
41
  ) -> void
42
42
 
43
43
  def to_hash: -> {
44
- ann: bool,
44
+ type: String,
45
+ ann: Turbopuffer::Models::AttributeSchemaConfig::ann,
45
46
  filterable: bool,
46
47
  full_text_search: Turbopuffer::Models::full_text_search,
47
- regex: bool,
48
- type: String
48
+ regex: bool
49
49
  }
50
+
51
+ type ann = bool | Turbopuffer::AttributeSchemaConfig::Ann::AnnConfig
52
+
53
+ module Ann
54
+ extend Turbopuffer::Internal::Type::Union
55
+
56
+ type ann_config =
57
+ { distance_metric: Turbopuffer::Models::distance_metric }
58
+
59
+ class AnnConfig < Turbopuffer::Internal::Type::BaseModel
60
+ attr_reader distance_metric: Turbopuffer::Models::distance_metric?
61
+
62
+ def distance_metric=: (
63
+ Turbopuffer::Models::distance_metric
64
+ ) -> Turbopuffer::Models::distance_metric
65
+
66
+ def initialize: (
67
+ ?distance_metric: Turbopuffer::Models::distance_metric
68
+ ) -> void
69
+
70
+ def to_hash: -> {
71
+ distance_metric: Turbopuffer::Models::distance_metric
72
+ }
73
+ end
74
+
75
+ def self?.variants: -> ::Array[Turbopuffer::Models::AttributeSchemaConfig::ann]
76
+ end
50
77
  end
51
78
  end
52
79
  end