turbopuffer-ruby 0.2.0.pre.alpha.2 → 0.2.0.pre.alpha.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb7be5124356c0bcd637642e5f56b96e428889dc4e134a9bc880f868ebc17b24
4
- data.tar.gz: 1309991cd8b0b822fa5fa3d6f67fb8c7790199ffb6101424ee6bfce87f49cf31
3
+ metadata.gz: 1f1fb1336c9388a530172358ada2e2883b25463ae15575216f14711e628f0651
4
+ data.tar.gz: 461943b677f38feb4b327ac315c1ecce8997336992235329402e762baa7070f8
5
5
  SHA512:
6
- metadata.gz: 7dbbc536240fd62400665f437c48c26539e540cfe273616587b69efbeee213aa050ffbf0d3c4e237e026212638a828c3e87d3778ff7b2084af5572ec5d33730a
7
- data.tar.gz: bce84da11da7e137f08860c9c782e9a4648b00b4d41e18eb1e58d643707a7f4c939cc92858aeaa89a41485fc137e9d4675cedd6402e7252a9b901520ecacf757
6
+ metadata.gz: af9ab90abd3318e3578092c4247962f45df06cd06c67cf3ae8690361638dddaa8571096cf080c54c381ea666aeee08eba3029162b35fab45e672cecb5a7edac6
7
+ data.tar.gz: 1dacf25a64e4c91e670e607e3732386c2a3ba043d0671c938918e59301cceda0dc6c3a0309f98714ad9e29db2705226a6c19ee4626c49c45f0152c54d7aef848
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.0-alpha.3 (2025-07-22)
4
+
5
+ Full Changelog: [v0.2.0-alpha.2...v0.2.0-alpha.3](https://github.com/turbopuffer/turbopuffer-ruby/compare/v0.2.0-alpha.2...v0.2.0-alpha.3)
6
+
7
+ ### Bug Fixes
8
+
9
+ * allow modifying Row objects in place ([269929a](https://github.com/turbopuffer/turbopuffer-ruby/commit/269929aace3a3b69a5db972d1382a01080f0c70a))
10
+ * improve the README example ([84793e6](https://github.com/turbopuffer/turbopuffer-ruby/commit/84793e649a8b45d3e7c0826c90899a3b25220190))
11
+ * **internal:** tests should use normalized property names ([a2bfe81](https://github.com/turbopuffer/turbopuffer-ruby/commit/a2bfe81c3149796e0d2fed0e54db8e6deacef03b))
12
+
13
+
14
+ ### Chores
15
+
16
+ * **internal:** version bump ([9ac2013](https://github.com/turbopuffer/turbopuffer-ruby/commit/9ac201321f311c97923ed9c667d88d1b9c4221f0))
17
+
3
18
  ## 0.2.0-alpha.2 (2025-07-21)
4
19
 
5
20
  Full Changelog: [v0.2.0-alpha.1...v0.2.0-alpha.2](https://github.com/turbopuffer/turbopuffer-ruby/compare/v0.2.0-alpha.1...v0.2.0-alpha.2)
data/README.md CHANGED
@@ -17,7 +17,7 @@ To use this gem, install via Bundler by adding the following to your application
17
17
  <!-- x-release-please-start-version -->
18
18
 
19
19
  ```ruby
20
- gem "turbopuffer-ruby", "~> 0.2.0.pre.alpha.2"
20
+ gem "turbopuffer-ruby", "~> 0.2.0.pre.alpha.3"
21
21
  ```
22
22
 
23
23
  <!-- x-release-please-end -->
@@ -27,19 +27,39 @@ gem "turbopuffer-ruby", "~> 0.2.0.pre.alpha.2"
27
27
  ```ruby
28
28
  require "bundler/setup"
29
29
  require "turbopuffer"
30
+ require "json"
30
31
 
31
- turbopuffer = Turbopuffer::Client.new(
32
- api_key: ENV["TURBOPUFFER_API_KEY"] # This is the default and can be omitted
32
+ tpuf = Turbopuffer::Client.new(
33
+ # API tokens are created in the dashboard: https://turbopuffer.com/dashboard
34
+ api_key: ENV["TURBOPUFFER_API_KEY"],
35
+ # Pick the right region: https://turbopuffer.com/docs/regions
36
+ region: "gcp-us-central1",
33
37
  )
34
38
 
35
- response = turbopuffer.namespace("products").write(
36
- distance_metric: "cosine_distance",
37
- upsert_rows: [
38
- {id: "2108ed60-6851-49a0-9016-8325434f3845", vector: [0.1, 0.2], attributes: {name: "Red boots", price: 34.99}}
39
- ]
39
+ ns = tpuf.namespace("example")
40
+
41
+ # Query nearest neighbors with filter
42
+ result = ns.query(
43
+ rank_by: ["vector", "ANN", openai_or_rand_vector("walrus narwhal")],
44
+ top_k: 10,
45
+ filters: ["And", [["name", "Eq", "foo"], ["public", "Eq", 1]]],
46
+ include_attributes: ["name"],
40
47
  )
48
+ puts result.rows
49
+ # {id: 1, "$dist": 0.0, name: "foo"}
50
+
51
+ # Full-text search on an attribute
52
+ # If you want to combine FTS and vector search, see https://turbopuffer.com/docs/hybrid-search
53
+ result = ns.query(
54
+ top_k: 10,
55
+ filters: ["name", "Eq", "foo"],
56
+ rank_by: ["text", "BM25", "quick walrus"],
57
+ )
58
+ puts result.rows
59
+ # {id: 1, "$dist": 0.19856808}
60
+ # {id: 2, "$dist": 0.16853257}
41
61
 
42
- puts(response.rows_affected)
62
+ # See https://turbopuffer.com/docs/quickstart for more.s
43
63
  ```
44
64
 
45
65
  ### Pagination
@@ -213,13 +233,7 @@ You can provide typesafe request parameters like so:
213
233
  ```ruby
214
234
  turbopuffer.namespace("products").write(
215
235
  distance_metric: "cosine_distance",
216
- upsert_rows: [
217
- Turbopuffer::Row.new(
218
- id: "2108ed60-6851-49a0-9016-8325434f3845",
219
- vector: [0.1, 0.2],
220
- attributes: {name: "Red boots", price: 34.99}
221
- )
222
- ]
236
+ upsert_rows: [Turbopuffer::Row.new(id: "2108ed60-6851-49a0-9016-8325434f3845", vector: [0.1, 0.2])]
223
237
  )
224
238
  ```
225
239
 
@@ -237,13 +251,7 @@ turbopuffer.namespace("products").write(
237
251
  # You can also splat a full Params class:
238
252
  params = Turbopuffer::NamespaceWriteParams.new(
239
253
  distance_metric: "cosine_distance",
240
- upsert_rows: [
241
- Turbopuffer::Row.new(
242
- id: "2108ed60-6851-49a0-9016-8325434f3845",
243
- vector: [0.1, 0.2],
244
- attributes: {name: "Red boots", price: 34.99}
245
- )
246
- ]
254
+ upsert_rows: [Turbopuffer::Row.new(id: "2108ed60-6851-49a0-9016-8325434f3845", vector: [0.1, 0.2])]
247
255
  )
248
256
  turbopuffer.namespace("products").write(**params)
249
257
  ```
@@ -33,6 +33,14 @@ module Turbopuffer
33
33
  def respond_to_missing?(name, include_private = false)
34
34
  @data.key?(name) || super
35
35
  end
36
+
37
+ def []=(key, value)
38
+ unless key.instance_of?(Symbol)
39
+ raise ArgumentError.new("Expected symbol key for set, got #{key.inspect}")
40
+ end
41
+
42
+ @data[key] = value
43
+ end
36
44
  end
37
45
  end
38
46
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Turbopuffer
4
- VERSION = "0.2.0.pre.alpha.2"
4
+ VERSION = "0.2.0.pre.alpha.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbopuffer-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.pre.alpha.2
4
+ version: 0.2.0.pre.alpha.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Turbopuffer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-21 00:00:00.000000000 Z
11
+ date: 2025-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool