turbopuffer-ruby 0.2.0.pre.alpha.1

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 (194) hide show
  1. checksums.yaml +7 -0
  2. data/.ignore +2 -0
  3. data/CHANGELOG.md +60 -0
  4. data/README.md +291 -0
  5. data/SECURITY.md +27 -0
  6. data/lib/turbopuffer/client.rb +130 -0
  7. data/lib/turbopuffer/errors.rb +214 -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 +563 -0
  11. data/lib/turbopuffer/internal/transport/pooled_net_requester.rb +209 -0
  12. data/lib/turbopuffer/internal/type/array_of.rb +167 -0
  13. data/lib/turbopuffer/internal/type/base_model.rb +534 -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 +300 -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 +187 -0
  20. data/lib/turbopuffer/internal/type/request_parameters.rb +42 -0
  21. data/lib/turbopuffer/internal/type/union.rb +252 -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/attribute_schema.rb +19 -0
  26. data/lib/turbopuffer/models/attribute_schema_config.rb +48 -0
  27. data/lib/turbopuffer/models/attribute_type.rb +7 -0
  28. data/lib/turbopuffer/models/client_namespaces_params.rb +38 -0
  29. data/lib/turbopuffer/models/columns.rb +64 -0
  30. data/lib/turbopuffer/models/distance_metric.rb +19 -0
  31. data/lib/turbopuffer/models/full_text_search.rb +20 -0
  32. data/lib/turbopuffer/models/full_text_search_config.rb +72 -0
  33. data/lib/turbopuffer/models/id.rb +19 -0
  34. data/lib/turbopuffer/models/include_attributes.rb +22 -0
  35. data/lib/turbopuffer/models/language.rb +32 -0
  36. data/lib/turbopuffer/models/namespace_delete_all_params.rb +20 -0
  37. data/lib/turbopuffer/models/namespace_delete_all_response.rb +19 -0
  38. data/lib/turbopuffer/models/namespace_hint_cache_warm_params.rb +20 -0
  39. data/lib/turbopuffer/models/namespace_hint_cache_warm_response.rb +26 -0
  40. data/lib/turbopuffer/models/namespace_metadata.rb +35 -0
  41. data/lib/turbopuffer/models/namespace_metadata_params.rb +20 -0
  42. data/lib/turbopuffer/models/namespace_multi_query_params.rb +73 -0
  43. data/lib/turbopuffer/models/namespace_multi_query_response.rb +51 -0
  44. data/lib/turbopuffer/models/namespace_query_params.rb +119 -0
  45. data/lib/turbopuffer/models/namespace_query_response.rb +41 -0
  46. data/lib/turbopuffer/models/namespace_recall_params.rb +57 -0
  47. data/lib/turbopuffer/models/namespace_recall_response.rb +39 -0
  48. data/lib/turbopuffer/models/namespace_schema_params.rb +20 -0
  49. data/lib/turbopuffer/models/namespace_schema_response.rb +8 -0
  50. data/lib/turbopuffer/models/namespace_summary.rb +19 -0
  51. data/lib/turbopuffer/models/namespace_update_schema_params.rb +29 -0
  52. data/lib/turbopuffer/models/namespace_update_schema_response.rb +9 -0
  53. data/lib/turbopuffer/models/namespace_write_params.rb +158 -0
  54. data/lib/turbopuffer/models/namespace_write_response.rb +67 -0
  55. data/lib/turbopuffer/models/query.rb +63 -0
  56. data/lib/turbopuffer/models/query_billing.rb +26 -0
  57. data/lib/turbopuffer/models/query_performance.rb +63 -0
  58. data/lib/turbopuffer/models/row.rb +38 -0
  59. data/lib/turbopuffer/models/tokenizer.rb +17 -0
  60. data/lib/turbopuffer/models/vector.rb +22 -0
  61. data/lib/turbopuffer/models/vector_encoding.rb +16 -0
  62. data/lib/turbopuffer/models/write_billing.rb +26 -0
  63. data/lib/turbopuffer/models.rb +101 -0
  64. data/lib/turbopuffer/namespace.rb +22 -0
  65. data/lib/turbopuffer/request_options.rb +77 -0
  66. data/lib/turbopuffer/resources/namespaces.rb +311 -0
  67. data/lib/turbopuffer/version.rb +5 -0
  68. data/lib/turbopuffer.rb +94 -0
  69. data/manifest.yaml +15 -0
  70. data/rbi/turbopuffer/client.rbi +91 -0
  71. data/rbi/turbopuffer/errors.rbi +178 -0
  72. data/rbi/turbopuffer/file_part.rbi +37 -0
  73. data/rbi/turbopuffer/internal/namespace_page.rbi +22 -0
  74. data/rbi/turbopuffer/internal/transport/base_client.rbi +298 -0
  75. data/rbi/turbopuffer/internal/transport/pooled_net_requester.rbi +80 -0
  76. data/rbi/turbopuffer/internal/type/array_of.rbi +104 -0
  77. data/rbi/turbopuffer/internal/type/base_model.rbi +304 -0
  78. data/rbi/turbopuffer/internal/type/base_page.rbi +43 -0
  79. data/rbi/turbopuffer/internal/type/boolean.rbi +58 -0
  80. data/rbi/turbopuffer/internal/type/converter.rbi +162 -0
  81. data/rbi/turbopuffer/internal/type/enum.rbi +82 -0
  82. data/rbi/turbopuffer/internal/type/file_input.rbi +59 -0
  83. data/rbi/turbopuffer/internal/type/hash_of.rbi +104 -0
  84. data/rbi/turbopuffer/internal/type/request_parameters.rbi +31 -0
  85. data/rbi/turbopuffer/internal/type/union.rbi +121 -0
  86. data/rbi/turbopuffer/internal/type/unknown.rbi +58 -0
  87. data/rbi/turbopuffer/internal/util.rbi +487 -0
  88. data/rbi/turbopuffer/internal.rbi +18 -0
  89. data/rbi/turbopuffer/models/attribute_schema.rbi +17 -0
  90. data/rbi/turbopuffer/models/attribute_schema_config.rbi +92 -0
  91. data/rbi/turbopuffer/models/attribute_type.rbi +7 -0
  92. data/rbi/turbopuffer/models/client_namespaces_params.rbi +71 -0
  93. data/rbi/turbopuffer/models/columns.rbi +82 -0
  94. data/rbi/turbopuffer/models/distance_metric.rbi +27 -0
  95. data/rbi/turbopuffer/models/full_text_search.rbi +19 -0
  96. data/rbi/turbopuffer/models/full_text_search_config.rbi +116 -0
  97. data/rbi/turbopuffer/models/id.rbi +16 -0
  98. data/rbi/turbopuffer/models/include_attributes.rbi +24 -0
  99. data/rbi/turbopuffer/models/language.rbi +36 -0
  100. data/rbi/turbopuffer/models/namespace_delete_all_params.rbi +41 -0
  101. data/rbi/turbopuffer/models/namespace_delete_all_response.rbi +31 -0
  102. data/rbi/turbopuffer/models/namespace_hint_cache_warm_params.rbi +41 -0
  103. data/rbi/turbopuffer/models/namespace_hint_cache_warm_response.rbi +38 -0
  104. data/rbi/turbopuffer/models/namespace_metadata.rbi +54 -0
  105. data/rbi/turbopuffer/models/namespace_metadata_params.rbi +41 -0
  106. data/rbi/turbopuffer/models/namespace_multi_query_params.rbi +175 -0
  107. data/rbi/turbopuffer/models/namespace_multi_query_response.rbi +111 -0
  108. data/rbi/turbopuffer/models/namespace_query_params.rbi +241 -0
  109. data/rbi/turbopuffer/models/namespace_query_response.rbi +73 -0
  110. data/rbi/turbopuffer/models/namespace_recall_params.rbi +93 -0
  111. data/rbi/turbopuffer/models/namespace_recall_response.rbi +59 -0
  112. data/rbi/turbopuffer/models/namespace_schema_params.rbi +41 -0
  113. data/rbi/turbopuffer/models/namespace_schema_response.rbi +11 -0
  114. data/rbi/turbopuffer/models/namespace_summary.rbi +28 -0
  115. data/rbi/turbopuffer/models/namespace_update_schema_params.rbi +80 -0
  116. data/rbi/turbopuffer/models/namespace_update_schema_response.rbi +11 -0
  117. data/rbi/turbopuffer/models/namespace_write_params.rbi +290 -0
  118. data/rbi/turbopuffer/models/namespace_write_response.rbi +101 -0
  119. data/rbi/turbopuffer/models/query.rbi +106 -0
  120. data/rbi/turbopuffer/models/query_billing.rbi +46 -0
  121. data/rbi/turbopuffer/models/query_performance.rbi +82 -0
  122. data/rbi/turbopuffer/models/row.rbi +47 -0
  123. data/rbi/turbopuffer/models/tokenizer.rbi +22 -0
  124. data/rbi/turbopuffer/models/vector.rbi +22 -0
  125. data/rbi/turbopuffer/models/vector_encoding.rbi +22 -0
  126. data/rbi/turbopuffer/models/write_billing.rbi +49 -0
  127. data/rbi/turbopuffer/models.rbi +64 -0
  128. data/rbi/turbopuffer/namespace.rbi +8 -0
  129. data/rbi/turbopuffer/request_options.rbi +59 -0
  130. data/rbi/turbopuffer/resources/namespaces.rbi +243 -0
  131. data/rbi/turbopuffer/version.rbi +5 -0
  132. data/sig/turbopuffer/client.rbs +41 -0
  133. data/sig/turbopuffer/errors.rbs +110 -0
  134. data/sig/turbopuffer/file_part.rbs +21 -0
  135. data/sig/turbopuffer/internal/namespace_page.rbs +13 -0
  136. data/sig/turbopuffer/internal/transport/base_client.rbs +131 -0
  137. data/sig/turbopuffer/internal/transport/pooled_net_requester.rbs +45 -0
  138. data/sig/turbopuffer/internal/type/array_of.rbs +48 -0
  139. data/sig/turbopuffer/internal/type/base_model.rbs +102 -0
  140. data/sig/turbopuffer/internal/type/base_page.rbs +24 -0
  141. data/sig/turbopuffer/internal/type/boolean.rbs +26 -0
  142. data/sig/turbopuffer/internal/type/converter.rbs +62 -0
  143. data/sig/turbopuffer/internal/type/enum.rbs +32 -0
  144. data/sig/turbopuffer/internal/type/file_input.rbs +25 -0
  145. data/sig/turbopuffer/internal/type/hash_of.rbs +48 -0
  146. data/sig/turbopuffer/internal/type/request_parameters.rbs +19 -0
  147. data/sig/turbopuffer/internal/type/union.rbs +52 -0
  148. data/sig/turbopuffer/internal/type/unknown.rbs +26 -0
  149. data/sig/turbopuffer/internal/util.rbs +185 -0
  150. data/sig/turbopuffer/internal.rbs +9 -0
  151. data/sig/turbopuffer/models/attribute_schema.rbs +11 -0
  152. data/sig/turbopuffer/models/attribute_schema_config.rbs +45 -0
  153. data/sig/turbopuffer/models/attribute_type.rbs +5 -0
  154. data/sig/turbopuffer/models/client_namespaces_params.rbs +38 -0
  155. data/sig/turbopuffer/models/columns.rbs +42 -0
  156. data/sig/turbopuffer/models/distance_metric.rbs +17 -0
  157. data/sig/turbopuffer/models/full_text_search.rbs +11 -0
  158. data/sig/turbopuffer/models/full_text_search_config.rbs +68 -0
  159. data/sig/turbopuffer/models/id.rbs +11 -0
  160. data/sig/turbopuffer/models/include_attributes.rbs +13 -0
  161. data/sig/turbopuffer/models/language.rbs +48 -0
  162. data/sig/turbopuffer/models/namespace_delete_all_params.rbs +25 -0
  163. data/sig/turbopuffer/models/namespace_delete_all_response.rbs +13 -0
  164. data/sig/turbopuffer/models/namespace_hint_cache_warm_params.rbs +25 -0
  165. data/sig/turbopuffer/models/namespace_hint_cache_warm_response.rbs +17 -0
  166. data/sig/turbopuffer/models/namespace_metadata.rbs +30 -0
  167. data/sig/turbopuffer/models/namespace_metadata_params.rbs +25 -0
  168. data/sig/turbopuffer/models/namespace_multi_query_params.rbs +86 -0
  169. data/sig/turbopuffer/models/namespace_multi_query_response.rbs +53 -0
  170. data/sig/turbopuffer/models/namespace_query_params.rbs +125 -0
  171. data/sig/turbopuffer/models/namespace_query_response.rbs +39 -0
  172. data/sig/turbopuffer/models/namespace_recall_params.rbs +56 -0
  173. data/sig/turbopuffer/models/namespace_recall_response.rbs +26 -0
  174. data/sig/turbopuffer/models/namespace_schema_params.rbs +25 -0
  175. data/sig/turbopuffer/models/namespace_schema_response.rbs +8 -0
  176. data/sig/turbopuffer/models/namespace_summary.rbs +13 -0
  177. data/sig/turbopuffer/models/namespace_update_schema_params.rbs +37 -0
  178. data/sig/turbopuffer/models/namespace_update_schema_response.rbs +8 -0
  179. data/sig/turbopuffer/models/namespace_write_params.rbs +156 -0
  180. data/sig/turbopuffer/models/namespace_write_response.rbs +56 -0
  181. data/sig/turbopuffer/models/query.rbs +61 -0
  182. data/sig/turbopuffer/models/query_billing.rbs +25 -0
  183. data/sig/turbopuffer/models/query_performance.rbs +45 -0
  184. data/sig/turbopuffer/models/row.rbs +24 -0
  185. data/sig/turbopuffer/models/tokenizer.rbs +15 -0
  186. data/sig/turbopuffer/models/vector.rbs +13 -0
  187. data/sig/turbopuffer/models/vector_encoding.rbs +14 -0
  188. data/sig/turbopuffer/models/write_billing.rbs +27 -0
  189. data/sig/turbopuffer/models.rbs +61 -0
  190. data/sig/turbopuffer/namespace.rbs +5 -0
  191. data/sig/turbopuffer/request_options.rbs +36 -0
  192. data/sig/turbopuffer/resources/namespaces.rbs +81 -0
  193. data/sig/turbopuffer/version.rbs +3 -0
  194. metadata +251 -0
