turbopuffer 0.1.0 → 1.2.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 (207) hide show
  1. checksums.yaml +4 -4
  2. data/.ignore +2 -0
  3. data/CHANGELOG.md +205 -0
  4. data/README.md +270 -40
  5. data/SECURITY.md +27 -0
  6. data/lib/turbopuffer/client.rb +122 -16
  7. data/lib/turbopuffer/errors.rb +228 -0
  8. data/lib/turbopuffer/file_part.rb +55 -0
  9. data/lib/turbopuffer/internal/namespace_page.rb +86 -0
  10. data/lib/turbopuffer/internal/transport/base_client.rb +567 -0
  11. data/lib/turbopuffer/internal/transport/pooled_net_requester.rb +201 -0
  12. data/lib/turbopuffer/internal/type/array_of.rb +168 -0
  13. data/lib/turbopuffer/internal/type/base_model.rb +529 -0
  14. data/lib/turbopuffer/internal/type/base_page.rb +55 -0
  15. data/lib/turbopuffer/internal/type/boolean.rb +77 -0
  16. data/lib/turbopuffer/internal/type/converter.rb +327 -0
  17. data/lib/turbopuffer/internal/type/enum.rb +152 -0
  18. data/lib/turbopuffer/internal/type/file_input.rb +108 -0
  19. data/lib/turbopuffer/internal/type/hash_of.rb +188 -0
  20. data/lib/turbopuffer/internal/type/request_parameters.rb +42 -0
  21. data/lib/turbopuffer/internal/type/union.rb +254 -0
  22. data/lib/turbopuffer/internal/type/unknown.rb +81 -0
  23. data/lib/turbopuffer/internal/util.rb +914 -0
  24. data/lib/turbopuffer/internal.rb +20 -0
  25. data/lib/turbopuffer/models/aggregation_group.rb +8 -0
  26. data/lib/turbopuffer/models/attribute_schema.rb +19 -0
  27. data/lib/turbopuffer/models/attribute_schema_config.rb +56 -0
  28. data/lib/turbopuffer/models/attribute_type.rb +7 -0
  29. data/lib/turbopuffer/models/client_namespaces_params.rb +38 -0
  30. data/lib/turbopuffer/models/columns.rb +64 -0
  31. data/lib/turbopuffer/models/distance_metric.rb +19 -0
  32. data/lib/turbopuffer/models/full_text_search.rb +20 -0
  33. data/lib/turbopuffer/models/full_text_search_config.rb +83 -0
  34. data/lib/turbopuffer/models/id.rb +19 -0
  35. data/lib/turbopuffer/models/include_attributes.rb +22 -0
  36. data/lib/turbopuffer/models/language.rb +32 -0
  37. data/lib/turbopuffer/models/namespace_delete_all_params.rb +20 -0
  38. data/lib/turbopuffer/models/namespace_delete_all_response.rb +19 -0
  39. data/lib/turbopuffer/models/namespace_explain_query_params.rb +137 -0
  40. data/lib/turbopuffer/models/namespace_explain_query_response.rb +19 -0
  41. data/lib/turbopuffer/models/namespace_hint_cache_warm_params.rb +20 -0
  42. data/lib/turbopuffer/models/namespace_hint_cache_warm_response.rb +26 -0
  43. data/lib/turbopuffer/models/namespace_metadata.rb +43 -0
  44. data/lib/turbopuffer/models/namespace_metadata_params.rb +20 -0
  45. data/lib/turbopuffer/models/namespace_multi_query_params.rb +73 -0
  46. data/lib/turbopuffer/models/namespace_multi_query_response.rb +58 -0
  47. data/lib/turbopuffer/models/namespace_query_params.rb +137 -0
  48. data/lib/turbopuffer/models/namespace_query_response.rb +49 -0
  49. data/lib/turbopuffer/models/namespace_recall_params.rb +66 -0
  50. data/lib/turbopuffer/models/namespace_recall_response.rb +68 -0
  51. data/lib/turbopuffer/models/namespace_schema_params.rb +20 -0
  52. data/lib/turbopuffer/models/namespace_schema_response.rb +8 -0
  53. data/lib/turbopuffer/models/namespace_summary.rb +19 -0
  54. data/lib/turbopuffer/models/namespace_update_schema_params.rb +29 -0
  55. data/lib/turbopuffer/models/namespace_update_schema_response.rb +9 -0
  56. data/lib/turbopuffer/models/namespace_write_params.rb +158 -0
  57. data/lib/turbopuffer/models/namespace_write_response.rb +67 -0
  58. data/lib/turbopuffer/models/query.rb +81 -0
  59. data/lib/turbopuffer/models/query_billing.rb +26 -0
  60. data/lib/turbopuffer/models/query_performance.rb +63 -0
  61. data/lib/turbopuffer/models/row.rb +46 -0
  62. data/lib/turbopuffer/models/tokenizer.rb +19 -0
  63. data/lib/turbopuffer/models/vector.rb +22 -0
  64. data/lib/turbopuffer/models/vector_encoding.rb +16 -0
  65. data/lib/turbopuffer/models/write_billing.rb +26 -0
  66. data/lib/turbopuffer/models.rb +106 -0
  67. data/lib/turbopuffer/namespace.rb +14 -50
  68. data/lib/turbopuffer/request_options.rb +77 -0
  69. data/lib/turbopuffer/resources/namespaces.rb +366 -0
  70. data/lib/turbopuffer/version.rb +1 -1
  71. data/lib/turbopuffer.rb +92 -4
  72. data/manifest.yaml +15 -0
  73. data/rbi/turbopuffer/client.rbi +91 -0
  74. data/rbi/turbopuffer/errors.rbi +205 -0
  75. data/rbi/turbopuffer/file_part.rbi +37 -0
  76. data/rbi/turbopuffer/internal/namespace_page.rbi +22 -0
  77. data/rbi/turbopuffer/internal/transport/base_client.rbi +297 -0
  78. data/rbi/turbopuffer/internal/transport/pooled_net_requester.rbi +80 -0
  79. data/rbi/turbopuffer/internal/type/array_of.rbi +104 -0
  80. data/rbi/turbopuffer/internal/type/base_model.rbi +304 -0
  81. data/rbi/turbopuffer/internal/type/base_page.rbi +43 -0
  82. data/rbi/turbopuffer/internal/type/boolean.rbi +58 -0
  83. data/rbi/turbopuffer/internal/type/converter.rbi +216 -0
  84. data/rbi/turbopuffer/internal/type/enum.rbi +82 -0
  85. data/rbi/turbopuffer/internal/type/file_input.rbi +59 -0
  86. data/rbi/turbopuffer/internal/type/hash_of.rbi +104 -0
  87. data/rbi/turbopuffer/internal/type/request_parameters.rbi +31 -0
  88. data/rbi/turbopuffer/internal/type/union.rbi +128 -0
  89. data/rbi/turbopuffer/internal/type/unknown.rbi +58 -0
  90. data/rbi/turbopuffer/internal/util.rbi +487 -0
  91. data/rbi/turbopuffer/internal.rbi +18 -0
  92. data/rbi/turbopuffer/models/aggregation_group.rbi +13 -0
  93. data/rbi/turbopuffer/models/attribute_schema.rbi +17 -0
  94. data/rbi/turbopuffer/models/attribute_schema_config.rbi +103 -0
  95. data/rbi/turbopuffer/models/attribute_type.rbi +7 -0
  96. data/rbi/turbopuffer/models/client_namespaces_params.rbi +71 -0
  97. data/rbi/turbopuffer/models/columns.rbi +82 -0
  98. data/rbi/turbopuffer/models/distance_metric.rbi +27 -0
  99. data/rbi/turbopuffer/models/full_text_search.rbi +19 -0
  100. data/rbi/turbopuffer/models/full_text_search_config.rbi +133 -0
  101. data/rbi/turbopuffer/models/id.rbi +16 -0
  102. data/rbi/turbopuffer/models/include_attributes.rbi +24 -0
  103. data/rbi/turbopuffer/models/language.rbi +36 -0
  104. data/rbi/turbopuffer/models/namespace_delete_all_params.rbi +41 -0
  105. data/rbi/turbopuffer/models/namespace_delete_all_response.rbi +31 -0
  106. data/rbi/turbopuffer/models/namespace_explain_query_params.rbi +273 -0
  107. data/rbi/turbopuffer/models/namespace_explain_query_response.rbi +34 -0
  108. data/rbi/turbopuffer/models/namespace_hint_cache_warm_params.rbi +41 -0
  109. data/rbi/turbopuffer/models/namespace_hint_cache_warm_response.rbi +38 -0
  110. data/rbi/turbopuffer/models/namespace_metadata.rbi +62 -0
  111. data/rbi/turbopuffer/models/namespace_metadata_params.rbi +41 -0
  112. data/rbi/turbopuffer/models/namespace_multi_query_params.rbi +175 -0
  113. data/rbi/turbopuffer/models/namespace_multi_query_response.rbi +121 -0
  114. data/rbi/turbopuffer/models/namespace_query_params.rbi +267 -0
  115. data/rbi/turbopuffer/models/namespace_query_response.rbi +84 -0
  116. data/rbi/turbopuffer/models/namespace_recall_params.rbi +106 -0
  117. data/rbi/turbopuffer/models/namespace_recall_response.rbi +134 -0
  118. data/rbi/turbopuffer/models/namespace_schema_params.rbi +41 -0
  119. data/rbi/turbopuffer/models/namespace_schema_response.rbi +11 -0
  120. data/rbi/turbopuffer/models/namespace_summary.rbi +28 -0
  121. data/rbi/turbopuffer/models/namespace_update_schema_params.rbi +80 -0
  122. data/rbi/turbopuffer/models/namespace_update_schema_response.rbi +11 -0
  123. data/rbi/turbopuffer/models/namespace_write_params.rbi +290 -0
  124. data/rbi/turbopuffer/models/namespace_write_response.rbi +101 -0
  125. data/rbi/turbopuffer/models/query.rbi +132 -0
  126. data/rbi/turbopuffer/models/query_billing.rbi +46 -0
  127. data/rbi/turbopuffer/models/query_performance.rbi +82 -0
  128. data/rbi/turbopuffer/models/row.rbi +47 -0
  129. data/rbi/turbopuffer/models/tokenizer.rbi +24 -0
  130. data/rbi/turbopuffer/models/vector.rbi +22 -0
  131. data/rbi/turbopuffer/models/vector_encoding.rbi +22 -0
  132. data/rbi/turbopuffer/models/write_billing.rbi +49 -0
  133. data/rbi/turbopuffer/models.rbi +72 -0
  134. data/rbi/turbopuffer/namespace.rbi +8 -0
  135. data/rbi/turbopuffer/request_options.rbi +59 -0
  136. data/rbi/turbopuffer/resources/namespaces.rbi +304 -0
  137. data/rbi/turbopuffer/version.rbi +5 -0
  138. data/sig/turbopuffer/client.rbs +41 -0
  139. data/sig/turbopuffer/errors.rbs +117 -0
  140. data/sig/turbopuffer/file_part.rbs +21 -0
  141. data/sig/turbopuffer/internal/namespace_page.rbs +13 -0
  142. data/sig/turbopuffer/internal/transport/base_client.rbs +131 -0
  143. data/sig/turbopuffer/internal/transport/pooled_net_requester.rbs +45 -0
  144. data/sig/turbopuffer/internal/type/array_of.rbs +48 -0
  145. data/sig/turbopuffer/internal/type/base_model.rbs +102 -0
  146. data/sig/turbopuffer/internal/type/base_page.rbs +24 -0
  147. data/sig/turbopuffer/internal/type/boolean.rbs +26 -0
  148. data/sig/turbopuffer/internal/type/converter.rbs +79 -0
  149. data/sig/turbopuffer/internal/type/enum.rbs +32 -0
  150. data/sig/turbopuffer/internal/type/file_input.rbs +25 -0
  151. data/sig/turbopuffer/internal/type/hash_of.rbs +48 -0
  152. data/sig/turbopuffer/internal/type/request_parameters.rbs +19 -0
  153. data/sig/turbopuffer/internal/type/union.rbs +52 -0
  154. data/sig/turbopuffer/internal/type/unknown.rbs +26 -0
  155. data/sig/turbopuffer/internal/util.rbs +185 -0
  156. data/sig/turbopuffer/internal.rbs +9 -0
  157. data/sig/turbopuffer/models/aggregation_group.rbs +7 -0
  158. data/sig/turbopuffer/models/attribute_schema.rbs +11 -0
  159. data/sig/turbopuffer/models/attribute_schema_config.rbs +52 -0
  160. data/sig/turbopuffer/models/attribute_type.rbs +5 -0
  161. data/sig/turbopuffer/models/client_namespaces_params.rbs +38 -0
  162. data/sig/turbopuffer/models/columns.rbs +42 -0
  163. data/sig/turbopuffer/models/distance_metric.rbs +17 -0
  164. data/sig/turbopuffer/models/full_text_search.rbs +11 -0
  165. data/sig/turbopuffer/models/full_text_search_config.rbs +75 -0
  166. data/sig/turbopuffer/models/id.rbs +11 -0
  167. data/sig/turbopuffer/models/include_attributes.rbs +13 -0
  168. data/sig/turbopuffer/models/language.rbs +48 -0
  169. data/sig/turbopuffer/models/namespace_delete_all_params.rbs +25 -0
  170. data/sig/turbopuffer/models/namespace_delete_all_response.rbs +13 -0
  171. data/sig/turbopuffer/models/namespace_explain_query_params.rbs +141 -0
  172. data/sig/turbopuffer/models/namespace_explain_query_response.rbs +15 -0
  173. data/sig/turbopuffer/models/namespace_hint_cache_warm_params.rbs +25 -0
  174. data/sig/turbopuffer/models/namespace_hint_cache_warm_response.rbs +18 -0
  175. data/sig/turbopuffer/models/namespace_metadata.rbs +35 -0
  176. data/sig/turbopuffer/models/namespace_metadata_params.rbs +25 -0
  177. data/sig/turbopuffer/models/namespace_multi_query_params.rbs +86 -0
  178. data/sig/turbopuffer/models/namespace_multi_query_response.rbs +65 -0
  179. data/sig/turbopuffer/models/namespace_query_params.rbs +139 -0
  180. data/sig/turbopuffer/models/namespace_query_response.rbs +48 -0
  181. data/sig/turbopuffer/models/namespace_recall_params.rbs +63 -0
  182. data/sig/turbopuffer/models/namespace_recall_response.rbs +61 -0
  183. data/sig/turbopuffer/models/namespace_schema_params.rbs +25 -0
  184. data/sig/turbopuffer/models/namespace_schema_response.rbs +8 -0
  185. data/sig/turbopuffer/models/namespace_summary.rbs +13 -0
  186. data/sig/turbopuffer/models/namespace_update_schema_params.rbs +37 -0
  187. data/sig/turbopuffer/models/namespace_update_schema_response.rbs +8 -0
  188. data/sig/turbopuffer/models/namespace_write_params.rbs +156 -0
  189. data/sig/turbopuffer/models/namespace_write_response.rbs +56 -0
  190. data/sig/turbopuffer/models/query.rbs +75 -0
  191. data/sig/turbopuffer/models/query_billing.rbs +25 -0
  192. data/sig/turbopuffer/models/query_performance.rbs +45 -0
  193. data/sig/turbopuffer/models/row.rbs +24 -0
  194. data/sig/turbopuffer/models/tokenizer.rbs +16 -0
  195. data/sig/turbopuffer/models/vector.rbs +13 -0
  196. data/sig/turbopuffer/models/vector_encoding.rbs +14 -0
  197. data/sig/turbopuffer/models/write_billing.rbs +27 -0
  198. data/sig/turbopuffer/models.rbs +65 -0
  199. data/sig/turbopuffer/namespace.rbs +5 -0
  200. data/sig/turbopuffer/request_options.rbs +36 -0
  201. data/sig/turbopuffer/resources/namespaces.rbs +99 -0
  202. data/sig/turbopuffer/version.rbs +3 -0
  203. metadata +218 -29
  204. data/.standard.yml +0 -3
  205. data/LICENSE.txt +0 -21
  206. data/Rakefile +0 -10
  207. data/sig/turbopuffer.rbs +0 -4
