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.
- checksums.yaml +4 -4
- data/.ignore +2 -0
- data/CHANGELOG.md +205 -0
- data/README.md +270 -40
- data/SECURITY.md +27 -0
- data/lib/turbopuffer/client.rb +122 -16
- data/lib/turbopuffer/errors.rb +228 -0
- data/lib/turbopuffer/file_part.rb +55 -0
- data/lib/turbopuffer/internal/namespace_page.rb +86 -0
- data/lib/turbopuffer/internal/transport/base_client.rb +567 -0
- data/lib/turbopuffer/internal/transport/pooled_net_requester.rb +201 -0
- data/lib/turbopuffer/internal/type/array_of.rb +168 -0
- data/lib/turbopuffer/internal/type/base_model.rb +529 -0
- data/lib/turbopuffer/internal/type/base_page.rb +55 -0
- data/lib/turbopuffer/internal/type/boolean.rb +77 -0
- data/lib/turbopuffer/internal/type/converter.rb +327 -0
- data/lib/turbopuffer/internal/type/enum.rb +152 -0
- data/lib/turbopuffer/internal/type/file_input.rb +108 -0
- data/lib/turbopuffer/internal/type/hash_of.rb +188 -0
- data/lib/turbopuffer/internal/type/request_parameters.rb +42 -0
- data/lib/turbopuffer/internal/type/union.rb +254 -0
- data/lib/turbopuffer/internal/type/unknown.rb +81 -0
- data/lib/turbopuffer/internal/util.rb +914 -0
- data/lib/turbopuffer/internal.rb +20 -0
- data/lib/turbopuffer/models/aggregation_group.rb +8 -0
- data/lib/turbopuffer/models/attribute_schema.rb +19 -0
- data/lib/turbopuffer/models/attribute_schema_config.rb +56 -0
- data/lib/turbopuffer/models/attribute_type.rb +7 -0
- data/lib/turbopuffer/models/client_namespaces_params.rb +38 -0
- data/lib/turbopuffer/models/columns.rb +64 -0
- data/lib/turbopuffer/models/distance_metric.rb +19 -0
- data/lib/turbopuffer/models/full_text_search.rb +20 -0
- data/lib/turbopuffer/models/full_text_search_config.rb +83 -0
- data/lib/turbopuffer/models/id.rb +19 -0
- data/lib/turbopuffer/models/include_attributes.rb +22 -0
- data/lib/turbopuffer/models/language.rb +32 -0
- data/lib/turbopuffer/models/namespace_delete_all_params.rb +20 -0
- data/lib/turbopuffer/models/namespace_delete_all_response.rb +19 -0
- data/lib/turbopuffer/models/namespace_explain_query_params.rb +137 -0
- data/lib/turbopuffer/models/namespace_explain_query_response.rb +19 -0
- data/lib/turbopuffer/models/namespace_hint_cache_warm_params.rb +20 -0
- data/lib/turbopuffer/models/namespace_hint_cache_warm_response.rb +26 -0
- data/lib/turbopuffer/models/namespace_metadata.rb +43 -0
- data/lib/turbopuffer/models/namespace_metadata_params.rb +20 -0
- data/lib/turbopuffer/models/namespace_multi_query_params.rb +73 -0
- data/lib/turbopuffer/models/namespace_multi_query_response.rb +58 -0
- data/lib/turbopuffer/models/namespace_query_params.rb +137 -0
- data/lib/turbopuffer/models/namespace_query_response.rb +49 -0
- data/lib/turbopuffer/models/namespace_recall_params.rb +66 -0
- data/lib/turbopuffer/models/namespace_recall_response.rb +68 -0
- data/lib/turbopuffer/models/namespace_schema_params.rb +20 -0
- data/lib/turbopuffer/models/namespace_schema_response.rb +8 -0
- data/lib/turbopuffer/models/namespace_summary.rb +19 -0
- data/lib/turbopuffer/models/namespace_update_schema_params.rb +29 -0
- data/lib/turbopuffer/models/namespace_update_schema_response.rb +9 -0
- data/lib/turbopuffer/models/namespace_write_params.rb +158 -0
- data/lib/turbopuffer/models/namespace_write_response.rb +67 -0
- data/lib/turbopuffer/models/query.rb +81 -0
- data/lib/turbopuffer/models/query_billing.rb +26 -0
- data/lib/turbopuffer/models/query_performance.rb +63 -0
- data/lib/turbopuffer/models/row.rb +46 -0
- data/lib/turbopuffer/models/tokenizer.rb +19 -0
- data/lib/turbopuffer/models/vector.rb +22 -0
- data/lib/turbopuffer/models/vector_encoding.rb +16 -0
- data/lib/turbopuffer/models/write_billing.rb +26 -0
- data/lib/turbopuffer/models.rb +106 -0
- data/lib/turbopuffer/namespace.rb +14 -50
- data/lib/turbopuffer/request_options.rb +77 -0
- data/lib/turbopuffer/resources/namespaces.rb +366 -0
- data/lib/turbopuffer/version.rb +1 -1
- data/lib/turbopuffer.rb +92 -4
- data/manifest.yaml +15 -0
- data/rbi/turbopuffer/client.rbi +91 -0
- data/rbi/turbopuffer/errors.rbi +205 -0
- data/rbi/turbopuffer/file_part.rbi +37 -0
- data/rbi/turbopuffer/internal/namespace_page.rbi +22 -0
- data/rbi/turbopuffer/internal/transport/base_client.rbi +297 -0
- data/rbi/turbopuffer/internal/transport/pooled_net_requester.rbi +80 -0
- data/rbi/turbopuffer/internal/type/array_of.rbi +104 -0
- data/rbi/turbopuffer/internal/type/base_model.rbi +304 -0
- data/rbi/turbopuffer/internal/type/base_page.rbi +43 -0
- data/rbi/turbopuffer/internal/type/boolean.rbi +58 -0
- data/rbi/turbopuffer/internal/type/converter.rbi +216 -0
- data/rbi/turbopuffer/internal/type/enum.rbi +82 -0
- data/rbi/turbopuffer/internal/type/file_input.rbi +59 -0
- data/rbi/turbopuffer/internal/type/hash_of.rbi +104 -0
- data/rbi/turbopuffer/internal/type/request_parameters.rbi +31 -0
- data/rbi/turbopuffer/internal/type/union.rbi +128 -0
- data/rbi/turbopuffer/internal/type/unknown.rbi +58 -0
- data/rbi/turbopuffer/internal/util.rbi +487 -0
- data/rbi/turbopuffer/internal.rbi +18 -0
- data/rbi/turbopuffer/models/aggregation_group.rbi +13 -0
- data/rbi/turbopuffer/models/attribute_schema.rbi +17 -0
- data/rbi/turbopuffer/models/attribute_schema_config.rbi +103 -0
- data/rbi/turbopuffer/models/attribute_type.rbi +7 -0
- data/rbi/turbopuffer/models/client_namespaces_params.rbi +71 -0
- data/rbi/turbopuffer/models/columns.rbi +82 -0
- data/rbi/turbopuffer/models/distance_metric.rbi +27 -0
- data/rbi/turbopuffer/models/full_text_search.rbi +19 -0
- data/rbi/turbopuffer/models/full_text_search_config.rbi +133 -0
- data/rbi/turbopuffer/models/id.rbi +16 -0
- data/rbi/turbopuffer/models/include_attributes.rbi +24 -0
- data/rbi/turbopuffer/models/language.rbi +36 -0
- data/rbi/turbopuffer/models/namespace_delete_all_params.rbi +41 -0
- data/rbi/turbopuffer/models/namespace_delete_all_response.rbi +31 -0
- data/rbi/turbopuffer/models/namespace_explain_query_params.rbi +273 -0
- data/rbi/turbopuffer/models/namespace_explain_query_response.rbi +34 -0
- data/rbi/turbopuffer/models/namespace_hint_cache_warm_params.rbi +41 -0
- data/rbi/turbopuffer/models/namespace_hint_cache_warm_response.rbi +38 -0
- data/rbi/turbopuffer/models/namespace_metadata.rbi +62 -0
- data/rbi/turbopuffer/models/namespace_metadata_params.rbi +41 -0
- data/rbi/turbopuffer/models/namespace_multi_query_params.rbi +175 -0
- data/rbi/turbopuffer/models/namespace_multi_query_response.rbi +121 -0
- data/rbi/turbopuffer/models/namespace_query_params.rbi +267 -0
- data/rbi/turbopuffer/models/namespace_query_response.rbi +84 -0
- data/rbi/turbopuffer/models/namespace_recall_params.rbi +106 -0
- data/rbi/turbopuffer/models/namespace_recall_response.rbi +134 -0
- data/rbi/turbopuffer/models/namespace_schema_params.rbi +41 -0
- data/rbi/turbopuffer/models/namespace_schema_response.rbi +11 -0
- data/rbi/turbopuffer/models/namespace_summary.rbi +28 -0
- data/rbi/turbopuffer/models/namespace_update_schema_params.rbi +80 -0
- data/rbi/turbopuffer/models/namespace_update_schema_response.rbi +11 -0
- data/rbi/turbopuffer/models/namespace_write_params.rbi +290 -0
- data/rbi/turbopuffer/models/namespace_write_response.rbi +101 -0
- data/rbi/turbopuffer/models/query.rbi +132 -0
- data/rbi/turbopuffer/models/query_billing.rbi +46 -0
- data/rbi/turbopuffer/models/query_performance.rbi +82 -0
- data/rbi/turbopuffer/models/row.rbi +47 -0
- data/rbi/turbopuffer/models/tokenizer.rbi +24 -0
- data/rbi/turbopuffer/models/vector.rbi +22 -0
- data/rbi/turbopuffer/models/vector_encoding.rbi +22 -0
- data/rbi/turbopuffer/models/write_billing.rbi +49 -0
- data/rbi/turbopuffer/models.rbi +72 -0
- data/rbi/turbopuffer/namespace.rbi +8 -0
- data/rbi/turbopuffer/request_options.rbi +59 -0
- data/rbi/turbopuffer/resources/namespaces.rbi +304 -0
- data/rbi/turbopuffer/version.rbi +5 -0
- data/sig/turbopuffer/client.rbs +41 -0
- data/sig/turbopuffer/errors.rbs +117 -0
- data/sig/turbopuffer/file_part.rbs +21 -0
- data/sig/turbopuffer/internal/namespace_page.rbs +13 -0
- data/sig/turbopuffer/internal/transport/base_client.rbs +131 -0
- data/sig/turbopuffer/internal/transport/pooled_net_requester.rbs +45 -0
- data/sig/turbopuffer/internal/type/array_of.rbs +48 -0
- data/sig/turbopuffer/internal/type/base_model.rbs +102 -0
- data/sig/turbopuffer/internal/type/base_page.rbs +24 -0
- data/sig/turbopuffer/internal/type/boolean.rbs +26 -0
- data/sig/turbopuffer/internal/type/converter.rbs +79 -0
- data/sig/turbopuffer/internal/type/enum.rbs +32 -0
- data/sig/turbopuffer/internal/type/file_input.rbs +25 -0
- data/sig/turbopuffer/internal/type/hash_of.rbs +48 -0
- data/sig/turbopuffer/internal/type/request_parameters.rbs +19 -0
- data/sig/turbopuffer/internal/type/union.rbs +52 -0
- data/sig/turbopuffer/internal/type/unknown.rbs +26 -0
- data/sig/turbopuffer/internal/util.rbs +185 -0
- data/sig/turbopuffer/internal.rbs +9 -0
- data/sig/turbopuffer/models/aggregation_group.rbs +7 -0
- data/sig/turbopuffer/models/attribute_schema.rbs +11 -0
- data/sig/turbopuffer/models/attribute_schema_config.rbs +52 -0
- data/sig/turbopuffer/models/attribute_type.rbs +5 -0
- data/sig/turbopuffer/models/client_namespaces_params.rbs +38 -0
- data/sig/turbopuffer/models/columns.rbs +42 -0
- data/sig/turbopuffer/models/distance_metric.rbs +17 -0
- data/sig/turbopuffer/models/full_text_search.rbs +11 -0
- data/sig/turbopuffer/models/full_text_search_config.rbs +75 -0
- data/sig/turbopuffer/models/id.rbs +11 -0
- data/sig/turbopuffer/models/include_attributes.rbs +13 -0
- data/sig/turbopuffer/models/language.rbs +48 -0
- data/sig/turbopuffer/models/namespace_delete_all_params.rbs +25 -0
- data/sig/turbopuffer/models/namespace_delete_all_response.rbs +13 -0
- data/sig/turbopuffer/models/namespace_explain_query_params.rbs +141 -0
- data/sig/turbopuffer/models/namespace_explain_query_response.rbs +15 -0
- data/sig/turbopuffer/models/namespace_hint_cache_warm_params.rbs +25 -0
- data/sig/turbopuffer/models/namespace_hint_cache_warm_response.rbs +18 -0
- data/sig/turbopuffer/models/namespace_metadata.rbs +35 -0
- data/sig/turbopuffer/models/namespace_metadata_params.rbs +25 -0
- data/sig/turbopuffer/models/namespace_multi_query_params.rbs +86 -0
- data/sig/turbopuffer/models/namespace_multi_query_response.rbs +65 -0
- data/sig/turbopuffer/models/namespace_query_params.rbs +139 -0
- data/sig/turbopuffer/models/namespace_query_response.rbs +48 -0
- data/sig/turbopuffer/models/namespace_recall_params.rbs +63 -0
- data/sig/turbopuffer/models/namespace_recall_response.rbs +61 -0
- data/sig/turbopuffer/models/namespace_schema_params.rbs +25 -0
- data/sig/turbopuffer/models/namespace_schema_response.rbs +8 -0
- data/sig/turbopuffer/models/namespace_summary.rbs +13 -0
- data/sig/turbopuffer/models/namespace_update_schema_params.rbs +37 -0
- data/sig/turbopuffer/models/namespace_update_schema_response.rbs +8 -0
- data/sig/turbopuffer/models/namespace_write_params.rbs +156 -0
- data/sig/turbopuffer/models/namespace_write_response.rbs +56 -0
- data/sig/turbopuffer/models/query.rbs +75 -0
- data/sig/turbopuffer/models/query_billing.rbs +25 -0
- data/sig/turbopuffer/models/query_performance.rbs +45 -0
- data/sig/turbopuffer/models/row.rbs +24 -0
- data/sig/turbopuffer/models/tokenizer.rbs +16 -0
- data/sig/turbopuffer/models/vector.rbs +13 -0
- data/sig/turbopuffer/models/vector_encoding.rbs +14 -0
- data/sig/turbopuffer/models/write_billing.rbs +27 -0
- data/sig/turbopuffer/models.rbs +65 -0
- data/sig/turbopuffer/namespace.rbs +5 -0
- data/sig/turbopuffer/request_options.rbs +36 -0
- data/sig/turbopuffer/resources/namespaces.rbs +99 -0
- data/sig/turbopuffer/version.rbs +3 -0
- metadata +218 -29
- data/.standard.yml +0 -3
- data/LICENSE.txt +0 -21
- data/Rakefile +0 -10
- data/sig/turbopuffer.rbs +0 -4
@@ -0,0 +1,82 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Turbopuffer
|
4
|
+
module Models
|
5
|
+
class QueryPerformance < Turbopuffer::Internal::Type::BaseModel
|
6
|
+
OrHash =
|
7
|
+
T.type_alias do
|
8
|
+
T.any(Turbopuffer::QueryPerformance, Turbopuffer::Internal::AnyHash)
|
9
|
+
end
|
10
|
+
|
11
|
+
# the approximate number of documents in the namespace.
|
12
|
+
sig { returns(Integer) }
|
13
|
+
attr_accessor :approx_namespace_size
|
14
|
+
|
15
|
+
# The ratio of cache hits to total cache lookups.
|
16
|
+
sig { returns(Float) }
|
17
|
+
attr_accessor :cache_hit_ratio
|
18
|
+
|
19
|
+
# A qualitative description of the cache hit ratio (`hot`, `warm`, or `cold`).
|
20
|
+
sig { returns(String) }
|
21
|
+
attr_accessor :cache_temperature
|
22
|
+
|
23
|
+
# The number of unindexed documents processed by the query.
|
24
|
+
sig { returns(Integer) }
|
25
|
+
attr_accessor :exhaustive_search_count
|
26
|
+
|
27
|
+
# Request time measured on the server, excluding time spent waiting due to the
|
28
|
+
# namespace concurrency limit.
|
29
|
+
sig { returns(Integer) }
|
30
|
+
attr_accessor :query_execution_ms
|
31
|
+
|
32
|
+
# Request time measured on the server, including time spent waiting for other
|
33
|
+
# queries to complete if the namespace was at its concurrency limit.
|
34
|
+
sig { returns(Integer) }
|
35
|
+
attr_accessor :server_total_ms
|
36
|
+
|
37
|
+
# The performance information for a query.
|
38
|
+
sig do
|
39
|
+
params(
|
40
|
+
approx_namespace_size: Integer,
|
41
|
+
cache_hit_ratio: Float,
|
42
|
+
cache_temperature: String,
|
43
|
+
exhaustive_search_count: Integer,
|
44
|
+
query_execution_ms: Integer,
|
45
|
+
server_total_ms: Integer
|
46
|
+
).returns(T.attached_class)
|
47
|
+
end
|
48
|
+
def self.new(
|
49
|
+
# the approximate number of documents in the namespace.
|
50
|
+
approx_namespace_size:,
|
51
|
+
# The ratio of cache hits to total cache lookups.
|
52
|
+
cache_hit_ratio:,
|
53
|
+
# A qualitative description of the cache hit ratio (`hot`, `warm`, or `cold`).
|
54
|
+
cache_temperature:,
|
55
|
+
# The number of unindexed documents processed by the query.
|
56
|
+
exhaustive_search_count:,
|
57
|
+
# Request time measured on the server, excluding time spent waiting due to the
|
58
|
+
# namespace concurrency limit.
|
59
|
+
query_execution_ms:,
|
60
|
+
# Request time measured on the server, including time spent waiting for other
|
61
|
+
# queries to complete if the namespace was at its concurrency limit.
|
62
|
+
server_total_ms:
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
66
|
+
sig do
|
67
|
+
override.returns(
|
68
|
+
{
|
69
|
+
approx_namespace_size: Integer,
|
70
|
+
cache_hit_ratio: Float,
|
71
|
+
cache_temperature: String,
|
72
|
+
exhaustive_search_count: Integer,
|
73
|
+
query_execution_ms: Integer,
|
74
|
+
server_total_ms: Integer
|
75
|
+
}
|
76
|
+
)
|
77
|
+
end
|
78
|
+
def to_hash
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Turbopuffer
|
4
|
+
module Models
|
5
|
+
class Row < Turbopuffer::Internal::Type::BaseModel
|
6
|
+
OrHash =
|
7
|
+
T.type_alias { T.any(Turbopuffer::Row, Turbopuffer::Internal::AnyHash) }
|
8
|
+
|
9
|
+
# An identifier for a document.
|
10
|
+
sig { returns(Turbopuffer::ID::Variants) }
|
11
|
+
attr_accessor :id
|
12
|
+
|
13
|
+
# A vector embedding associated with a document.
|
14
|
+
sig { returns(T.nilable(Turbopuffer::Vector::Variants)) }
|
15
|
+
attr_reader :vector
|
16
|
+
|
17
|
+
sig { params(vector: Turbopuffer::Vector::Variants).void }
|
18
|
+
attr_writer :vector
|
19
|
+
|
20
|
+
# A single document, in a row-based format.
|
21
|
+
sig do
|
22
|
+
params(
|
23
|
+
id: Turbopuffer::ID::Variants,
|
24
|
+
vector: Turbopuffer::Vector::Variants
|
25
|
+
).returns(T.attached_class)
|
26
|
+
end
|
27
|
+
def self.new(
|
28
|
+
# An identifier for a document.
|
29
|
+
id:,
|
30
|
+
# A vector embedding associated with a document.
|
31
|
+
vector: nil
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
sig do
|
36
|
+
override.returns(
|
37
|
+
{
|
38
|
+
id: Turbopuffer::ID::Variants,
|
39
|
+
vector: Turbopuffer::Vector::Variants
|
40
|
+
}
|
41
|
+
)
|
42
|
+
end
|
43
|
+
def to_hash
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Turbopuffer
|
4
|
+
module Models
|
5
|
+
# The tokenizer to use for full-text search on an attribute. Defaults to
|
6
|
+
# `word_v2`.
|
7
|
+
module Tokenizer
|
8
|
+
extend Turbopuffer::Internal::Type::Enum
|
9
|
+
|
10
|
+
TaggedSymbol = T.type_alias { T.all(Symbol, Turbopuffer::Tokenizer) }
|
11
|
+
OrSymbol = T.type_alias { T.any(Symbol, String) }
|
12
|
+
|
13
|
+
PRE_TOKENIZED_ARRAY =
|
14
|
+
T.let(:pre_tokenized_array, Turbopuffer::Tokenizer::TaggedSymbol)
|
15
|
+
WORD_V0 = T.let(:word_v0, Turbopuffer::Tokenizer::TaggedSymbol)
|
16
|
+
WORD_V1 = T.let(:word_v1, Turbopuffer::Tokenizer::TaggedSymbol)
|
17
|
+
WORD_V2 = T.let(:word_v2, Turbopuffer::Tokenizer::TaggedSymbol)
|
18
|
+
|
19
|
+
sig { override.returns(T::Array[Turbopuffer::Tokenizer::TaggedSymbol]) }
|
20
|
+
def self.values
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Turbopuffer
|
4
|
+
module Models
|
5
|
+
# A vector embedding associated with a document.
|
6
|
+
module Vector
|
7
|
+
extend Turbopuffer::Internal::Type::Union
|
8
|
+
|
9
|
+
Variants = T.type_alias { T.any(T::Array[Float], String) }
|
10
|
+
|
11
|
+
sig { override.returns(T::Array[Turbopuffer::Vector::Variants]) }
|
12
|
+
def self.variants
|
13
|
+
end
|
14
|
+
|
15
|
+
FloatArray =
|
16
|
+
T.let(
|
17
|
+
Turbopuffer::Internal::Type::ArrayOf[Float],
|
18
|
+
Turbopuffer::Internal::Type::Converter
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Turbopuffer
|
4
|
+
module Models
|
5
|
+
# The encoding to use for vectors in the response.
|
6
|
+
module VectorEncoding
|
7
|
+
extend Turbopuffer::Internal::Type::Enum
|
8
|
+
|
9
|
+
TaggedSymbol = T.type_alias { T.all(Symbol, Turbopuffer::VectorEncoding) }
|
10
|
+
OrSymbol = T.type_alias { T.any(Symbol, String) }
|
11
|
+
|
12
|
+
FLOAT = T.let(:float, Turbopuffer::VectorEncoding::TaggedSymbol)
|
13
|
+
BASE64 = T.let(:base64, Turbopuffer::VectorEncoding::TaggedSymbol)
|
14
|
+
|
15
|
+
sig do
|
16
|
+
override.returns(T::Array[Turbopuffer::VectorEncoding::TaggedSymbol])
|
17
|
+
end
|
18
|
+
def self.values
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Turbopuffer
|
4
|
+
module Models
|
5
|
+
class WriteBilling < Turbopuffer::Internal::Type::BaseModel
|
6
|
+
OrHash =
|
7
|
+
T.type_alias do
|
8
|
+
T.any(Turbopuffer::WriteBilling, Turbopuffer::Internal::AnyHash)
|
9
|
+
end
|
10
|
+
|
11
|
+
# The number of billable logical bytes written to the namespace.
|
12
|
+
sig { returns(Integer) }
|
13
|
+
attr_accessor :billable_logical_bytes_written
|
14
|
+
|
15
|
+
# The billing information for a query.
|
16
|
+
sig { returns(T.nilable(Turbopuffer::QueryBilling)) }
|
17
|
+
attr_reader :query
|
18
|
+
|
19
|
+
sig { params(query: Turbopuffer::QueryBilling::OrHash).void }
|
20
|
+
attr_writer :query
|
21
|
+
|
22
|
+
# The billing information for a write request.
|
23
|
+
sig do
|
24
|
+
params(
|
25
|
+
billable_logical_bytes_written: Integer,
|
26
|
+
query: Turbopuffer::QueryBilling::OrHash
|
27
|
+
).returns(T.attached_class)
|
28
|
+
end
|
29
|
+
def self.new(
|
30
|
+
# The number of billable logical bytes written to the namespace.
|
31
|
+
billable_logical_bytes_written:,
|
32
|
+
# The billing information for a query.
|
33
|
+
query: nil
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
sig do
|
38
|
+
override.returns(
|
39
|
+
{
|
40
|
+
billable_logical_bytes_written: Integer,
|
41
|
+
query: Turbopuffer::QueryBilling
|
42
|
+
}
|
43
|
+
)
|
44
|
+
end
|
45
|
+
def to_hash
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Turbopuffer
|
4
|
+
AggregationGroup =
|
5
|
+
T.let(
|
6
|
+
Turbopuffer::Models::AggregationGroup,
|
7
|
+
Turbopuffer::Internal::Type::Converter
|
8
|
+
)
|
9
|
+
|
10
|
+
AttributeSchema = Turbopuffer::Models::AttributeSchema
|
11
|
+
|
12
|
+
AttributeSchemaConfig = Turbopuffer::Models::AttributeSchemaConfig
|
13
|
+
|
14
|
+
AttributeType = Turbopuffer::Models::AttributeType
|
15
|
+
|
16
|
+
ClientNamespacesParams = Turbopuffer::Models::ClientNamespacesParams
|
17
|
+
|
18
|
+
Columns = Turbopuffer::Models::Columns
|
19
|
+
|
20
|
+
DistanceMetric = Turbopuffer::Models::DistanceMetric
|
21
|
+
|
22
|
+
FullTextSearch = Turbopuffer::Models::FullTextSearch
|
23
|
+
|
24
|
+
FullTextSearchConfig = Turbopuffer::Models::FullTextSearchConfig
|
25
|
+
|
26
|
+
ID = Turbopuffer::Models::ID
|
27
|
+
|
28
|
+
IncludeAttributes = Turbopuffer::Models::IncludeAttributes
|
29
|
+
|
30
|
+
Language = Turbopuffer::Models::Language
|
31
|
+
|
32
|
+
NamespaceDeleteAllParams = Turbopuffer::Models::NamespaceDeleteAllParams
|
33
|
+
|
34
|
+
NamespaceExplainQueryParams = Turbopuffer::Models::NamespaceExplainQueryParams
|
35
|
+
|
36
|
+
NamespaceHintCacheWarmParams =
|
37
|
+
Turbopuffer::Models::NamespaceHintCacheWarmParams
|
38
|
+
|
39
|
+
NamespaceMetadata = Turbopuffer::Models::NamespaceMetadata
|
40
|
+
|
41
|
+
NamespaceMetadataParams = Turbopuffer::Models::NamespaceMetadataParams
|
42
|
+
|
43
|
+
NamespaceMultiQueryParams = Turbopuffer::Models::NamespaceMultiQueryParams
|
44
|
+
|
45
|
+
NamespaceQueryParams = Turbopuffer::Models::NamespaceQueryParams
|
46
|
+
|
47
|
+
NamespaceRecallParams = Turbopuffer::Models::NamespaceRecallParams
|
48
|
+
|
49
|
+
NamespaceSchemaParams = Turbopuffer::Models::NamespaceSchemaParams
|
50
|
+
|
51
|
+
NamespaceSummary = Turbopuffer::Models::NamespaceSummary
|
52
|
+
|
53
|
+
NamespaceUpdateSchemaParams = Turbopuffer::Models::NamespaceUpdateSchemaParams
|
54
|
+
|
55
|
+
NamespaceWriteParams = Turbopuffer::Models::NamespaceWriteParams
|
56
|
+
|
57
|
+
Query = Turbopuffer::Models::Query
|
58
|
+
|
59
|
+
QueryBilling = Turbopuffer::Models::QueryBilling
|
60
|
+
|
61
|
+
QueryPerformance = Turbopuffer::Models::QueryPerformance
|
62
|
+
|
63
|
+
Row = Turbopuffer::Models::Row
|
64
|
+
|
65
|
+
Tokenizer = Turbopuffer::Models::Tokenizer
|
66
|
+
|
67
|
+
Vector = Turbopuffer::Models::Vector
|
68
|
+
|
69
|
+
VectorEncoding = Turbopuffer::Models::VectorEncoding
|
70
|
+
|
71
|
+
WriteBilling = Turbopuffer::Models::WriteBilling
|
72
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Turbopuffer
|
4
|
+
# Specify HTTP behaviour to use for a specific request. These options supplement
|
5
|
+
# or override those provided at the client level.
|
6
|
+
#
|
7
|
+
# When making a request, you can pass an actual {RequestOptions} instance, or
|
8
|
+
# simply pass a Hash with symbol keys matching the attributes on this class.
|
9
|
+
class RequestOptions < Turbopuffer::Internal::Type::BaseModel
|
10
|
+
OrHash =
|
11
|
+
T.type_alias do
|
12
|
+
T.any(Turbopuffer::RequestOptions, Turbopuffer::Internal::AnyHash)
|
13
|
+
end
|
14
|
+
|
15
|
+
# @api private
|
16
|
+
sig { params(opts: Turbopuffer::RequestOptions::OrHash).void }
|
17
|
+
def self.validate!(opts)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Idempotency key to send with request and all associated retries. Will only be
|
21
|
+
# sent for write requests.
|
22
|
+
sig { returns(T.nilable(String)) }
|
23
|
+
attr_accessor :idempotency_key
|
24
|
+
|
25
|
+
# Extra query params to send with the request. These are `.merge`’d into any
|
26
|
+
# `query` given at the client level.
|
27
|
+
sig do
|
28
|
+
returns(
|
29
|
+
T.nilable(T::Hash[String, T.nilable(T.any(T::Array[String], String))])
|
30
|
+
)
|
31
|
+
end
|
32
|
+
attr_accessor :extra_query
|
33
|
+
|
34
|
+
# Extra headers to send with the request. These are `.merged`’d into any
|
35
|
+
# `extra_headers` given at the client level.
|
36
|
+
sig { returns(T.nilable(T::Hash[String, T.nilable(String)])) }
|
37
|
+
attr_accessor :extra_headers
|
38
|
+
|
39
|
+
# Extra data to send with the request. These are deep merged into any data
|
40
|
+
# generated as part of the normal request.
|
41
|
+
sig { returns(T.nilable(T.anything)) }
|
42
|
+
attr_accessor :extra_body
|
43
|
+
|
44
|
+
# Maximum number of retries to attempt after a failed initial request.
|
45
|
+
sig { returns(T.nilable(Integer)) }
|
46
|
+
attr_accessor :max_retries
|
47
|
+
|
48
|
+
# Request timeout in seconds.
|
49
|
+
sig { returns(T.nilable(Float)) }
|
50
|
+
attr_accessor :timeout
|
51
|
+
|
52
|
+
# Returns a new instance of RequestOptions.
|
53
|
+
sig do
|
54
|
+
params(values: Turbopuffer::Internal::AnyHash).returns(T.attached_class)
|
55
|
+
end
|
56
|
+
def self.new(values = {})
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,304 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Turbopuffer
|
4
|
+
module Resources
|
5
|
+
class Namespaces
|
6
|
+
# Delete namespace.
|
7
|
+
sig do
|
8
|
+
params(
|
9
|
+
namespace: T.nilable(String),
|
10
|
+
request_options: Turbopuffer::RequestOptions::OrHash
|
11
|
+
).returns(Turbopuffer::Models::NamespaceDeleteAllResponse)
|
12
|
+
end
|
13
|
+
def delete_all(
|
14
|
+
# The name of the namespace.
|
15
|
+
namespace: nil,
|
16
|
+
request_options: {}
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Explain a query plan.
|
21
|
+
sig do
|
22
|
+
params(
|
23
|
+
namespace: String,
|
24
|
+
aggregate_by: T::Hash[Symbol, T.anything],
|
25
|
+
consistency:
|
26
|
+
Turbopuffer::NamespaceExplainQueryParams::Consistency::OrHash,
|
27
|
+
distance_metric: Turbopuffer::DistanceMetric::OrSymbol,
|
28
|
+
exclude_attributes: T::Array[String],
|
29
|
+
filters: T.anything,
|
30
|
+
group_by: T::Array[String],
|
31
|
+
include_attributes: Turbopuffer::IncludeAttributes::Variants,
|
32
|
+
rank_by: T.anything,
|
33
|
+
top_k: Integer,
|
34
|
+
vector_encoding: Turbopuffer::VectorEncoding::OrSymbol,
|
35
|
+
request_options: Turbopuffer::RequestOptions::OrHash
|
36
|
+
).returns(Turbopuffer::Models::NamespaceExplainQueryResponse)
|
37
|
+
end
|
38
|
+
def explain_query(
|
39
|
+
# Path param: The name of the namespace.
|
40
|
+
namespace: nil,
|
41
|
+
# Body param: Aggregations to compute over all documents in the namespace that
|
42
|
+
# match the filters.
|
43
|
+
aggregate_by: nil,
|
44
|
+
# Body param: The consistency level for a query.
|
45
|
+
consistency: nil,
|
46
|
+
# Body param: A function used to calculate vector similarity.
|
47
|
+
distance_metric: nil,
|
48
|
+
# Body param: List of attribute names to exclude from the response. All other
|
49
|
+
# attributes will be included in the response.
|
50
|
+
exclude_attributes: nil,
|
51
|
+
# Body param: Exact filters for attributes to refine search results for. Think of
|
52
|
+
# it as a SQL WHERE clause.
|
53
|
+
filters: nil,
|
54
|
+
# Body param: Groups documents by the specified attributes (the "group key")
|
55
|
+
# before computing aggregates. Aggregates are computed separately for each group.
|
56
|
+
group_by: nil,
|
57
|
+
# Body param: Whether to include attributes in the response.
|
58
|
+
include_attributes: nil,
|
59
|
+
# Body param: How to rank the documents in the namespace.
|
60
|
+
rank_by: nil,
|
61
|
+
# Body param: The number of results to return.
|
62
|
+
top_k: nil,
|
63
|
+
# Body param: The encoding to use for vectors in the response.
|
64
|
+
vector_encoding: nil,
|
65
|
+
request_options: {}
|
66
|
+
)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Warm the cache for a namespace.
|
70
|
+
sig do
|
71
|
+
params(
|
72
|
+
namespace: T.nilable(String),
|
73
|
+
request_options: Turbopuffer::RequestOptions::OrHash
|
74
|
+
).returns(Turbopuffer::Models::NamespaceHintCacheWarmResponse)
|
75
|
+
end
|
76
|
+
def hint_cache_warm(
|
77
|
+
# The name of the namespace.
|
78
|
+
namespace: nil,
|
79
|
+
request_options: {}
|
80
|
+
)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Get metadata about a namespace.
|
84
|
+
sig do
|
85
|
+
params(
|
86
|
+
namespace: String,
|
87
|
+
request_options: Turbopuffer::RequestOptions::OrHash
|
88
|
+
).returns(Turbopuffer::NamespaceMetadata)
|
89
|
+
end
|
90
|
+
def metadata(
|
91
|
+
# The name of the namespace.
|
92
|
+
namespace: nil,
|
93
|
+
request_options: {}
|
94
|
+
)
|
95
|
+
end
|
96
|
+
|
97
|
+
# Issue multiple concurrent queries filter or search documents.
|
98
|
+
sig do
|
99
|
+
params(
|
100
|
+
queries: T::Array[Turbopuffer::Query::OrHash],
|
101
|
+
namespace: String,
|
102
|
+
consistency:
|
103
|
+
Turbopuffer::NamespaceMultiQueryParams::Consistency::OrHash,
|
104
|
+
vector_encoding: Turbopuffer::VectorEncoding::OrSymbol,
|
105
|
+
request_options: Turbopuffer::RequestOptions::OrHash
|
106
|
+
).returns(Turbopuffer::Models::NamespaceMultiQueryResponse)
|
107
|
+
end
|
108
|
+
def multi_query(
|
109
|
+
# Body param:
|
110
|
+
queries:,
|
111
|
+
# Path param: The name of the namespace.
|
112
|
+
namespace: nil,
|
113
|
+
# Body param: The consistency level for a query.
|
114
|
+
consistency: nil,
|
115
|
+
# Body param: The encoding to use for vectors in the response.
|
116
|
+
vector_encoding: nil,
|
117
|
+
request_options: {}
|
118
|
+
)
|
119
|
+
end
|
120
|
+
|
121
|
+
# Query, filter, full-text search and vector search documents.
|
122
|
+
sig do
|
123
|
+
params(
|
124
|
+
namespace: T.nilable(String),
|
125
|
+
aggregate_by: T::Hash[Symbol, T.anything],
|
126
|
+
consistency: Turbopuffer::NamespaceQueryParams::Consistency::OrHash,
|
127
|
+
distance_metric: Turbopuffer::DistanceMetric::OrSymbol,
|
128
|
+
exclude_attributes: T::Array[String],
|
129
|
+
filters: T.anything,
|
130
|
+
group_by: T::Array[String],
|
131
|
+
include_attributes: Turbopuffer::IncludeAttributes::Variants,
|
132
|
+
rank_by: T.anything,
|
133
|
+
top_k: Integer,
|
134
|
+
vector_encoding: Turbopuffer::VectorEncoding::OrSymbol,
|
135
|
+
request_options: Turbopuffer::RequestOptions::OrHash
|
136
|
+
).returns(Turbopuffer::Models::NamespaceQueryResponse)
|
137
|
+
end
|
138
|
+
def query(
|
139
|
+
# Path param: The name of the namespace.
|
140
|
+
namespace: nil,
|
141
|
+
# Body param: Aggregations to compute over all documents in the namespace that
|
142
|
+
# match the filters.
|
143
|
+
aggregate_by: nil,
|
144
|
+
# Body param: The consistency level for a query.
|
145
|
+
consistency: nil,
|
146
|
+
# Body param: A function used to calculate vector similarity.
|
147
|
+
distance_metric: nil,
|
148
|
+
# Body param: List of attribute names to exclude from the response. All other
|
149
|
+
# attributes will be included in the response.
|
150
|
+
exclude_attributes: nil,
|
151
|
+
# Body param: Exact filters for attributes to refine search results for. Think of
|
152
|
+
# it as a SQL WHERE clause.
|
153
|
+
filters: nil,
|
154
|
+
# Body param: Groups documents by the specified attributes (the "group key")
|
155
|
+
# before computing aggregates. Aggregates are computed separately for each group.
|
156
|
+
group_by: nil,
|
157
|
+
# Body param: Whether to include attributes in the response.
|
158
|
+
include_attributes: nil,
|
159
|
+
# Body param: How to rank the documents in the namespace.
|
160
|
+
rank_by: nil,
|
161
|
+
# Body param: The number of results to return.
|
162
|
+
top_k: nil,
|
163
|
+
# Body param: The encoding to use for vectors in the response.
|
164
|
+
vector_encoding: nil,
|
165
|
+
request_options: {}
|
166
|
+
)
|
167
|
+
end
|
168
|
+
|
169
|
+
# Evaluate recall.
|
170
|
+
sig do
|
171
|
+
params(
|
172
|
+
namespace: T.nilable(String),
|
173
|
+
filters: T.anything,
|
174
|
+
include_ground_truth: T::Boolean,
|
175
|
+
num: Integer,
|
176
|
+
queries: T::Array[Float],
|
177
|
+
top_k: Integer,
|
178
|
+
request_options: Turbopuffer::RequestOptions::OrHash
|
179
|
+
).returns(Turbopuffer::Models::NamespaceRecallResponse)
|
180
|
+
end
|
181
|
+
def recall(
|
182
|
+
# Path param: The name of the namespace.
|
183
|
+
namespace: nil,
|
184
|
+
# Body param: Filter by attributes. Same syntax as the query endpoint.
|
185
|
+
filters: nil,
|
186
|
+
# Body param: Include ground truth data (query vectors and true nearest neighbors)
|
187
|
+
# in the response.
|
188
|
+
include_ground_truth: nil,
|
189
|
+
# Body param: The number of searches to run.
|
190
|
+
num: nil,
|
191
|
+
# Body param: Use specific query vectors for the measurement. If omitted, sampled
|
192
|
+
# from the index.
|
193
|
+
queries: nil,
|
194
|
+
# Body param: Search for `top_k` nearest neighbors.
|
195
|
+
top_k: nil,
|
196
|
+
request_options: {}
|
197
|
+
)
|
198
|
+
end
|
199
|
+
|
200
|
+
# Get namespace schema.
|
201
|
+
sig do
|
202
|
+
params(
|
203
|
+
namespace: T.nilable(String),
|
204
|
+
request_options: Turbopuffer::RequestOptions::OrHash
|
205
|
+
).returns(T::Hash[Symbol, Turbopuffer::AttributeSchemaConfig])
|
206
|
+
end
|
207
|
+
def schema(
|
208
|
+
# The name of the namespace.
|
209
|
+
namespace: nil,
|
210
|
+
request_options: {}
|
211
|
+
)
|
212
|
+
end
|
213
|
+
|
214
|
+
# Update namespace schema.
|
215
|
+
sig do
|
216
|
+
params(
|
217
|
+
namespace: T.nilable(String),
|
218
|
+
schema:
|
219
|
+
T::Hash[
|
220
|
+
Symbol,
|
221
|
+
T.any(String, Turbopuffer::AttributeSchemaConfig::OrHash)
|
222
|
+
],
|
223
|
+
request_options: Turbopuffer::RequestOptions::OrHash
|
224
|
+
).returns(T::Hash[Symbol, Turbopuffer::AttributeSchemaConfig])
|
225
|
+
end
|
226
|
+
def update_schema(
|
227
|
+
# Path param: The name of the namespace.
|
228
|
+
namespace: nil,
|
229
|
+
# Body param: The desired schema for the namespace.
|
230
|
+
schema: nil,
|
231
|
+
request_options: {}
|
232
|
+
)
|
233
|
+
end
|
234
|
+
|
235
|
+
# Create, update, or delete documents.
|
236
|
+
sig do
|
237
|
+
params(
|
238
|
+
namespace: T.nilable(String),
|
239
|
+
copy_from_namespace: String,
|
240
|
+
delete_by_filter: T.anything,
|
241
|
+
delete_condition: T.anything,
|
242
|
+
deletes: T::Array[Turbopuffer::ID::Variants],
|
243
|
+
distance_metric: Turbopuffer::DistanceMetric::OrSymbol,
|
244
|
+
encryption: Turbopuffer::NamespaceWriteParams::Encryption::OrHash,
|
245
|
+
patch_columns: Turbopuffer::Columns::OrHash,
|
246
|
+
patch_condition: T.anything,
|
247
|
+
patch_rows: T::Array[Turbopuffer::Row::OrHash],
|
248
|
+
schema:
|
249
|
+
T::Hash[
|
250
|
+
Symbol,
|
251
|
+
T.any(String, Turbopuffer::AttributeSchemaConfig::OrHash)
|
252
|
+
],
|
253
|
+
upsert_columns: Turbopuffer::Columns::OrHash,
|
254
|
+
upsert_condition: T.anything,
|
255
|
+
upsert_rows: T::Array[Turbopuffer::Row::OrHash],
|
256
|
+
request_options: Turbopuffer::RequestOptions::OrHash
|
257
|
+
).returns(Turbopuffer::Models::NamespaceWriteResponse)
|
258
|
+
end
|
259
|
+
def write(
|
260
|
+
# Path param: The name of the namespace.
|
261
|
+
namespace: nil,
|
262
|
+
# Body param: The namespace to copy documents from.
|
263
|
+
copy_from_namespace: nil,
|
264
|
+
# Body param: The filter specifying which documents to delete.
|
265
|
+
delete_by_filter: nil,
|
266
|
+
# Body param: A condition evaluated against the current value of each document
|
267
|
+
# targeted by a delete write. Only documents that pass the condition are deleted.
|
268
|
+
delete_condition: nil,
|
269
|
+
# Body param:
|
270
|
+
deletes: nil,
|
271
|
+
# Body param: A function used to calculate vector similarity.
|
272
|
+
distance_metric: nil,
|
273
|
+
# Body param: The encryption configuration for a namespace.
|
274
|
+
encryption: nil,
|
275
|
+
# Body param: A list of documents in columnar format. Each key is a column name,
|
276
|
+
# mapped to an array of values for that column.
|
277
|
+
patch_columns: nil,
|
278
|
+
# Body param: A condition evaluated against the current value of each document
|
279
|
+
# targeted by a patch write. Only documents that pass the condition are patched.
|
280
|
+
patch_condition: nil,
|
281
|
+
# Body param:
|
282
|
+
patch_rows: nil,
|
283
|
+
# Body param: The schema of the attributes attached to the documents.
|
284
|
+
schema: nil,
|
285
|
+
# Body param: A list of documents in columnar format. Each key is a column name,
|
286
|
+
# mapped to an array of values for that column.
|
287
|
+
upsert_columns: nil,
|
288
|
+
# Body param: A condition evaluated against the current value of each document
|
289
|
+
# targeted by an upsert write. Only documents that pass the condition are
|
290
|
+
# upserted.
|
291
|
+
upsert_condition: nil,
|
292
|
+
# Body param:
|
293
|
+
upsert_rows: nil,
|
294
|
+
request_options: {}
|
295
|
+
)
|
296
|
+
end
|
297
|
+
|
298
|
+
# @api private
|
299
|
+
sig { params(client: Turbopuffer::Client).returns(T.attached_class) }
|
300
|
+
def self.new(client:)
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
304
|
+
end
|