turbopuffer 2.3.0 → 2.5.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 (75) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +40 -0
  3. data/README.md +1 -10
  4. data/lib/turbopuffer/client.rb +2 -2
  5. data/lib/turbopuffer/internal/type/union.rb +17 -7
  6. data/lib/turbopuffer/models/attribute_schema_config.rb +14 -1
  7. data/lib/turbopuffer/models/copy_from_namespace_operation.rb +84 -0
  8. data/lib/turbopuffer/models/copy_from_namespace_operation_result.rb +37 -0
  9. data/lib/turbopuffer/models/highlight_config_params.rb +46 -0
  10. data/lib/turbopuffer/models/highlight_fragment_by.rb +25 -0
  11. data/lib/turbopuffer/models/highlight_offset_units.rb +17 -0
  12. data/lib/turbopuffer/models/namespace_explain_query_params.rb +20 -1
  13. data/lib/turbopuffer/models/namespace_metadata.rb +32 -2
  14. data/lib/turbopuffer/models/namespace_metadata_patch.rb +10 -1
  15. data/lib/turbopuffer/models/namespace_multi_query_params.rb +55 -2
  16. data/lib/turbopuffer/models/namespace_poll_copy_from_params.rb +26 -0
  17. data/lib/turbopuffer/models/namespace_query_params.rb +20 -1
  18. data/lib/turbopuffer/models/namespace_start_copy_from_params.rb +53 -0
  19. data/lib/turbopuffer/models/namespace_start_copy_from_response.rb +17 -0
  20. data/lib/turbopuffer/models/namespace_write_params.rb +12 -1
  21. data/lib/turbopuffer/models/operation_error.rb +46 -0
  22. data/lib/turbopuffer/models/rerank_limit.rb +18 -0
  23. data/lib/turbopuffer/models/rrf_params.rb +14 -1
  24. data/lib/turbopuffer/models/sharding_config.rb +21 -0
  25. data/lib/turbopuffer/models/write_result.rb +112 -0
  26. data/lib/turbopuffer/models.rb +22 -0
  27. data/lib/turbopuffer/resources/namespaces.rb +87 -5
  28. data/lib/turbopuffer/version.rb +1 -1
  29. data/lib/turbopuffer.rb +12 -0
  30. data/rbi/turbopuffer/client.rbi +2 -2
  31. data/rbi/turbopuffer/models/attribute_schema_config.rbi +20 -3
  32. data/rbi/turbopuffer/models/copy_from_namespace_operation.rbi +133 -0
  33. data/rbi/turbopuffer/models/copy_from_namespace_operation_result.rbi +85 -0
  34. data/rbi/turbopuffer/models/highlight_config_params.rbi +85 -0
  35. data/rbi/turbopuffer/models/highlight_fragment_by.rbi +36 -0
  36. data/rbi/turbopuffer/models/highlight_offset_units.rbi +27 -0
  37. data/rbi/turbopuffer/models/namespace_explain_query_params.rbi +28 -0
  38. data/rbi/turbopuffer/models/namespace_metadata.rbi +50 -4
  39. data/rbi/turbopuffer/models/namespace_metadata_patch.rbi +18 -3
  40. data/rbi/turbopuffer/models/namespace_multi_query_params.rbi +69 -0
  41. data/rbi/turbopuffer/models/namespace_poll_copy_from_params.rbi +49 -0
  42. data/rbi/turbopuffer/models/namespace_query_params.rbi +28 -0
  43. data/rbi/turbopuffer/models/namespace_start_copy_from_params.rbi +113 -0
  44. data/rbi/turbopuffer/models/namespace_start_copy_from_response.rbi +30 -0
  45. data/rbi/turbopuffer/models/namespace_write_params.rbi +17 -0
  46. data/rbi/turbopuffer/models/operation_error.rbi +77 -0
  47. data/rbi/turbopuffer/models/rerank_limit.rbi +28 -0
  48. data/rbi/turbopuffer/models/rrf_params.rbi +22 -3
  49. data/rbi/turbopuffer/models/sharding_config.rbi +31 -0
  50. data/rbi/turbopuffer/models/write_result.rbi +159 -0
  51. data/rbi/turbopuffer/models.rbi +24 -0
  52. data/rbi/turbopuffer/resources/namespaces.rbi +87 -0
  53. data/sig/turbopuffer/models/attribute_schema_config.rbs +12 -3
  54. data/sig/turbopuffer/models/copy_from_namespace_operation.rbs +65 -0
  55. data/sig/turbopuffer/models/copy_from_namespace_operation_result.rbs +33 -0
  56. data/sig/turbopuffer/models/highlight_config_params.rbs +47 -0
  57. data/sig/turbopuffer/models/highlight_fragment_by.rbs +23 -0
  58. data/sig/turbopuffer/models/highlight_offset_units.rbs +15 -0
  59. data/sig/turbopuffer/models/namespace_explain_query_params.rbs +14 -0
  60. data/sig/turbopuffer/models/namespace_metadata.rbs +29 -4
  61. data/sig/turbopuffer/models/namespace_metadata_patch.rbs +12 -3
  62. data/sig/turbopuffer/models/namespace_multi_query_params.rbs +38 -0
  63. data/sig/turbopuffer/models/namespace_poll_copy_from_params.rbs +30 -0
  64. data/sig/turbopuffer/models/namespace_query_params.rbs +14 -0
  65. data/sig/turbopuffer/models/namespace_start_copy_from_params.rbs +56 -0
  66. data/sig/turbopuffer/models/namespace_start_copy_from_response.rbs +13 -0
  67. data/sig/turbopuffer/models/namespace_write_params.rbs +9 -0
  68. data/sig/turbopuffer/models/operation_error.rbs +34 -0
  69. data/sig/turbopuffer/models/rerank_limit.rbs +13 -0
  70. data/sig/turbopuffer/models/rrf_params.rbs +10 -3
  71. data/sig/turbopuffer/models/sharding_config.rbs +13 -0
  72. data/sig/turbopuffer/models/write_result.rbs +99 -0
  73. data/sig/turbopuffer/models.rbs +22 -0
  74. data/sig/turbopuffer/resources/namespaces.rbs +23 -0
  75. metadata +38 -2