@@ -0,0 +1,267 @@
1
+ # typed: strong
2
+
3
+ module Turbopuffer
4
+ module Models
5
+ class NamespaceQueryParams < Turbopuffer::Internal::Type::BaseModel
6
+ extend Turbopuffer::Internal::Type::RequestParameters::Converter
7
+ include Turbopuffer::Internal::Type::RequestParameters
8
+
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(
12
+ Turbopuffer::NamespaceQueryParams,
13
+ Turbopuffer::Internal::AnyHash
14
+ )
15
+ end
16
+
17
+ sig { returns(T.nilable(String)) }
18
+ attr_reader :namespace
19
+
20
+ sig { params(namespace: String).void }
21
+ attr_writer :namespace
22
+
23
+ # Aggregations to compute over all documents in the namespace that match the
24
+ # filters.
25
+ sig { returns(T.nilable(T::Hash[Symbol, T.anything])) }
26
+ attr_reader :aggregate_by
27
+
28
+ sig { params(aggregate_by: T::Hash[Symbol, T.anything]).void }
29
+ attr_writer :aggregate_by
30
+
31
+ # The consistency level for a query.
32
+ sig { returns(T.nilable(Turbopuffer::NamespaceQueryParams::Consistency)) }
33
+ attr_reader :consistency
34
+
35
+ sig do
36
+ params(
37
+ consistency: Turbopuffer::NamespaceQueryParams::Consistency::OrHash
38
+ ).void
39
+ end
40
+ attr_writer :consistency
41
+
42
+ # A function used to calculate vector similarity.
43
+ sig { returns(T.nilable(Turbopuffer::DistanceMetric::OrSymbol)) }
44
+ attr_reader :distance_metric
45
+
46
+ sig do
47
+ params(distance_metric: Turbopuffer::DistanceMetric::OrSymbol).void
48
+ end
49
+ attr_writer :distance_metric
50
+
51
+ # List of attribute names to exclude from the response. All other attributes will
52
+ # be included in the response.
53
+ sig { returns(T.nilable(T::Array[String])) }
54
+ attr_reader :exclude_attributes
55
+
56
+ sig { params(exclude_attributes: T::Array[String]).void }
57
+ attr_writer :exclude_attributes
58
+
59
+ # Exact filters for attributes to refine search results for. Think of it as a SQL
60
+ # WHERE clause.
61
+ sig { returns(T.nilable(T.anything)) }
62
+ attr_reader :filters
63
+
64
+ sig { params(filters: T.anything).void }
65
+ attr_writer :filters
66
+
67
+ # Groups documents by the specified attributes (the "group key") before computing
68
+ # aggregates. Aggregates are computed separately for each group.
69
+ sig { returns(T.nilable(T::Array[String])) }
70
+ attr_reader :group_by
71
+
72
+ sig { params(group_by: T::Array[String]).void }
73
+ attr_writer :group_by
74
+
75
+ # Whether to include attributes in the response.
76
+ sig { returns(T.nilable(Turbopuffer::IncludeAttributes::Variants)) }
77
+ attr_reader :include_attributes
78
+
79
+ sig do
80
+ params(
81
+ include_attributes: Turbopuffer::IncludeAttributes::Variants
82
+ ).void
83
+ end
84
+ attr_writer :include_attributes
85
+
86
+ # How to rank the documents in the namespace.
87
+ sig { returns(T.nilable(T.anything)) }
88
+ attr_reader :rank_by
89
+
90
+ sig { params(rank_by: T.anything).void }
91
+ attr_writer :rank_by
92
+
93
+ # The number of results to return.
94
+ sig { returns(T.nilable(Integer)) }
95
+ attr_reader :top_k
96
+
97
+ sig { params(top_k: Integer).void }
98
+ attr_writer :top_k
99
+
100
+ # The encoding to use for vectors in the response.
101
+ sig { returns(T.nilable(Turbopuffer::VectorEncoding::OrSymbol)) }
102
+ attr_reader :vector_encoding
103
+
104
+ sig do
105
+ params(vector_encoding: Turbopuffer::VectorEncoding::OrSymbol).void
106
+ end
107
+ attr_writer :vector_encoding
108
+
109
+ sig do
110
+ params(
111
+ namespace: String,
112
+ aggregate_by: T::Hash[Symbol, T.anything],
113
+ consistency: Turbopuffer::NamespaceQueryParams::Consistency::OrHash,
114
+ distance_metric: Turbopuffer::DistanceMetric::OrSymbol,
115
+ exclude_attributes: T::Array[String],
116
+ filters: T.anything,
117
+ group_by: T::Array[String],
118
+ include_attributes: Turbopuffer::IncludeAttributes::Variants,
119
+ rank_by: T.anything,
120
+ top_k: Integer,
121
+ vector_encoding: Turbopuffer::VectorEncoding::OrSymbol,
122
+ request_options: Turbopuffer::RequestOptions::OrHash
123
+ ).returns(T.attached_class)
124
+ end
125
+ def self.new(
126
+ namespace: nil,
127
+ # Aggregations to compute over all documents in the namespace that match the
128
+ # filters.
129
+ aggregate_by: nil,
130
+ # The consistency level for a query.
131
+ consistency: nil,
132
+ # A function used to calculate vector similarity.
133
+ distance_metric: nil,
134
+ # List of attribute names to exclude from the response. All other attributes will
135
+ # be included in the response.
136
+ exclude_attributes: nil,
137
+ # Exact filters for attributes to refine search results for. Think of it as a SQL
138
+ # WHERE clause.
139
+ filters: nil,
140
+ # Groups documents by the specified attributes (the "group key") before computing
141
+ # aggregates. Aggregates are computed separately for each group.
142
+ group_by: nil,
143
+ # Whether to include attributes in the response.
144
+ include_attributes: nil,
145
+ # How to rank the documents in the namespace.
146
+ rank_by: nil,
147
+ # The number of results to return.
148
+ top_k: nil,
149
+ # The encoding to use for vectors in the response.
150
+ vector_encoding: nil,
151
+ request_options: {}
152
+ )
153
+ end
154
+
155
+ sig do
156
+ override.returns(
157
+ {
158
+ namespace: String,
159
+ aggregate_by: T::Hash[Symbol, T.anything],
160
+ consistency: Turbopuffer::NamespaceQueryParams::Consistency,
161
+ distance_metric: Turbopuffer::DistanceMetric::OrSymbol,
162
+ exclude_attributes: T::Array[String],
163
+ filters: T.anything,
164
+ group_by: T::Array[String],
165
+ include_attributes: Turbopuffer::IncludeAttributes::Variants,
166
+ rank_by: T.anything,
167
+ top_k: Integer,
168
+ vector_encoding: Turbopuffer::VectorEncoding::OrSymbol,
169
+ request_options: Turbopuffer::RequestOptions
170
+ }
171
+ )
172
+ end
173
+ def to_hash
174
+ end
175
+
176
+ class Consistency < Turbopuffer::Internal::Type::BaseModel
177
+ OrHash =
178
+ T.type_alias do
179
+ T.any(
180
+ Turbopuffer::NamespaceQueryParams::Consistency,
181
+ Turbopuffer::Internal::AnyHash
182
+ )
183
+ end
184
+
185
+ # The query's consistency level.
186
+ sig do
187
+ returns(
188
+ T.nilable(
189
+ Turbopuffer::NamespaceQueryParams::Consistency::Level::OrSymbol
190
+ )
191
+ )
192
+ end
193
+ attr_reader :level
194
+
195
+ sig do
196
+ params(
197
+ level:
198
+ Turbopuffer::NamespaceQueryParams::Consistency::Level::OrSymbol
199
+ ).void
200
+ end
201
+ attr_writer :level
202
+
203
+ # The consistency level for a query.
204
+ sig do
205
+ params(
206
+ level:
207
+ Turbopuffer::NamespaceQueryParams::Consistency::Level::OrSymbol
208
+ ).returns(T.attached_class)
209
+ end
210
+ def self.new(
211
+ # The query's consistency level.
212
+ level: nil
213
+ )
214
+ end
215
+
216
+ sig do
217
+ override.returns(
218
+ {
219
+ level:
220
+ Turbopuffer::NamespaceQueryParams::Consistency::Level::OrSymbol
221
+ }
222
+ )
223
+ end
224
+ def to_hash
225
+ end
226
+
227
+ # The query's consistency level.
228
+ module Level
229
+ extend Turbopuffer::Internal::Type::Enum
230
+
231
+ TaggedSymbol =
232
+ T.type_alias do
233
+ T.all(
234
+ Symbol,
235
+ Turbopuffer::NamespaceQueryParams::Consistency::Level
236
+ )
237
+ end
238
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
239
+
240
+ # Strong consistency. Requires a round-trip to object storage to fetch the latest writes.
241
+ STRONG =
242
+ T.let(
243
+ :strong,
244
+ Turbopuffer::NamespaceQueryParams::Consistency::Level::TaggedSymbol
245
+ )
246
+
247
+ # Eventual consistency. Does not require a round-trip to object storage, but may not see the latest writes.
248
+ EVENTUAL =
249
+ T.let(
250
+ :eventual,
251
+ Turbopuffer::NamespaceQueryParams::Consistency::Level::TaggedSymbol
252
+ )
253
+
254
+ sig do
255
+ override.returns(
256
+ T::Array[
257
+ Turbopuffer::NamespaceQueryParams::Consistency::Level::TaggedSymbol
258
+ ]
259
+ )
260
+ end
261
+ def self.values
262
+ end
263
+ end
264
+ end
265
+ end
266
+ end
267
+ end
@@ -0,0 +1,84 @@
1
+ # typed: strong
2
+
3
+ module Turbopuffer
4
+ module Models
5
+ class NamespaceQueryResponse < Turbopuffer::Internal::Type::BaseModel
6
+ OrHash =
7
+ T.type_alias do
8
+ T.any(
9
+ Turbopuffer::Models::NamespaceQueryResponse,
10
+ Turbopuffer::Internal::AnyHash
11
+ )
12
+ end
13
+
14
+ # The billing information for a query.
15
+ sig { returns(Turbopuffer::QueryBilling) }
16
+ attr_reader :billing
17
+
18
+ sig { params(billing: Turbopuffer::QueryBilling::OrHash).void }
19
+ attr_writer :billing
20
+
21
+ # The performance information for a query.
22
+ sig { returns(Turbopuffer::QueryPerformance) }
23
+ attr_reader :performance
24
+
25
+ sig { params(performance: Turbopuffer::QueryPerformance::OrHash).void }
26
+ attr_writer :performance
27
+
28
+ sig { returns(T.nilable(T::Array[T::Hash[Symbol, T.anything]])) }
29
+ attr_reader :aggregation_groups
30
+
31
+ sig do
32
+ params(aggregation_groups: T::Array[T::Hash[Symbol, T.anything]]).void
33
+ end
34
+ attr_writer :aggregation_groups
35
+
36
+ sig { returns(T.nilable(T::Hash[Symbol, T.anything])) }
37
+ attr_reader :aggregations
38
+
39
+ sig { params(aggregations: T::Hash[Symbol, T.anything]).void }
40
+ attr_writer :aggregations
41
+
42
+ sig { returns(T.nilable(T::Array[Turbopuffer::Row])) }
43
+ attr_reader :rows
44
+
45
+ sig { params(rows: T::Array[Turbopuffer::Row::OrHash]).void }
46
+ attr_writer :rows
47
+
48
+ # The result of a query.
49
+ sig do
50
+ params(
51
+ billing: Turbopuffer::QueryBilling::OrHash,
52
+ performance: Turbopuffer::QueryPerformance::OrHash,
53
+ aggregation_groups: T::Array[T::Hash[Symbol, T.anything]],
54
+ aggregations: T::Hash[Symbol, T.anything],
55
+ rows: T::Array[Turbopuffer::Row::OrHash]
56
+ ).returns(T.attached_class)
57
+ end
58
+ def self.new(
59
+ # The billing information for a query.
60
+ billing:,
61
+ # The performance information for a query.
62
+ performance:,
63
+ aggregation_groups: nil,
64
+ aggregations: nil,
65
+ rows: nil
66
+ )
67
+ end
68
+
69
+ sig do
70
+ override.returns(
71
+ {
72
+ billing: Turbopuffer::QueryBilling,
73
+ performance: Turbopuffer::QueryPerformance,
74
+ aggregation_groups: T::Array[T::Hash[Symbol, T.anything]],
75
+ aggregations: T::Hash[Symbol, T.anything],
76
+ rows: T::Array[Turbopuffer::Row]
77
+ }
78
+ )
79
+ end
80
+ def to_hash
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,106 @@
1
+ # typed: strong
2
+
3
+ module Turbopuffer
4
+ module Models
5
+ class NamespaceRecallParams < Turbopuffer::Internal::Type::BaseModel
6
+ extend Turbopuffer::Internal::Type::RequestParameters::Converter
7
+ include Turbopuffer::Internal::Type::RequestParameters
8
+
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(
12
+ Turbopuffer::NamespaceRecallParams,
13
+ Turbopuffer::Internal::AnyHash
14
+ )
15
+ end
16
+
17
+ sig { returns(T.nilable(String)) }
18
+ attr_reader :namespace
19
+
20
+ sig { params(namespace: String).void }
21
+ attr_writer :namespace
22
+
23
+ # Filter by attributes. Same syntax as the query endpoint.
24
+ sig { returns(T.nilable(T.anything)) }
25
+ attr_reader :filters
26
+
27
+ sig { params(filters: T.anything).void }
28
+ attr_writer :filters
29
+
30
+ # Include ground truth data (query vectors and true nearest neighbors) in the
31
+ # response.
32
+ sig { returns(T.nilable(T::Boolean)) }
33
+ attr_reader :include_ground_truth
34
+
35
+ sig { params(include_ground_truth: T::Boolean).void }
36
+ attr_writer :include_ground_truth
37
+
38
+ # The number of searches to run.
39
+ sig { returns(T.nilable(Integer)) }
40
+ attr_reader :num
41
+
42
+ sig { params(num: Integer).void }
43
+ attr_writer :num
44
+
45
+ # Use specific query vectors for the measurement. If omitted, sampled from the
46
+ # index.
47
+ sig { returns(T.nilable(T::Array[Float])) }
48
+ attr_reader :queries
49
+
50
+ sig { params(queries: T::Array[Float]).void }
51
+ attr_writer :queries
52
+
53
+ # Search for `top_k` nearest neighbors.
54
+ sig { returns(T.nilable(Integer)) }
55
+ attr_reader :top_k
56
+
57
+ sig { params(top_k: Integer).void }
58
+ attr_writer :top_k
59
+
60
+ sig do
61
+ params(
62
+ namespace: String,
63
+ filters: T.anything,
64
+ include_ground_truth: T::Boolean,
65
+ num: Integer,
66
+ queries: T::Array[Float],
67
+ top_k: Integer,
68
+ request_options: Turbopuffer::RequestOptions::OrHash
69
+ ).returns(T.attached_class)
70
+ end
71
+ def self.new(
72
+ namespace: nil,
73
+ # Filter by attributes. Same syntax as the query endpoint.
74
+ filters: nil,
75
+ # Include ground truth data (query vectors and true nearest neighbors) in the
76
+ # response.
77
+ include_ground_truth: nil,
78
+ # The number of searches to run.
79
+ num: nil,
80
+ # Use specific query vectors for the measurement. If omitted, sampled from the
81
+ # index.
82
+ queries: nil,
83
+ # Search for `top_k` nearest neighbors.
84
+ top_k: nil,
85
+ request_options: {}
86
+ )
87
+ end
88
+
89
+ sig do
90
+ override.returns(
91
+ {
92
+ namespace: String,
93
+ filters: T.anything,
94
+ include_ground_truth: T::Boolean,
95
+ num: Integer,
96
+ queries: T::Array[Float],
97
+ top_k: Integer,
98
+ request_options: Turbopuffer::RequestOptions
99
+ }
100
+ )
101
+ end
102
+ def to_hash
103
+ end
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,134 @@
1
+ # typed: strong
2
+
3
+ module Turbopuffer
4
+ module Models
5
+ class NamespaceRecallResponse < Turbopuffer::Internal::Type::BaseModel
6
+ OrHash =
7
+ T.type_alias do
8
+ T.any(
9
+ Turbopuffer::Models::NamespaceRecallResponse,
10
+ Turbopuffer::Internal::AnyHash
11
+ )
12
+ end
13
+
14
+ # The average number of documents retrieved by the approximate nearest neighbor
15
+ # searches.
16
+ sig { returns(Float) }
17
+ attr_accessor :avg_ann_count
18
+
19
+ # The average number of documents retrieved by the exhaustive searches.
20
+ sig { returns(Float) }
21
+ attr_accessor :avg_exhaustive_count
22
+
23
+ # The average recall of the queries.
24
+ sig { returns(Float) }
25
+ attr_accessor :avg_recall
26
+
27
+ # Ground truth data including query vectors and true nearest neighbors. Only
28
+ # included when include_ground_truth is true.
29
+ sig do
30
+ returns(
31
+ T.nilable(
32
+ T::Array[Turbopuffer::Models::NamespaceRecallResponse::GroundTruth]
33
+ )
34
+ )
35
+ end
36
+ attr_reader :ground_truth
37
+
38
+ sig do
39
+ params(
40
+ ground_truth:
41
+ T::Array[
42
+ Turbopuffer::Models::NamespaceRecallResponse::GroundTruth::OrHash
43
+ ]
44
+ ).void
45
+ end
46
+ attr_writer :ground_truth
47
+
48
+ # The response to a successful cache warm request.
49
+ sig do
50
+ params(
51
+ avg_ann_count: Float,
52
+ avg_exhaustive_count: Float,
53
+ avg_recall: Float,
54
+ ground_truth:
55
+ T::Array[
56
+ Turbopuffer::Models::NamespaceRecallResponse::GroundTruth::OrHash
57
+ ]
58
+ ).returns(T.attached_class)
59
+ end
60
+ def self.new(
61
+ # The average number of documents retrieved by the approximate nearest neighbor
62
+ # searches.
63
+ avg_ann_count:,
64
+ # The average number of documents retrieved by the exhaustive searches.
65
+ avg_exhaustive_count:,
66
+ # The average recall of the queries.
67
+ avg_recall:,
68
+ # Ground truth data including query vectors and true nearest neighbors. Only
69
+ # included when include_ground_truth is true.
70
+ ground_truth: nil
71
+ )
72
+ end
73
+
74
+ sig do
75
+ override.returns(
76
+ {
77
+ avg_ann_count: Float,
78
+ avg_exhaustive_count: Float,
79
+ avg_recall: Float,
80
+ ground_truth:
81
+ T::Array[
82
+ Turbopuffer::Models::NamespaceRecallResponse::GroundTruth
83
+ ]
84
+ }
85
+ )
86
+ end
87
+ def to_hash
88
+ end
89
+
90
+ class GroundTruth < Turbopuffer::Internal::Type::BaseModel
91
+ OrHash =
92
+ T.type_alias do
93
+ T.any(
94
+ Turbopuffer::Models::NamespaceRecallResponse::GroundTruth,
95
+ Turbopuffer::Internal::AnyHash
96
+ )
97
+ end
98
+
99
+ # The true nearest neighbors with their distances and vectors.
100
+ sig { returns(T::Array[Turbopuffer::Row]) }
101
+ attr_accessor :nearest_neighbors
102
+
103
+ # The query vector used for this search.
104
+ sig { returns(T::Array[Float]) }
105
+ attr_accessor :query_vector
106
+
107
+ sig do
108
+ params(
109
+ nearest_neighbors: T::Array[Turbopuffer::Row::OrHash],
110
+ query_vector: T::Array[Float]
111
+ ).returns(T.attached_class)
112
+ end
113
+ def self.new(
114
+ # The true nearest neighbors with their distances and vectors.
115
+ nearest_neighbors:,
116
+ # The query vector used for this search.
117
+ query_vector:
118
+ )
119
+ end
120
+
121
+ sig do
122
+ override.returns(
123
+ {
124
+ nearest_neighbors: T::Array[Turbopuffer::Row],
125
+ query_vector: T::Array[Float]
126
+ }
127
+ )
128
+ end
129
+ def to_hash
130
+ end
131
+ end
132
+ end
133
+ end
134
+ end
@@ -0,0 +1,41 @@
1
+ # typed: strong
2
+
3
+ module Turbopuffer
4
+ module Models
5
+ class NamespaceSchemaParams < Turbopuffer::Internal::Type::BaseModel
6
+ extend Turbopuffer::Internal::Type::RequestParameters::Converter
7
+ include Turbopuffer::Internal::Type::RequestParameters
8
+
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(
12
+ Turbopuffer::NamespaceSchemaParams,
13
+ Turbopuffer::Internal::AnyHash
14
+ )
15
+ end
16
+
17
+ sig { returns(T.nilable(String)) }
18
+ attr_reader :namespace
19
+
20
+ sig { params(namespace: String).void }
21
+ attr_writer :namespace
22
+
23
+ sig do
24
+ params(
25
+ namespace: String,
26
+ request_options: Turbopuffer::RequestOptions::OrHash
27
+ ).returns(T.attached_class)
28
+ end
29
+ def self.new(namespace: nil, request_options: {})
30
+ end
31
+
32
+ sig do
33
+ override.returns(
34
+ { namespace: String, request_options: Turbopuffer::RequestOptions }
35
+ )
36
+ end
37
+ def to_hash
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,11 @@
1
+ # typed: strong
2
+
3
+ module Turbopuffer
4
+ module Models
5
+ NamespaceSchemaResponse =
6
+ T.let(
7
+ Turbopuffer::Internal::Type::HashOf[Turbopuffer::AttributeSchemaConfig],
8
+ Turbopuffer::Internal::Type::Converter
9
+ )
10
+ end
11
+ end
@@ -0,0 +1,28 @@
1
+ # typed: strong
2
+
3
+ module Turbopuffer
4
+ module Models
5
+ class NamespaceSummary < Turbopuffer::Internal::Type::BaseModel
6
+ OrHash =
7
+ T.type_alias do
8
+ T.any(Turbopuffer::NamespaceSummary, Turbopuffer::Internal::AnyHash)
9
+ end
10
+
11
+ # The namespace ID.
12
+ sig { returns(String) }
13
+ attr_accessor :id
14
+
15
+ # A summary of a namespace.
16
+ sig { params(id: String).returns(T.attached_class) }
17
+ def self.new(
18
+ # The namespace ID.
19
+ id:
20
+ )
21
+ end
22
+
23
+ sig { override.returns({ id: String }) }
24
+ def to_hash
25
+ end
26
+ end
27
+ end
28
+ end