turbopuffer 2.2.0 → 2.4.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 (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +39 -0
  3. data/README.md +3 -3
  4. data/lib/turbopuffer/internal/transport/base_client.rb +4 -1
  5. data/lib/turbopuffer/models/attribute_schema_config.rb +14 -1
  6. data/lib/turbopuffer/models/highlight_config_params.rb +46 -0
  7. data/lib/turbopuffer/models/highlight_fragment_by.rb +25 -0
  8. data/lib/turbopuffer/models/highlight_offset_units.rb +17 -0
  9. data/lib/turbopuffer/models/namespace_copy_from_params.rb +9 -1
  10. data/lib/turbopuffer/models/namespace_explain_query_params.rb +11 -1
  11. data/lib/turbopuffer/models/namespace_metadata.rb +12 -1
  12. data/lib/turbopuffer/models/namespace_multi_query_params.rb +11 -1
  13. data/lib/turbopuffer/models/namespace_query_params.rb +11 -1
  14. data/lib/turbopuffer/models/namespace_write_params.rb +12 -1
  15. data/lib/turbopuffer/models/rrf_params.rb +14 -1
  16. data/lib/turbopuffer/models/sharding_config.rb +21 -0
  17. data/lib/turbopuffer/models.rb +8 -0
  18. data/lib/turbopuffer/resources/namespaces.rb +12 -4
  19. data/lib/turbopuffer/version.rb +1 -1
  20. data/lib/turbopuffer.rb +4 -0
  21. data/rbi/turbopuffer/models/attribute_schema_config.rbi +20 -3
  22. data/rbi/turbopuffer/models/highlight_config_params.rbi +85 -0
  23. data/rbi/turbopuffer/models/highlight_fragment_by.rbi +36 -0
  24. data/rbi/turbopuffer/models/highlight_offset_units.rbi +27 -0
  25. data/rbi/turbopuffer/models/namespace_copy_from_params.rbi +36 -0
  26. data/rbi/turbopuffer/models/namespace_explain_query_params.rbi +15 -0
  27. data/rbi/turbopuffer/models/namespace_metadata.rbi +20 -3
  28. data/rbi/turbopuffer/models/namespace_multi_query_params.rbi +15 -0
  29. data/rbi/turbopuffer/models/namespace_query_params.rbi +15 -0
  30. data/rbi/turbopuffer/models/namespace_write_params.rbi +17 -0
  31. data/rbi/turbopuffer/models/rrf_params.rbi +22 -3
  32. data/rbi/turbopuffer/models/sharding_config.rbi +31 -0
  33. data/rbi/turbopuffer/models.rbi +8 -0
  34. data/rbi/turbopuffer/resources/namespaces.rbi +24 -0
  35. data/sig/turbopuffer/models/attribute_schema_config.rbs +12 -3
  36. data/sig/turbopuffer/models/highlight_config_params.rbs +47 -0
  37. data/sig/turbopuffer/models/highlight_fragment_by.rbs +23 -0
  38. data/sig/turbopuffer/models/highlight_offset_units.rbs +15 -0
  39. data/sig/turbopuffer/models/namespace_copy_from_params.rbs +9 -0
  40. data/sig/turbopuffer/models/namespace_explain_query_params.rbs +7 -0
  41. data/sig/turbopuffer/models/namespace_metadata.rbs +12 -3
  42. data/sig/turbopuffer/models/namespace_multi_query_params.rbs +7 -0
  43. data/sig/turbopuffer/models/namespace_query_params.rbs +7 -0
  44. data/sig/turbopuffer/models/namespace_write_params.rbs +9 -0
  45. data/sig/turbopuffer/models/rrf_params.rbs +10 -3
  46. data/sig/turbopuffer/models/sharding_config.rbs +13 -0
  47. data/sig/turbopuffer/models.rbs +8 -0
  48. data/sig/turbopuffer/resources/namespaces.rbs +4 -0
  49. metadata +14 -2
@@ -0,0 +1,85 @@
1
+ # typed: strong
2
+
3
+ module Turbopuffer
4
+ module Models
5
+ class HighlightConfigParams < Turbopuffer::Internal::Type::BaseModel
6
+ OrHash =
7
+ T.type_alias do
8
+ T.any(
9
+ Turbopuffer::HighlightConfigParams,
10
+ Turbopuffer::Internal::AnyHash
11
+ )
12
+ end
13
+
14
+ # How to split a text attribute into fragments for highlighting.
15
+ sig { returns(T.nilable(Turbopuffer::HighlightFragmentBy::OrSymbol)) }
16
+ attr_reader :fragment_by
17
+
18
+ sig do
19
+ params(fragment_by: Turbopuffer::HighlightFragmentBy::OrSymbol).void
20
+ end
21
+ attr_writer :fragment_by
22
+
23
+ # The maximum number of fragments to return. Defaults to `3`.
24
+ sig { returns(T.nilable(Integer)) }
25
+ attr_reader :fragment_limit
26
+
27
+ sig { params(fragment_limit: Integer).void }
28
+ attr_writer :fragment_limit
29
+
30
+ # The units to report highlighted fragment offsets in.
31
+ sig { returns(T.nilable(Turbopuffer::HighlightOffsetUnits::OrSymbol)) }
32
+ attr_reader :include_offsets
33
+
34
+ sig do
35
+ params(
36
+ include_offsets: Turbopuffer::HighlightOffsetUnits::OrSymbol
37
+ ).void
38
+ end
39
+ attr_writer :include_offsets
40
+
41
+ # How to rank candidate fragments within the attribute before selecting the top
42
+ # `fragment_limit`. Defaults to the query's `rank_by`.
43
+ sig { returns(T.nilable(T.anything)) }
44
+ attr_reader :rank_fragments_by
45
+
46
+ sig { params(rank_fragments_by: T.anything).void }
47
+ attr_writer :rank_fragments_by
48
+
49
+ # Additional (optional) parameters for the Highlight compute expression.
50
+ sig do
51
+ params(
52
+ fragment_by: Turbopuffer::HighlightFragmentBy::OrSymbol,
53
+ fragment_limit: Integer,
54
+ include_offsets: Turbopuffer::HighlightOffsetUnits::OrSymbol,
55
+ rank_fragments_by: T.anything
56
+ ).returns(T.attached_class)
57
+ end
58
+ def self.new(
59
+ # How to split a text attribute into fragments for highlighting.
60
+ fragment_by: nil,
61
+ # The maximum number of fragments to return. Defaults to `3`.
62
+ fragment_limit: nil,
63
+ # The units to report highlighted fragment offsets in.
64
+ include_offsets: nil,
65
+ # How to rank candidate fragments within the attribute before selecting the top
66
+ # `fragment_limit`. Defaults to the query's `rank_by`.
67
+ rank_fragments_by: nil
68
+ )
69
+ end
70
+
71
+ sig do
72
+ override.returns(
73
+ {
74
+ fragment_by: Turbopuffer::HighlightFragmentBy::OrSymbol,
75
+ fragment_limit: Integer,
76
+ include_offsets: Turbopuffer::HighlightOffsetUnits::OrSymbol,
77
+ rank_fragments_by: T.anything
78
+ }
79
+ )
80
+ end
81
+ def to_hash
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,36 @@
1
+ # typed: strong
2
+
3
+ module Turbopuffer
4
+ module Models
5
+ # How to split a text attribute into fragments for highlighting.
6
+ module HighlightFragmentBy
7
+ extend Turbopuffer::Internal::Type::Enum
8
+
9
+ TaggedSymbol =
10
+ T.type_alias { T.all(Symbol, Turbopuffer::HighlightFragmentBy) }
11
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
12
+
13
+ # Treat the whole attribute as a single fragment.
14
+ NONE = T.let(:none, Turbopuffer::HighlightFragmentBy::TaggedSymbol)
15
+
16
+ # Split the attribute into sentences. This is the default.
17
+ SENTENCE =
18
+ T.let(:sentence, Turbopuffer::HighlightFragmentBy::TaggedSymbol)
19
+
20
+ # Split the attribute into paragraphs.
21
+ PARAGRAPH =
22
+ T.let(:paragraph, Turbopuffer::HighlightFragmentBy::TaggedSymbol)
23
+
24
+ # Split the attribute into individual words.
25
+ WORD = T.let(:word, Turbopuffer::HighlightFragmentBy::TaggedSymbol)
26
+
27
+ sig do
28
+ override.returns(
29
+ T::Array[Turbopuffer::HighlightFragmentBy::TaggedSymbol]
30
+ )
31
+ end
32
+ def self.values
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,27 @@
1
+ # typed: strong
2
+
3
+ module Turbopuffer
4
+ module Models
5
+ # The units to report highlighted fragment offsets in.
6
+ module HighlightOffsetUnits
7
+ extend Turbopuffer::Internal::Type::Enum
8
+
9
+ TaggedSymbol =
10
+ T.type_alias { T.all(Symbol, Turbopuffer::HighlightOffsetUnits) }
11
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
12
+
13
+ UTF_8 = T.let(:"utf-8", Turbopuffer::HighlightOffsetUnits::TaggedSymbol)
14
+ UTF_16 = T.let(:"utf-16", Turbopuffer::HighlightOffsetUnits::TaggedSymbol)
15
+ CODEPOINTS =
16
+ T.let(:codepoints, Turbopuffer::HighlightOffsetUnits::TaggedSymbol)
17
+
18
+ sig do
19
+ override.returns(
20
+ T::Array[Turbopuffer::HighlightOffsetUnits::TaggedSymbol]
21
+ )
22
+ end
23
+ def self.values
24
+ end
25
+ end
26
+ end
27
+ end
@@ -24,6 +24,30 @@ module Turbopuffer
24
24
  sig { returns(String) }
25
25
  attr_accessor :source_namespace
26
26
 
27
+ # (Optional) The encryption configuration for the destination namespace.
28
+ sig do
29
+ returns(
30
+ T.nilable(
31
+ T.any(
32
+ Turbopuffer::Encryption::CustomerManaged,
33
+ Turbopuffer::Encryption::Default
34
+ )
35
+ )
36
+ )
37
+ end
38
+ attr_reader :dest_encryption
39
+
40
+ sig do
41
+ params(
42
+ dest_encryption:
43
+ T.any(
44
+ Turbopuffer::Encryption::CustomerManaged::OrHash,
45
+ Turbopuffer::Encryption::Default::OrHash
46
+ )
47
+ ).void
48
+ end
49
+ attr_writer :dest_encryption
50
+
27
51
  # (Optional) An API key for the organization containing the source namespace
28
52
  sig { returns(T.nilable(String)) }
29
53
  attr_reader :source_api_key
@@ -42,6 +66,11 @@ module Turbopuffer
42
66
  params(
43
67
  source_namespace: String,
44
68
  namespace: String,
69
+ dest_encryption:
70
+ T.any(
71
+ Turbopuffer::Encryption::CustomerManaged::OrHash,
72
+ Turbopuffer::Encryption::Default::OrHash
73
+ ),
45
74
  source_api_key: String,
46
75
  source_region: String,
47
76
  request_options: Turbopuffer::RequestOptions::OrHash
@@ -51,6 +80,8 @@ module Turbopuffer
51
80
  # The namespace to copy documents from.
52
81
  source_namespace:,
53
82
  namespace: nil,
83
+ # (Optional) The encryption configuration for the destination namespace.
84
+ dest_encryption: nil,
54
85
  # (Optional) An API key for the organization containing the source namespace
55
86
  source_api_key: nil,
56
87
  # (Optional) The region of the source namespace.
@@ -64,6 +95,11 @@ module Turbopuffer
64
95
  {
65
96
  namespace: String,
66
97
  source_namespace: String,
98
+ dest_encryption:
99
+ T.any(
100
+ Turbopuffer::Encryption::CustomerManaged,
101
+ Turbopuffer::Encryption::Default
102
+ ),
67
103
  source_api_key: String,
68
104
  source_region: String,
69
105
  request_options: Turbopuffer::RequestOptions
@@ -28,6 +28,15 @@ module Turbopuffer
28
28
  sig { params(aggregate_by: T::Hash[Symbol, T.anything]).void }
29
29
  attr_writer :aggregate_by
30
30
 
31
+ # Computes additional values on documents returned by a query. Each key is the
32
+ # name of the computed attribute; each value is an expression describing how to
33
+ # compute it.
34
+ sig { returns(T.nilable(T::Hash[Symbol, T.anything])) }
35
+ attr_reader :compute_attributes
36
+
37
+ sig { params(compute_attributes: T::Hash[Symbol, T.anything]).void }
38
+ attr_writer :compute_attributes
39
+
31
40
  # The consistency level for a query.
32
41
  sig do
33
42
  returns(
@@ -122,6 +131,7 @@ module Turbopuffer
122
131
  params(
123
132
  namespace: String,
124
133
  aggregate_by: T::Hash[Symbol, T.anything],
134
+ compute_attributes: T::Hash[Symbol, T.anything],
125
135
  consistency:
126
136
  Turbopuffer::NamespaceExplainQueryParams::Consistency::OrHash,
127
137
  distance_metric: Turbopuffer::DistanceMetric::OrSymbol,
@@ -141,6 +151,10 @@ module Turbopuffer
141
151
  # Aggregations to compute over all documents in the namespace that match the
142
152
  # filters.
143
153
  aggregate_by: nil,
154
+ # Computes additional values on documents returned by a query. Each key is the
155
+ # name of the computed attribute; each value is an expression describing how to
156
+ # compute it.
157
+ compute_attributes: nil,
144
158
  # The consistency level for a query.
145
159
  consistency: nil,
146
160
  # A function used to calculate vector similarity.
@@ -173,6 +187,7 @@ module Turbopuffer
173
187
  {
174
188
  namespace: String,
175
189
  aggregate_by: T::Hash[Symbol, T.anything],
190
+ compute_attributes: T::Hash[Symbol, T.anything],
176
191
  consistency: Turbopuffer::NamespaceExplainQueryParams::Consistency,
177
192
  distance_metric: Turbopuffer::DistanceMetric::OrSymbol,
178
193
  exclude_attributes: T::Array[String],
@@ -45,6 +45,16 @@ module Turbopuffer
45
45
  end
46
46
  attr_writer :pinning
47
47
 
48
+ # Configuration for namespace sharding, which partitions a namespace's documents
49
+ # across multiple internal shards to scale indexing and query throughput beyond a
50
+ # single machine. Sharding can only be configured on a namespace's inaugural
51
+ # write, and cannot be added to or changed on an existing namespace.
52
+ sig { returns(T.nilable(Turbopuffer::ShardingConfig)) }
53
+ attr_reader :sharding
54
+
55
+ sig { params(sharding: Turbopuffer::ShardingConfig::OrHash).void }
56
+ attr_writer :sharding
57
+
48
58
  # Metadata about a namespace.
49
59
  sig do
50
60
  params(
@@ -63,7 +73,8 @@ module Turbopuffer
63
73
  ),
64
74
  schema: T::Hash[Symbol, Turbopuffer::AttributeSchemaConfig::OrHash],
65
75
  updated_at: Time,
66
- pinning: Turbopuffer::NamespaceMetadata::Pinning::OrHash
76
+ pinning: Turbopuffer::NamespaceMetadata::Pinning::OrHash,
77
+ sharding: Turbopuffer::ShardingConfig::OrHash
67
78
  ).returns(T.attached_class)
68
79
  end
69
80
  def self.new(
@@ -82,7 +93,12 @@ module Turbopuffer
82
93
  updated_at:,
83
94
  # Configuration for namespace pinning, along with the current status of the pinned
84
95
  # namespace.
85
- pinning: nil
96
+ pinning: nil,
97
+ # Configuration for namespace sharding, which partitions a namespace's documents
98
+ # across multiple internal shards to scale indexing and query throughput beyond a
99
+ # single machine. Sharding can only be configured on a namespace's inaugural
100
+ # write, and cannot be added to or changed on an existing namespace.
101
+ sharding: nil
86
102
  )
87
103
  end
88
104
 
@@ -96,7 +112,8 @@ module Turbopuffer
96
112
  index: Turbopuffer::NamespaceMetadata::Index::Variants,
97
113
  schema: T::Hash[Symbol, Turbopuffer::AttributeSchemaConfig],
98
114
  updated_at: Time,
99
- pinning: Turbopuffer::NamespaceMetadata::Pinning
115
+ pinning: Turbopuffer::NamespaceMetadata::Pinning,
116
+ sharding: Turbopuffer::ShardingConfig
100
117
  }
101
118
  )
102
119
  end
@@ -110,6 +110,15 @@ module Turbopuffer
110
110
  sig { params(aggregate_by: T::Hash[Symbol, T.anything]).void }
111
111
  attr_writer :aggregate_by
112
112
 
113
+ # Computes additional values on documents returned by a query. Each key is the
114
+ # name of the computed attribute; each value is an expression describing how to
115
+ # compute it.
116
+ sig { returns(T.nilable(T::Hash[Symbol, T.anything])) }
117
+ attr_reader :compute_attributes
118
+
119
+ sig { params(compute_attributes: T::Hash[Symbol, T.anything]).void }
120
+ attr_writer :compute_attributes
121
+
113
122
  # A function used to calculate vector similarity.
114
123
  sig { returns(T.nilable(Turbopuffer::DistanceMetric::OrSymbol)) }
115
124
  attr_reader :distance_metric
@@ -179,6 +188,7 @@ module Turbopuffer
179
188
  sig do
180
189
  params(
181
190
  aggregate_by: T::Hash[Symbol, T.anything],
191
+ compute_attributes: T::Hash[Symbol, T.anything],
182
192
  distance_metric: Turbopuffer::DistanceMetric::OrSymbol,
183
193
  exclude_attributes: T::Array[String],
184
194
  filters: T.anything,
@@ -193,6 +203,10 @@ module Turbopuffer
193
203
  # Aggregations to compute over all documents in the namespace that match the
194
204
  # filters.
195
205
  aggregate_by: nil,
206
+ # Computes additional values on documents returned by a query. Each key is the
207
+ # name of the computed attribute; each value is an expression describing how to
208
+ # compute it.
209
+ compute_attributes: nil,
196
210
  # A function used to calculate vector similarity.
197
211
  distance_metric: nil,
198
212
  # List of attribute names to exclude from the response. All other attributes will
@@ -219,6 +233,7 @@ module Turbopuffer
219
233
  override.returns(
220
234
  {
221
235
  aggregate_by: T::Hash[Symbol, T.anything],
236
+ compute_attributes: T::Hash[Symbol, T.anything],
222
237
  distance_metric: Turbopuffer::DistanceMetric::OrSymbol,
223
238
  exclude_attributes: T::Array[String],
224
239
  filters: T.anything,
@@ -28,6 +28,15 @@ module Turbopuffer
28
28
  sig { params(aggregate_by: T::Hash[Symbol, T.anything]).void }
29
29
  attr_writer :aggregate_by
30
30
 
31
+ # Computes additional values on documents returned by a query. Each key is the
32
+ # name of the computed attribute; each value is an expression describing how to
33
+ # compute it.
34
+ sig { returns(T.nilable(T::Hash[Symbol, T.anything])) }
35
+ attr_reader :compute_attributes
36
+
37
+ sig { params(compute_attributes: T::Hash[Symbol, T.anything]).void }
38
+ attr_writer :compute_attributes
39
+
31
40
  # The consistency level for a query.
32
41
  sig { returns(T.nilable(Turbopuffer::NamespaceQueryParams::Consistency)) }
33
42
  attr_reader :consistency
@@ -117,6 +126,7 @@ module Turbopuffer
117
126
  params(
118
127
  namespace: String,
119
128
  aggregate_by: T::Hash[Symbol, T.anything],
129
+ compute_attributes: T::Hash[Symbol, T.anything],
120
130
  consistency: Turbopuffer::NamespaceQueryParams::Consistency::OrHash,
121
131
  distance_metric: Turbopuffer::DistanceMetric::OrSymbol,
122
132
  exclude_attributes: T::Array[String],
@@ -135,6 +145,10 @@ module Turbopuffer
135
145
  # Aggregations to compute over all documents in the namespace that match the
136
146
  # filters.
137
147
  aggregate_by: nil,
148
+ # Computes additional values on documents returned by a query. Each key is the
149
+ # name of the computed attribute; each value is an expression describing how to
150
+ # compute it.
151
+ compute_attributes: nil,
138
152
  # The consistency level for a query.
139
153
  consistency: nil,
140
154
  # A function used to calculate vector similarity.
@@ -167,6 +181,7 @@ module Turbopuffer
167
181
  {
168
182
  namespace: String,
169
183
  aggregate_by: T::Hash[Symbol, T.anything],
184
+ compute_attributes: T::Hash[Symbol, T.anything],
170
185
  consistency: Turbopuffer::NamespaceQueryParams::Consistency,
171
186
  distance_metric: Turbopuffer::DistanceMetric::OrSymbol,
172
187
  exclude_attributes: T::Array[String],
@@ -209,6 +209,16 @@ module Turbopuffer
209
209
  end
210
210
  attr_writer :schema
211
211
 
212
+ # Configuration for namespace sharding, which partitions a namespace's documents
213
+ # across multiple internal shards to scale indexing and query throughput beyond a
214
+ # single machine. Sharding can only be configured on a namespace's inaugural
215
+ # write, and cannot be added to or changed on an existing namespace.
216
+ sig { returns(T.nilable(Turbopuffer::ShardingConfig)) }
217
+ attr_reader :sharding
218
+
219
+ sig { params(sharding: Turbopuffer::ShardingConfig::OrHash).void }
220
+ attr_writer :sharding
221
+
212
222
  # A list of documents in columnar format. Each key is a column name, mapped to an
213
223
  # array of values for that column.
214
224
  sig { returns(T.nilable(Turbopuffer::Columns)) }
@@ -267,6 +277,7 @@ module Turbopuffer
267
277
  Symbol,
268
278
  T.any(String, Turbopuffer::AttributeSchemaConfig::OrHash)
269
279
  ],
280
+ sharding: Turbopuffer::ShardingConfig::OrHash,
270
281
  upsert_columns: Turbopuffer::Columns::OrHash,
271
282
  upsert_condition: T.anything,
272
283
  upsert_rows: T::Array[Turbopuffer::Row::OrHash],
@@ -310,6 +321,11 @@ module Turbopuffer
310
321
  return_affected_ids: nil,
311
322
  # The schema of the attributes attached to the documents.
312
323
  schema: nil,
324
+ # Configuration for namespace sharding, which partitions a namespace's documents
325
+ # across multiple internal shards to scale indexing and query throughput beyond a
326
+ # single machine. Sharding can only be configured on a namespace's inaugural
327
+ # write, and cannot be added to or changed on an existing namespace.
328
+ sharding: nil,
313
329
  # A list of documents in columnar format. Each key is a column name, mapped to an
314
330
  # array of values for that column.
315
331
  upsert_columns: nil,
@@ -357,6 +373,7 @@ module Turbopuffer
357
373
  Symbol,
358
374
  T.any(String, Turbopuffer::AttributeSchemaConfig)
359
375
  ],
376
+ sharding: Turbopuffer::ShardingConfig,
360
377
  upsert_columns: Turbopuffer::Columns,
361
378
  upsert_condition: T.anything,
362
379
  upsert_rows: T::Array[Turbopuffer::Row],
@@ -15,15 +15,34 @@ module Turbopuffer
15
15
  sig { params(rank_constant: Integer).void }
16
16
  attr_writer :rank_constant
17
17
 
18
+ # A positive weight for each subquery, in the same order as `queries`. The number
19
+ # of weights must match the number of subqueries. When omitted, every subquery has
20
+ # a weight of `1`.
21
+ sig { returns(T.nilable(T::Array[Float])) }
22
+ attr_reader :weights
23
+
24
+ sig { params(weights: T::Array[Float]).void }
25
+ attr_writer :weights
26
+
18
27
  # Configuration options for RRF.
19
- sig { params(rank_constant: Integer).returns(T.attached_class) }
28
+ sig do
29
+ params(rank_constant: Integer, weights: T::Array[Float]).returns(
30
+ T.attached_class
31
+ )
32
+ end
20
33
  def self.new(
21
34
  # RRF rank constant (`k`). Must be greater than zero. Defaults to `60`.
22
- rank_constant: nil
35
+ rank_constant: nil,
36
+ # A positive weight for each subquery, in the same order as `queries`. The number
37
+ # of weights must match the number of subqueries. When omitted, every subquery has
38
+ # a weight of `1`.
39
+ weights: nil
23
40
  )
24
41
  end
25
42
 
26
- sig { override.returns({ rank_constant: Integer }) }
43
+ sig do
44
+ override.returns({ rank_constant: Integer, weights: T::Array[Float] })
45
+ end
27
46
  def to_hash
28
47
  end
29
48
  end
@@ -0,0 +1,31 @@
1
+ # typed: strong
2
+
3
+ module Turbopuffer
4
+ module Models
5
+ class ShardingConfig < Turbopuffer::Internal::Type::BaseModel
6
+ OrHash =
7
+ T.type_alias do
8
+ T.any(Turbopuffer::ShardingConfig, Turbopuffer::Internal::AnyHash)
9
+ end
10
+
11
+ # The number of shards to partition the namespace into.
12
+ sig { returns(Integer) }
13
+ attr_accessor :num_shards
14
+
15
+ # Configuration for namespace sharding, which partitions a namespace's documents
16
+ # across multiple internal shards to scale indexing and query throughput beyond a
17
+ # single machine. Sharding can only be configured on a namespace's inaugural
18
+ # write, and cannot be added to or changed on an existing namespace.
19
+ sig { params(num_shards: Integer).returns(T.attached_class) }
20
+ def self.new(
21
+ # The number of shards to partition the namespace into.
22
+ num_shards:
23
+ )
24
+ end
25
+
26
+ sig { override.returns({ num_shards: Integer }) }
27
+ def to_hash
28
+ end
29
+ end
30
+ end
31
+ end
@@ -49,6 +49,12 @@ module Turbopuffer
49
49
 
50
50
  FuzzyParams = Turbopuffer::Models::FuzzyParams
51
51
 
52
+ HighlightConfigParams = Turbopuffer::Models::HighlightConfigParams
53
+
54
+ HighlightFragmentBy = Turbopuffer::Models::HighlightFragmentBy
55
+
56
+ HighlightOffsetUnits = Turbopuffer::Models::HighlightOffsetUnits
57
+
52
58
  ID = Turbopuffer::Models::ID
53
59
 
54
60
  IncludeAttributes = Turbopuffer::Models::IncludeAttributes
@@ -103,6 +109,8 @@ module Turbopuffer
103
109
 
104
110
  SaturateParams = Turbopuffer::Models::SaturateParams
105
111
 
112
+ ShardingConfig = Turbopuffer::Models::ShardingConfig
113
+
106
114
  SparseDistanceMetric = Turbopuffer::Models::SparseDistanceMetric
107
115
 
108
116
  Tokenizer = Turbopuffer::Models::Tokenizer
@@ -25,6 +25,11 @@ module Turbopuffer
25
25
  params(
26
26
  source_namespace: String,
27
27
  namespace: String,
28
+ dest_encryption:
29
+ T.any(
30
+ Turbopuffer::Encryption::CustomerManaged::OrHash,
31
+ Turbopuffer::Encryption::Default::OrHash
32
+ ),
28
33
  source_api_key: String,
29
34
  source_region: String,
30
35
  request_options: Turbopuffer::RequestOptions::OrHash
@@ -35,6 +40,9 @@ module Turbopuffer
35
40
  source_namespace:,
36
41
  # Path param: The name of the namespace.
37
42
  namespace: nil,
43
+ # Body param: (Optional) The encryption configuration for the destination
44
+ # namespace.
45
+ dest_encryption: nil,
38
46
  # Body param: (Optional) An API key for the organization containing the source
39
47
  # namespace
40
48
  source_api_key: nil,
@@ -63,6 +71,7 @@ module Turbopuffer
63
71
  params(
64
72
  namespace: String,
65
73
  aggregate_by: T::Hash[Symbol, T.anything],
74
+ compute_attributes: T::Hash[Symbol, T.anything],
66
75
  consistency:
67
76
  Turbopuffer::NamespaceExplainQueryParams::Consistency::OrHash,
68
77
  distance_metric: Turbopuffer::DistanceMetric::OrSymbol,
@@ -83,6 +92,10 @@ module Turbopuffer
83
92
  # Body param: Aggregations to compute over all documents in the namespace that
84
93
  # match the filters.
85
94
  aggregate_by: nil,
95
+ # Body param: Computes additional values on documents returned by a query. Each
96
+ # key is the name of the computed attribute; each value is an expression
97
+ # describing how to compute it.
98
+ compute_attributes: nil,
86
99
  # Body param: The consistency level for a query.
87
100
  consistency: nil,
88
101
  # Body param: A function used to calculate vector similarity.
@@ -172,6 +185,7 @@ module Turbopuffer
172
185
  params(
173
186
  namespace: T.nilable(String),
174
187
  aggregate_by: T::Hash[Symbol, T.anything],
188
+ compute_attributes: T::Hash[Symbol, T.anything],
175
189
  consistency: Turbopuffer::NamespaceQueryParams::Consistency::OrHash,
176
190
  distance_metric: Turbopuffer::DistanceMetric::OrSymbol,
177
191
  exclude_attributes: T::Array[String],
@@ -191,6 +205,10 @@ module Turbopuffer
191
205
  # Body param: Aggregations to compute over all documents in the namespace that
192
206
  # match the filters.
193
207
  aggregate_by: nil,
208
+ # Body param: Computes additional values on documents returned by a query. Each
209
+ # key is the name of the computed attribute; each value is an expression
210
+ # describing how to compute it.
211
+ compute_attributes: nil,
194
212
  # Body param: The consistency level for a query.
195
213
  consistency: nil,
196
214
  # Body param: A function used to calculate vector similarity.
@@ -344,6 +362,7 @@ module Turbopuffer
344
362
  Symbol,
345
363
  T.any(String, Turbopuffer::AttributeSchemaConfig::OrHash)
346
364
  ],
365
+ sharding: Turbopuffer::ShardingConfig::OrHash,
347
366
  upsert_columns: Turbopuffer::Columns::OrHash,
348
367
  upsert_condition: T.anything,
349
368
  upsert_rows: T::Array[Turbopuffer::Row::OrHash],
@@ -391,6 +410,11 @@ module Turbopuffer
391
410
  return_affected_ids: nil,
392
411
  # Body param: The schema of the attributes attached to the documents.
393
412
  schema: nil,
413
+ # Body param: Configuration for namespace sharding, which partitions a namespace's
414
+ # documents across multiple internal shards to scale indexing and query throughput
415
+ # beyond a single machine. Sharding can only be configured on a namespace's
416
+ # inaugural write, and cannot be added to or changed on an existing namespace.
417
+ sharding: nil,
394
418
  # Body param: A list of documents in columnar format. Each key is a column name,
395
419
  # mapped to an array of values for that column.
396
420
  upsert_columns: nil,
@@ -82,7 +82,10 @@ module Turbopuffer
82
82
  extend Turbopuffer::Internal::Type::Union
83
83
 
84
84
  type ann_config =
85
- { distance_metric: Turbopuffer::Models::distance_metric }
85
+ {
86
+ distance_metric: Turbopuffer::Models::distance_metric,
87
+ late_interaction: bool
88
+ }
86
89
 
87
90
  class AnnConfig < Turbopuffer::Internal::Type::BaseModel
88
91
  attr_reader distance_metric: Turbopuffer::Models::distance_metric?
@@ -91,12 +94,18 @@ module Turbopuffer
91
94
  Turbopuffer::Models::distance_metric
92
95
  ) -> Turbopuffer::Models::distance_metric
93
96
 
97
+ attr_reader late_interaction: bool?
98
+
99
+ def late_interaction=: (bool) -> bool
100
+
94
101
  def initialize: (
95
- ?distance_metric: Turbopuffer::Models::distance_metric
102
+ ?distance_metric: Turbopuffer::Models::distance_metric,
103
+ ?late_interaction: bool
96
104
  ) -> void
97
105
 
98
106
  def to_hash: -> {
99
- distance_metric: Turbopuffer::Models::distance_metric
107
+ distance_metric: Turbopuffer::Models::distance_metric,
108
+ late_interaction: bool
100
109
  }
101
110
  end
102
111