data/lib/turbopuffer.rb CHANGED
@@ -68,6 +68,8 @@ require_relative "turbopuffer/models/client_namespaces_params"
68
68
  require_relative "turbopuffer/models/columns"
69
69
  require_relative "turbopuffer/models/contains_all_tokens_filter_params"
70
70
  require_relative "turbopuffer/models/contains_any_token_filter_params"
71
+ require_relative "turbopuffer/models/copy_from_namespace_operation"
72
+ require_relative "turbopuffer/models/copy_from_namespace_operation_result"
71
73
  require_relative "turbopuffer/models/copy_from_namespace_params"
72
74
  require_relative "turbopuffer/models/decay_params"
73
75
  require_relative "turbopuffer/models/distance_metric"
@@ -77,6 +79,9 @@ require_relative "turbopuffer/models/full_text_search"
77
79
  require_relative "turbopuffer/models/full_text_search_config"
78
80
  require_relative "turbopuffer/models/fuzzy_max_edit_distance"
79
81
  require_relative "turbopuffer/models/fuzzy_params"
82
+ require_relative "turbopuffer/models/highlight_config_params"
83
+ require_relative "turbopuffer/models/highlight_fragment_by"
84
+ require_relative "turbopuffer/models/highlight_offset_units"
80
85
  require_relative "turbopuffer/models/id"
81
86
  require_relative "turbopuffer/models/include_attributes"
82
87
  require_relative "turbopuffer/models/language"
@@ -95,29 +100,36 @@ require_relative "turbopuffer/models/namespace_metadata"
95
100
  require_relative "turbopuffer/models/namespace_metadata_params"
96
101
  require_relative "turbopuffer/models/namespace_multi_query_params"
97
102
  require_relative "turbopuffer/models/namespace_multi_query_response"
103
+ require_relative "turbopuffer/models/namespace_poll_copy_from_params"
98
104
  require_relative "turbopuffer/models/namespace_query_params"
