|
| 1 | +# Turbopuffer |
| 2 | + |
| 3 | +A Ruby client for accessing the Turbopuffer API. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +TODO: Replace |
| 8 | +`UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your |
| 9 | +gem name right after releasing it to RubyGems.org. Please do not do it earlier |
| 10 | +due to security reasons. Alternatively, replace this section with instructions |
| 11 | +to install your gem from git if you don't plan to release to RubyGems.org. |
| 12 | + |
| 13 | +Install the gem and add to the application's Gemfile by executing: |
| 14 | + |
| 15 | +```bash |
| 16 | +bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG |
| 17 | +``` |
| 18 | + |
| 19 | +If bundler is not being used to manage dependencies, install the gem by |
| 20 | +executing: |
| 21 | + |
| 22 | +```bash |
| 23 | +gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG |
| 24 | +``` |
| 25 | + |
| 26 | +## Usage |
| 27 | + |
| 28 | +```ruby |
| 29 | +tpuf = Turbopuffer::Client.new("your-token") |
| 30 | + |
| 31 | +ns = tpuf.namespace("namespace-name") |
| 32 | + |
| 33 | +ns.upsert( |
| 34 | + ids: [1, 2], |
| 35 | + vectors: [[0.1, 0.2], [0.3, 0.4]], |
| 36 | + attributes: {name: ["foo", "bar"]} |
| 37 | +) |
| 38 | + |
| 39 | +results = ns.query( |
| 40 | + vector: [0.15, 0.22], |
| 41 | + top_k: 10 |
| 42 | +) |
| 43 | + |
| 44 | +ns.delete_all |
| 45 | +``` |
| 46 | + |
| 47 | +## Development |
| 48 | + |
| 49 | +After checking out the repo, run `bin/setup` to install dependencies. Then, run |
| 50 | +`rake test` to run the tests. You can also run `bin/console` for an interactive |
| 51 | +prompt that will allow you to experiment. |
| 52 | + |
| 53 | +To install this gem onto your local machine, run `bundle exec rake install`. To |
| 54 | +release a new version, update the version number in `version.rb`, and then run |
| 55 | +`bundle exec rake release`, which will create a git tag for the version, push |
| 56 | +git commits and the created tag, and push the `.gem` file to |
| 57 | +[rubygems.org](https://rubygems.org). |
| 58 | + |
| 59 | +## Contributing |
| 60 | + |
| 61 | +Bug reports and pull requests are welcome on GitHub at |
| 62 | +https://github.com/xymbol/turbopuffer-ruby. |
| 63 | + |
| 64 | +## License |
| 65 | + |
| 66 | +The gem is available as open source under the terms of the [MIT |
| 67 | +License](https://opensource.org/licenses/MIT). |
0 commit comments