@@ -0,0 +1,175 @@
1
+ # typed: strong
2
+
3
+ module Turbopuffer
4
+ module Models
5
+ class NamespaceMultiQueryParams < 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::NamespaceMultiQueryParams,
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 { returns(T::Array[Turbopuffer::Query]) }
24
+ attr_accessor :queries
25
+
26
+ # The consistency level for a query.
27
+ sig do
28
+ returns(T.nilable(Turbopuffer::NamespaceMultiQueryParams::Consistency))
29
+ end
30
+ attr_reader :consistency
31
+
32
+ sig do
33
+ params(
34
+ consistency:
35
+ Turbopuffer::NamespaceMultiQueryParams::Consistency::OrHash
36
+ ).void
37
+ end
38
+ attr_writer :consistency
39
+
40
+ # The encoding to use for vectors in the response.
41
+ sig { returns(T.nilable(Turbopuffer::VectorEncoding::OrSymbol)) }
42
+ attr_reader :vector_encoding
43
+
44
+ sig do
45
+ params(vector_encoding: Turbopuffer::VectorEncoding::OrSymbol).void
46
+ end
47
+ attr_writer :vector_encoding
48
+
49
+ sig do
50
+ params(
51
+ queries: T::Array[Turbopuffer::Query::OrHash],
52
+ namespace: String,
53
+ consistency:
54
+ Turbopuffer::NamespaceMultiQueryParams::Consistency::OrHash,
55
+ vector_encoding: Turbopuffer::VectorEncoding::OrSymbol,
56
+ request_options: Turbopuffer::RequestOptions::OrHash
57
+ ).returns(T.attached_class)
58
+ end
59
+ def self.new(
60
+ queries:,
61
+ namespace: nil,
62
+ # The consistency level for a query.
63
+ consistency: nil,
64
+ # The encoding to use for vectors in the response.
65
+ vector_encoding: nil,
66
+ request_options: {}
67
+ )
68
+ end
69
+
70
+ sig do
71
+ override.returns(
72
+ {
73
+ namespace: String,
74
+ queries: T::Array[Turbopuffer::Query],
75
+ consistency: Turbopuffer::NamespaceMultiQueryParams::Consistency,
76
+ vector_encoding: Turbopuffer::VectorEncoding::OrSymbol,
77
+ request_options: Turbopuffer::RequestOptions
78
+ }
79
+ )
80
+ end
81
+ def to_hash
82
+ end
83
+
84
+ class Consistency < Turbopuffer::Internal::Type::BaseModel
85
+ OrHash =
86
+ T.type_alias do
87
+ T.any(
88
+ Turbopuffer::NamespaceMultiQueryParams::Consistency,
89
+ Turbopuffer::Internal::AnyHash
90
+ )
91
+ end
92
+
93
+ # The query's consistency level.
94
+ sig do
95
+ returns(
96
+ T.nilable(
97
+ Turbopuffer::NamespaceMultiQueryParams::Consistency::Level::OrSymbol
98
+ )
99
+ )
100
+ end
101
+ attr_reader :level
102
+
103
+ sig do
104
+ params(
105
+ level:
106
+ Turbopuffer::NamespaceMultiQueryParams::Consistency::Level::OrSymbol
107
+ ).void
108
+ end
109
+ attr_writer :level
110
+
111
+ # The consistency level for a query.
112
+ sig do
113
+ params(
114
+ level:
115
+ Turbopuffer::NamespaceMultiQueryParams::Consistency::Level::OrSymbol
116
+ ).returns(T.attached_class)
117
+ end
118
+ def self.new(
119
+ # The query's consistency level.
120
+ level: nil
121
+ )
122
+ end
123
+
124
+ sig do
125
+ override.returns(
126
+ {
127
+ level:
128
+ Turbopuffer::NamespaceMultiQueryParams::Consistency::Level::OrSymbol
129
+ }
130
+ )
131
+ end
132
+ def to_hash
133
+ end
134
+
135
+ # The query's consistency level.
136
+ module Level
137
+ extend Turbopuffer::Internal::Type::Enum
138
+
139
+ TaggedSymbol =
140
+ T.type_alias do
141
+ T.all(
142
+ Symbol,
143
+ Turbopuffer::NamespaceMultiQueryParams::Consistency::Level
144
+ )
145
+ end
146
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
147
+
148
+ # Strong consistency. Requires a round-trip to object storage to fetch the latest writes.
149
+ STRONG =
150
+ T.let(
151
+ :strong,
152
+ Turbopuffer::NamespaceMultiQueryParams::Consistency::Level::TaggedSymbol
153
+ )
154
+
155
+ # Eventual consistency. Does not require a round-trip to object storage, but may not see the latest writes.
156
+ EVENTUAL =
157
+ T.let(
158
+ :eventual,
159
+ Turbopuffer::NamespaceMultiQueryParams::Consistency::Level::TaggedSymbol
160
+ )
161
+
162
+ sig do
163
+ override.returns(
164
+ T::Array[
165
+ Turbopuffer::NamespaceMultiQueryParams::Consistency::Level::TaggedSymbol
166
+ ]
167
+ )
168
+ end
169
+ def self.values
170
+ end
171
+ end
172
+ end
173
+ end
174
+ end
175
+ end
@@ -0,0 +1,111 @@
1
+ # typed: strong
2
+
3
+ module Turbopuffer
4
+ module Models
5
+ class NamespaceMultiQueryResponse < Turbopuffer::Internal::Type::BaseModel
6
+ OrHash =
7
+ T.type_alias do
8
+ T.any(
9
+ Turbopuffer::Models::NamespaceMultiQueryResponse,
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 do
29
+ returns(
30
+ T::Array[Turbopuffer::Models::NamespaceMultiQueryResponse::Result]
31
+ )
32
+ end
33
+ attr_accessor :results
34
+
35
+ # The result of a multi-query.
36
+ sig do
37
+ params(
38
+ billing: Turbopuffer::QueryBilling::OrHash,
39
+ performance: Turbopuffer::QueryPerformance::OrHash,
40
+ results:
41
+ T::Array[
42
+ Turbopuffer::Models::NamespaceMultiQueryResponse::Result::OrHash
43
+ ]
44
+ ).returns(T.attached_class)
45
+ end
46
+ def self.new(
47
+ # The billing information for a query.
48
+ billing:,
49
+ # The performance information for a query.
50
+ performance:,
51
+ results:
52
+ )
53
+ end
54
+
55
+ sig do
56
+ override.returns(
57
+ {
58
+ billing: Turbopuffer::QueryBilling,
59
+ performance: Turbopuffer::QueryPerformance,
60
+ results:
61
+ T::Array[Turbopuffer::Models::NamespaceMultiQueryResponse::Result]
62
+ }
63
+ )
64
+ end
65
+ def to_hash
66
+ end
67
+
68
+ class Result < Turbopuffer::Internal::Type::BaseModel
69
+ OrHash =
70
+ T.type_alias do
71
+ T.any(
72
+ Turbopuffer::Models::NamespaceMultiQueryResponse::Result,
73
+ Turbopuffer::Internal::AnyHash
74
+ )
75
+ end
76
+
77
+ sig { returns(T.nilable(T::Hash[Symbol, T.anything])) }
78
+ attr_reader :aggregations
79
+
80
+ sig { params(aggregations: T::Hash[Symbol, T.anything]).void }
81
+ attr_writer :aggregations
82
+
83
+ sig { returns(T.nilable(T::Array[Turbopuffer::Row])) }
84
+ attr_reader :rows
85
+
86
+ sig { params(rows: T::Array[Turbopuffer::Row::OrHash]).void }
87
+ attr_writer :rows
88
+
89
+ sig do
90
+ params(
91
+ aggregations: T::Hash[Symbol, T.anything],
92
+ rows: T::Array[Turbopuffer::Row::OrHash]
93
+ ).returns(T.attached_class)
94
+ end
95
+ def self.new(aggregations: nil, rows: nil)
96
+ end
97
+
98
+ sig do
99
+ override.returns(
100
+ {
101
+ aggregations: T::Hash[Symbol, T.anything],
102
+ rows: T::Array[Turbopuffer::Row]
103
+ }
104
+ )
105
+ end
106
+ def to_hash
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,241 @@
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
+ # Exact filters for attributes to refine search results for. Think of it as a SQL
52
+ # WHERE clause.
53
+ sig { returns(T.nilable(T.anything)) }
54
+ attr_reader :filters
55
+
56
+ sig { params(filters: T.anything).void }
57
+ attr_writer :filters
58
+
59
+ # Whether to include attributes in the response.
60
+ sig { returns(T.nilable(Turbopuffer::IncludeAttributes::Variants)) }
61
+ attr_reader :include_attributes
62
+
63
+ sig do
64
+ params(
65
+ include_attributes: Turbopuffer::IncludeAttributes::Variants
66
+ ).void
67
+ end
68
+ attr_writer :include_attributes
69
+
70
+ # How to rank the documents in the namespace.
71
+ sig { returns(T.nilable(T.anything)) }
72
+ attr_reader :rank_by
73
+
74
+ sig { params(rank_by: T.anything).void }
75
+ attr_writer :rank_by
76
+
77
+ # The number of results to return.
78
+ sig { returns(T.nilable(Integer)) }
79
+ attr_reader :top_k
80
+
81
+ sig { params(top_k: Integer).void }
82
+ attr_writer :top_k
83
+
84
+ # The encoding to use for vectors in the response.
85
+ sig { returns(T.nilable(Turbopuffer::VectorEncoding::OrSymbol)) }
86
+ attr_reader :vector_encoding
87
+
88
+ sig do
89
+ params(vector_encoding: Turbopuffer::VectorEncoding::OrSymbol).void
90
+ end
91
+ attr_writer :vector_encoding
92
+
93
+ sig do
94
+ params(
95
+ namespace: String,
96
+ aggregate_by: T::Hash[Symbol, T.anything],
97
+ consistency: Turbopuffer::NamespaceQueryParams::Consistency::OrHash,
98
+ distance_metric: Turbopuffer::DistanceMetric::OrSymbol,
99
+ filters: T.anything,
100
+ include_attributes: Turbopuffer::IncludeAttributes::Variants,
101
+ rank_by: T.anything,
102
+ top_k: Integer,
103
+ vector_encoding: Turbopuffer::VectorEncoding::OrSymbol,
104
+ request_options: Turbopuffer::RequestOptions::OrHash
105
+ ).returns(T.attached_class)
106
+ end
107
+ def self.new(
108
+ namespace: nil,
109
+ # Aggregations to compute over all documents in the namespace that match the
110
+ # filters.
111
+ aggregate_by: nil,
112
+ # The consistency level for a query.
113
+ consistency: nil,
114
+ # A function used to calculate vector similarity.
115
+ distance_metric: nil,
116
+ # Exact filters for attributes to refine search results for. Think of it as a SQL
117
+ # WHERE clause.
118
+ filters: nil,
119
+ # Whether to include attributes in the response.
120
+ include_attributes: nil,
121
+ # How to rank the documents in the namespace.
122
+ rank_by: nil,
123
+ # The number of results to return.
124
+ top_k: nil,
125
+ # The encoding to use for vectors in the response.
126
+ vector_encoding: nil,
127
+ request_options: {}
128
+ )
129
+ end
130
+
131
+ sig do
132
+ override.returns(
133
+ {
134
+ namespace: String,
135
+ aggregate_by: T::Hash[Symbol, T.anything],
136
+ consistency: Turbopuffer::NamespaceQueryParams::Consistency,
137
+ distance_metric: Turbopuffer::DistanceMetric::OrSymbol,
138
+ filters: T.anything,
139
+ include_attributes: Turbopuffer::IncludeAttributes::Variants,
140
+ rank_by: T.anything,
141
+ top_k: Integer,
142
+ vector_encoding: Turbopuffer::VectorEncoding::OrSymbol,
143
+ request_options: Turbopuffer::RequestOptions
144
+ }
145
+ )
146
+ end
147
+ def to_hash
148
+ end
149
+
150
+ class Consistency < Turbopuffer::Internal::Type::BaseModel
151
+ OrHash =
152
+ T.type_alias do
153
+ T.any(
154
+ Turbopuffer::NamespaceQueryParams::Consistency,
155
+ Turbopuffer::Internal::AnyHash
156
+ )
157
+ end
158
+
159
+ # The query's consistency level.
160
+ sig do
161
+ returns(
162
+ T.nilable(
163
+ Turbopuffer::NamespaceQueryParams::Consistency::Level::OrSymbol
164
+ )
165
+ )
166
+ end
167
+ attr_reader :level
168
+
169
+ sig do
170
+ params(
171
+ level:
172
+ Turbopuffer::NamespaceQueryParams::Consistency::Level::OrSymbol
173
+ ).void
174
+ end
175
+ attr_writer :level
176
+
177
+ # The consistency level for a query.
178
+ sig do
179
+ params(
180
+ level:
181
+ Turbopuffer::NamespaceQueryParams::Consistency::Level::OrSymbol
182
+ ).returns(T.attached_class)
183
+ end
184
+ def self.new(
185
+ # The query's consistency level.
186
+ level: nil
187
+ )
188
+ end
189
+
190
+ sig do
191
+ override.returns(
192
+ {
193
+ level:
194
+ Turbopuffer::NamespaceQueryParams::Consistency::Level::OrSymbol
195
+ }
196
+ )
197
+ end
198
+ def to_hash
199
+ end
200
+
201
+ # The query's consistency level.
202
+ module Level
203
+ extend Turbopuffer::Internal::Type::Enum
204
+
205
+ TaggedSymbol =
206
+ T.type_alias do
207
+ T.all(
208
+ Symbol,
209
+ Turbopuffer::NamespaceQueryParams::Consistency::Level
210
+ )
211
+ end
212
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
213
+
214
+ # Strong consistency. Requires a round-trip to object storage to fetch the latest writes.
215
+ STRONG =
216
+ T.let(
217
+ :strong,
218
+ Turbopuffer::NamespaceQueryParams::Consistency::Level::TaggedSymbol
219
+ )
220
+
221
+ # Eventual consistency. Does not require a round-trip to object storage, but may not see the latest writes.
222
+ EVENTUAL =
223
+ T.let(
224
+ :eventual,
225
+ Turbopuffer::NamespaceQueryParams::Consistency::Level::TaggedSymbol
226
+ )
227
+
228
+ sig do
229
+ override.returns(
230
+ T::Array[
231
+ Turbopuffer::NamespaceQueryParams::Consistency::Level::TaggedSymbol
232
+ ]
233
+ )
234
+ end
235
+ def self.values
236
+ end
237
+ end
238
+ end
239
+ end
240
+ end
241
+ end
@@ -0,0 +1,73 @@
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::Hash[Symbol, T.anything])) }
29
+ attr_reader :aggregations
30
+
31
+ sig { params(aggregations: T::Hash[Symbol, T.anything]).void }
32
+ attr_writer :aggregations
33
+
34
+ sig { returns(T.nilable(T::Array[Turbopuffer::Row])) }
35
+ attr_reader :rows
36
+
37
+ sig { params(rows: T::Array[Turbopuffer::Row::OrHash]).void }
38
+ attr_writer :rows
39
+
40
+ # The result of a query.
41
+ sig do
42
+ params(
43
+ billing: Turbopuffer::QueryBilling::OrHash,
44
+ performance: Turbopuffer::QueryPerformance::OrHash,
45
+ aggregations: T::Hash[Symbol, T.anything],
46
+ rows: T::Array[Turbopuffer::Row::OrHash]
47
+ ).returns(T.attached_class)
48
+ end
49
+ def self.new(
50
+ # The billing information for a query.
51
+ billing:,
52
+ # The performance information for a query.
53
+ performance:,
54
+ aggregations: nil,
55
+ rows: nil
56
+ )
57
+ end
58
+
59
+ sig do
60
+ override.returns(
61
+ {
62
+ billing: Turbopuffer::QueryBilling,
63
+ performance: Turbopuffer::QueryPerformance,
64
+ aggregations: T::Hash[Symbol, T.anything],
65
+ rows: T::Array[Turbopuffer::Row]
66
+ }
67
+ )
68
+ end
69
+ def to_hash
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,93 @@
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
+ # The number of searches to run.
31
+ sig { returns(T.nilable(Integer)) }
32
+ attr_reader :num
33
+
34
+ sig { params(num: Integer).void }
35
+ attr_writer :num
36
+
37
+ # Use specific query vectors for the measurement. If omitted, sampled from the
38
+ # index.
39
+ sig { returns(T.nilable(T::Array[Float])) }
40
+ attr_reader :queries
41
+
42
+ sig { params(queries: T::Array[Float]).void }
43
+ attr_writer :queries
44
+
45
+ # Search for `top_k` nearest neighbors.
46
+ sig { returns(T.nilable(Integer)) }
47
+ attr_reader :top_k
48
+
49
+ sig { params(top_k: Integer).void }
50
+ attr_writer :top_k
51
+
52
+ sig do
53
+ params(
54
+ namespace: String,
55
+ filters: T.anything,
56
+ num: Integer,
57
+ queries: T::Array[Float],
58
+ top_k: Integer,
59
+ request_options: Turbopuffer::RequestOptions::OrHash
60
+ ).returns(T.attached_class)
61
+ end
62
+ def self.new(
63
+ namespace: nil,
64
+ # Filter by attributes. Same syntax as the query endpoint.
65
+ filters: nil,
66
+ # The number of searches to run.
67
+ num: nil,
68
+ # Use specific query vectors for the measurement. If omitted, sampled from the
69
+ # index.
70
+ queries: nil,
71
+ # Search for `top_k` nearest neighbors.
72
+ top_k: nil,
73
+ request_options: {}
74
+ )
75
+ end
76
+
77
+ sig do
78
+ override.returns(
79
+ {
80
+ namespace: String,
81
+ filters: T.anything,
82
+ num: Integer,
83
+ queries: T::Array[Float],
84
+ top_k: Integer,
85
+ request_options: Turbopuffer::RequestOptions
86
+ }
87
+ )
88
+ end
89
+ def to_hash
90
+ end
91
+ end
92
+ end
93
+ end