99
105
  require_relative "turbopuffer/models/namespace_query_response"
100
106
  require_relative "turbopuffer/models/namespace_recall_params"
101
107
  require_relative "turbopuffer/models/namespace_recall_response"
102
108
  require_relative "turbopuffer/models/namespace_schema_params"
103
109
  require_relative "turbopuffer/models/namespace_schema_response"
110
+ require_relative "turbopuffer/models/namespace_start_copy_from_params"
111
+ require_relative "turbopuffer/models/namespace_start_copy_from_response"
104
112
  require_relative "turbopuffer/models/namespace_summary"
105
113
  require_relative "turbopuffer/models/namespace_update_metadata_params"
106
114
  require_relative "turbopuffer/models/namespace_update_schema_params"
107
115
  require_relative "turbopuffer/models/namespace_update_schema_response"
108
116
  require_relative "turbopuffer/models/namespace_write_params"
109
117
  require_relative "turbopuffer/models/namespace_write_response"
118
+ require_relative "turbopuffer/models/operation_error"
110
119
  require_relative "turbopuffer/models/query_billing"
111
120
  require_relative "turbopuffer/models/query_performance"
121
+ require_relative "turbopuffer/models/rerank_limit"
112
122
  require_relative "turbopuffer/models/row"
113
123
  require_relative "turbopuffer/models/rrf_params"
114
124
  require_relative "turbopuffer/models/saturate_params"
125
+ require_relative "turbopuffer/models/sharding_config"
115
126
  require_relative "turbopuffer/models/sparse_distance_metric"
116
127
  require_relative "turbopuffer/models/tokenizer"
117
128
  require_relative "turbopuffer/models/vector"
118
129
  require_relative "turbopuffer/models/vector_encoding"
119
130
  require_relative "turbopuffer/models/write_billing"
120
131
  require_relative "turbopuffer/models/write_performance"
132
+ require_relative "turbopuffer/models/write_result"
121
133
  require_relative "turbopuffer/models"
122
134
  require_relative "turbopuffer/resources/namespaces"
123
135
  require_relative "turbopuffer/namespace"
@@ -10,7 +10,7 @@ module Turbopuffer
10
10
 
11
11
  DEFAULT_MAX_RETRY_DELAY = T.let(8.0, Float)
12
12
 
13
- # API key used for authentication
13
+ # API key used for authentication.
14
14
  sig { returns(String) }
15
15
  attr_reader :api_key
16
16
 
@@ -73,7 +73,7 @@ module Turbopuffer
73
73
  ).returns(T.attached_class)
74
74
  end
75
75
  def self.new(
76
- # API key used for authentication Defaults to `ENV["TURBOPUFFER_API_KEY"]`
76
+ # API key used for authentication. Defaults to `ENV["TURBOPUFFER_API_KEY"]`
77
77
  api_key: ENV["TURBOPUFFER_API_KEY"],
78
78
  # The turbopuffer region to use. Defaults to `ENV["TURBOPUFFER_REGION"]`
79
79
  region: ENV["TURBOPUFFER_REGION"],
@@ -210,21 +210,38 @@ module Turbopuffer
210
210
  end
211
211
  attr_writer :distance_metric
212
212
 
213
+ # Opt in to late-interaction (MUVERA) indexing. Only valid on fixed-dim `[][N]f32`
214
+ # vector array attributes, and is required to enable an ANN index on such
215
+ # attributes. Defaults to `false`.
216
+ sig { returns(T.nilable(T::Boolean)) }
217
+ attr_reader :late_interaction
218
+
219
+ sig { params(late_interaction: T::Boolean).void }
220
+ attr_writer :late_interaction
221
+
213
222
  # Configuration options for ANN (Approximate Nearest Neighbor) indexing.
214
223
  sig do
215
224
  params(
216
- distance_metric: Turbopuffer::DistanceMetric::OrSymbol
225
+ distance_metric: Turbopuffer::DistanceMetric::OrSymbol,
226
+ late_interaction: T::Boolean
217
227
  ).returns(T.attached_class)
218
228
  end
219
229
  def self.new(
220
230
  # A function used to calculate vector similarity.
221
- distance_metric: nil
231
+ distance_metric: nil,
232
+ # Opt in to late-interaction (MUVERA) indexing. Only valid on fixed-dim `[][N]f32`
233
+ # vector array attributes, and is required to enable an ANN index on such
234
+ # attributes. Defaults to `false`.
235
+ late_interaction: nil
222
236
  )
223
237
  end
224
238
 
225
239
  sig do
226
240
  override.returns(
227
- { distance_metric: Turbopuffer::DistanceMetric::OrSymbol }
241
+ {
242
+ distance_metric: Turbopuffer::DistanceMetric::OrSymbol,
243
+ late_interaction: T::Boolean
244
+ }
228
245
  )
229
246
  end
230
247
  def to_hash
@@ -0,0 +1,133 @@
1
+ # typed: strong
2
+
3
+ module Turbopuffer
4
+ module Models
5
+ # The current status of a copy operation.
6
+ module CopyFromNamespaceOperation
7
+ extend Turbopuffer::Internal::Type::Union
8
+
9
+ Variants =
10
+ T.type_alias do
11
+ T.any(
12
+ Turbopuffer::CopyFromNamespaceOperation::Running,
13
+ Turbopuffer::CopyFromNamespaceOperation::Finished
14
+ )
15
+ end
16
+
17
+ class Running < Turbopuffer::Internal::Type::BaseModel
18
+ OrHash =
19
+ T.type_alias do
20
+ T.any(
21
+ Turbopuffer::CopyFromNamespaceOperation::Running,
22
+ Turbopuffer::Internal::AnyHash
23
+ )
24
+ end
25
+
26
+ # The time at which the operation started.
27
+ sig { returns(Time) }
28
+ attr_accessor :start_time
29
+
30
+ sig { returns(Symbol) }
31
+ attr_accessor :status
32
+
33
+ # A freeform description of the operation's progress. May be absent, and its
34
+ # format may change.
35
+ sig { returns(T.nilable(String)) }
36
+ attr_reader :progress
37
+
38
+ sig { params(progress: String).void }
39
+ attr_writer :progress
40
+
41
+ sig do
42
+ params(start_time: Time, progress: String, status: Symbol).returns(
43
+ T.attached_class
44
+ )
45
+ end
46
+ def self.new(
47
+ # The time at which the operation started.
48
+ start_time:,
49
+ # A freeform description of the operation's progress. May be absent, and its
50
+ # format may change.
51
+ progress: nil,
52
+ status: :running
53
+ )
54
+ end
55
+
56
+ sig do
57
+ override.returns(
58
+ { start_time: Time, status: Symbol, progress: String }
59
+ )
60
+ end
61
+ def to_hash
62
+ end
63
+ end
64
+
65
+ class Finished < Turbopuffer::Internal::Type::BaseModel
66
+ OrHash =
67
+ T.type_alias do
68
+ T.any(
69
+ Turbopuffer::CopyFromNamespaceOperation::Finished,
70
+ Turbopuffer::Internal::AnyHash
71
+ )
72
+ end
73
+
74
+ # The time at which the operation finished.
75
+ sig { returns(Time) }
76
+ attr_accessor :finish_time
77
+
78
+ sig { returns(Turbopuffer::CopyFromNamespaceOperationResult::Variants) }
79
+ attr_accessor :result
80
+
81
+ # The time at which the operation started.
82
+ sig { returns(Time) }
83
+ attr_accessor :start_time
84
+
85
+ sig { returns(Symbol) }
86
+ attr_accessor :status
87
+
88
+ sig do
89
+ params(
90
+ finish_time: Time,
91
+ result:
92
+ T.any(
93
+ Turbopuffer::CopyFromNamespaceOperationResult::Success::OrHash,
94
+ Turbopuffer::CopyFromNamespaceOperationResult::Error::OrHash
95
+ ),
96
+ start_time: Time,
97
+ status: Symbol
98
+ ).returns(T.attached_class)
99
+ end
100
+ def self.new(
101
+ # The time at which the operation finished.
102
+ finish_time:,
103
+ result:,
104
+ # The time at which the operation started.
105
+ start_time:,
106
+ status: :finished
107
+ )
108
+ end
109
+
110
+ sig do
111
+ override.returns(
112
+ {
113
+ finish_time: Time,
114
+ result: Turbopuffer::CopyFromNamespaceOperationResult::Variants,
115
+ start_time: Time,
116
+ status: Symbol
117
+ }
118
+ )
119
+ end
120
+ def to_hash
121
+ end
122
+ end
123
+
124
+ sig do
125
+ override.returns(
126
+ T::Array[Turbopuffer::CopyFromNamespaceOperation::Variants]
127
+ )
128
+ end
129
+ def self.variants
130
+ end
131
+ end
132
+ end
133
+ end
@@ -0,0 +1,85 @@
1
+ # typed: strong
2
+
3
+ module Turbopuffer
4
+ module Models
5
+ module CopyFromNamespaceOperationResult
6
+ extend Turbopuffer::Internal::Type::Union
7
+
8
+ Variants =
9
+ T.type_alias do
10
+ T.any(
11
+ Turbopuffer::CopyFromNamespaceOperationResult::Success,
12
+ Turbopuffer::CopyFromNamespaceOperationResult::Error
13
+ )
14
+ end
15
+
16
+ class Success < Turbopuffer::Internal::Type::BaseModel
17
+ OrHash =
18
+ T.type_alias do
19
+ T.any(
20
+ Turbopuffer::CopyFromNamespaceOperationResult::Success,
21
+ Turbopuffer::Internal::AnyHash
22
+ )
23
+ end
24
+
25
+ # The response to a successful write request.
26
+ sig { returns(Turbopuffer::WriteResult) }
27
+ attr_reader :success
28
+
29
+ sig { params(success: Turbopuffer::WriteResult::OrHash).void }
30
+ attr_writer :success
31
+
32
+ sig do
33
+ params(success: Turbopuffer::WriteResult::OrHash).returns(
34
+ T.attached_class
35
+ )
36
+ end
37
+ def self.new(
38
+ # The response to a successful write request.
39
+ success:
40
+ )
41
+ end
42
+
43
+ sig { override.returns({ success: Turbopuffer::WriteResult }) }
44
+ def to_hash
45
+ end
46
+ end
47
+
48
+ class Error < Turbopuffer::Internal::Type::BaseModel
49
+ OrHash =
50
+ T.type_alias do
51
+ T.any(
52
+ Turbopuffer::CopyFromNamespaceOperationResult::Error,
53
+ Turbopuffer::Internal::AnyHash
54
+ )
55
+ end
56
+
57
+ sig { returns(Turbopuffer::OperationError) }
58
+ attr_reader :error
59
+
60
+ sig { params(error: Turbopuffer::OperationError::OrHash).void }
61
+ attr_writer :error
62
+
63
+ sig do
64
+ params(error: Turbopuffer::OperationError::OrHash).returns(
65
+ T.attached_class
66
+ )
67
+ end
68
+ def self.new(error:)
69
+ end
70
+
71
+ sig { override.returns({ error: Turbopuffer::OperationError }) }
72
+ def to_hash
73
+ end
74
+ end
75
+
76
+ sig do
77
+ override.returns(
78
+ T::Array[Turbopuffer::CopyFromNamespaceOperationResult::Variants]
79
+ )
80
+ end
81
+ def self.variants
82
+ end
83
+ end
84
+ end
85
+ end
@@ -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
@@ -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(
@@ -95,6 +104,14 @@ module Turbopuffer
95
104
  sig { params(limit: T.any(Integer, Turbopuffer::Limit::OrHash)).void }
96
105
  attr_writer :limit
97
106
 
107
+ # Number of documents to skip before returning results. Supported only in v2
108
+ # queries with an explicit `rank_by` and `top_k` or `limit`.
109
+ sig { returns(T.nilable(Integer)) }
110
+ attr_reader :offset
111
+
112
+ sig { params(offset: Integer).void }
113
+ attr_writer :offset
114
+
98
115
  # How to rank the documents in the namespace.
99
116
  sig { returns(T.nilable(T.anything)) }
100
117
  attr_reader :rank_by
@@ -122,6 +139,7 @@ module Turbopuffer
122
139
  params(
123
140
  namespace: String,
124
141
  aggregate_by: T::Hash[Symbol, T.anything],
142
+ compute_attributes: T::Hash[Symbol, T.anything],
125
143
  consistency:
126
144
  Turbopuffer::NamespaceExplainQueryParams::Consistency::OrHash,
127
145
  distance_metric: Turbopuffer::DistanceMetric::OrSymbol,
@@ -130,6 +148,7 @@ module Turbopuffer
130
148
  group_by: T::Array[T.anything],
131
149
  include_attributes: Turbopuffer::IncludeAttributes::Variants,
132
150
  limit: T.any(Integer, Turbopuffer::Limit::OrHash),
151
+ offset: Integer,
133
152
  rank_by: T.anything,
134
153
  top_k: Integer,
135
154
  vector_encoding: Turbopuffer::VectorEncoding::OrSymbol,
@@ -141,6 +160,10 @@ module Turbopuffer
141
160
  # Aggregations to compute over all documents in the namespace that match the
142
161
  # filters.
143
162
  aggregate_by: nil,
163
+ # Computes additional values on documents returned by a query. Each key is the
164
+ # name of the computed attribute; each value is an expression describing how to
165
+ # compute it.
166
+ compute_attributes: nil,
144
167
  # The consistency level for a query.
145
168
  consistency: nil,
146
169
  # A function used to calculate vector similarity.
@@ -158,6 +181,9 @@ module Turbopuffer
158
181
  include_attributes: nil,
159
182
  # Limits the documents returned by a query.
160
183
  limit: nil,
184
+ # Number of documents to skip before returning results. Supported only in v2
185
+ # queries with an explicit `rank_by` and `top_k` or `limit`.
186
+ offset: nil,
161
187
  # How to rank the documents in the namespace.
162
188
  rank_by: nil,
163
189
  # The number of results to return.
@@ -173,6 +199,7 @@ module Turbopuffer
173
199
  {
174
200
  namespace: String,
175
201
  aggregate_by: T::Hash[Symbol, T.anything],
202
+ compute_attributes: T::Hash[Symbol, T.anything],
176
203
  consistency: Turbopuffer::NamespaceExplainQueryParams::Consistency,
177
204
  distance_metric: Turbopuffer::DistanceMetric::OrSymbol,
178
205
  exclude_attributes: T::Array[String],
@@ -180,6 +207,7 @@ module Turbopuffer
180
207
  group_by: T::Array[T.anything],
181
208
  include_attributes: Turbopuffer::IncludeAttributes::Variants,
182
209
  limit: T.any(Integer, Turbopuffer::Limit),
210
+ offset: Integer,
183
211
  rank_by: T.anything,
184
212
  top_k: Integer,
185
213
  vector_encoding: Turbopuffer::VectorEncoding::OrSymbol,
@@ -45,6 +45,23 @@ module Turbopuffer
45
45
  end
46
46
  attr_writer :pinning
47
47
 
48
+ # Whether document and schema writes are rejected. Omitted when `false`.
49
+ sig { returns(T.nilable(T::Boolean)) }
50
+ attr_reader :read_only
51
+
52
+ sig { params(read_only: T::Boolean).void }
53
+ attr_writer :read_only
54
+
55
+ # Configuration for namespace sharding, which partitions a namespace's documents
56
+ # across multiple internal shards to scale indexing and query throughput beyond a
57
+ # single machine. Sharding can only be configured on a namespace's inaugural
58
+ # write, and cannot be added to or changed on an existing namespace.
59
+ sig { returns(T.nilable(Turbopuffer::ShardingConfig)) }
60
+ attr_reader :sharding
61
+
62
+ sig { params(sharding: Turbopuffer::ShardingConfig::OrHash).void }
63
+ attr_writer :sharding
64
+
48
65
  # Metadata about a namespace.
49
66
  sig do
50
67
  params(
@@ -63,7 +80,9 @@ module Turbopuffer
63
80
  ),
64
81
  schema: T::Hash[Symbol, Turbopuffer::AttributeSchemaConfig::OrHash],
65
82
  updated_at: Time,
66
- pinning: Turbopuffer::NamespaceMetadata::Pinning::OrHash
83
+ pinning: Turbopuffer::NamespaceMetadata::Pinning::OrHash,
84
+ read_only: T::Boolean,
85
+ sharding: Turbopuffer::ShardingConfig::OrHash
67
86
  ).returns(T.attached_class)
68
87
  end
69
88
  def self.new(
@@ -82,7 +101,14 @@ module Turbopuffer
82
101
  updated_at:,
83
102
  # Configuration for namespace pinning, along with the current status of the pinned
84
103
  # namespace.
85
- pinning: nil
104
+ pinning: nil,
105
+ # Whether document and schema writes are rejected. Omitted when `false`.
106
+ read_only: nil,
107
+ # Configuration for namespace sharding, which partitions a namespace's documents
108
+ # across multiple internal shards to scale indexing and query throughput beyond a
109
+ # single machine. Sharding can only be configured on a namespace's inaugural
110
+ # write, and cannot be added to or changed on an existing namespace.
111
+ sharding: nil
86
112
  )
87
113
  end
88
114
 
@@ -96,7 +122,9 @@ module Turbopuffer
96
122
  index: Turbopuffer::NamespaceMetadata::Index::Variants,
97
123
  schema: T::Hash[Symbol, Turbopuffer::AttributeSchemaConfig],
98
124
  updated_at: Time,
99
- pinning: Turbopuffer::NamespaceMetadata::Pinning
125
+ pinning: Turbopuffer::NamespaceMetadata::Pinning,
126
+ read_only: T::Boolean,
127
+ sharding: Turbopuffer::ShardingConfig
100
128
  }
101
129
  )
102
130
  end
@@ -235,6 +263,13 @@ module Turbopuffer
235
263
  sig { returns(Integer) }
236
264
  attr_accessor :ready_replicas
237
265
 
266
+ # The number of running replicas for the namespace. Replicas are billed once
267
+ # running, even before they finish warming their caches and become ready to serve
268
+ # traffic. This count is updated independently and may briefly disagree with the
269
+ # other status fields.
270
+ sig { returns(Integer) }
271
+ attr_accessor :replicas
272
+
238
273
  # The timestamp of the latest pinning status snapshot.
239
274
  sig { returns(Time) }
240
275
  attr_accessor :updated_at
@@ -248,6 +283,7 @@ module Turbopuffer
248
283
  sig do
249
284
  params(
250
285
  ready_replicas: Integer,
286
+ replicas: Integer,
251
287
  updated_at: Time,
252
288
  utilization: Float
253
289
  ).returns(T.attached_class)
@@ -255,6 +291,11 @@ module Turbopuffer
255
291
  def self.new(
256
292
  # The number of replicas that are warm and serving traffic.
257
293
  ready_replicas:,
294
+ # The number of running replicas for the namespace. Replicas are billed once
295
+ # running, even before they finish warming their caches and become ready to serve
296
+ # traffic. This count is updated independently and may briefly disagree with the
297
+ # other status fields.
298
+ replicas:,
258
299
  # The timestamp of the latest pinning status snapshot.
259
300
  updated_at:,
260
301
  # Aggregate utilization for the pinned namespace, reported as a value between 0.0
@@ -265,7 +306,12 @@ module Turbopuffer
265
306
 
266
307
  sig do
267
308
  override.returns(
268
- { ready_replicas: Integer, updated_at: Time, utilization: Float }
309
+ {
310
+ ready_replicas: Integer,
311
+ replicas: Integer,
312
+ updated_at: Time,
313
+ utilization: Float
314
+ }
269
315
  )
270
316
  end
271
317
  def to_hash