mirror of
https://github.com/asg017/sqlite-vec.git
synced 2026-04-25 00:36:56 +02:00
docs
This commit is contained in:
parent
4febdff11a
commit
356f75cca7
17 changed files with 350 additions and 166 deletions
|
|
@ -1,9 +1,37 @@
|
|||
# Using `sqlite-vec` in Ruby
|
||||
|
||||
https://rubygems.org/gems/sqlite-vec
|
||||

|
||||
|
||||
Ruby developers can use `sqlite-vec` with the [`sqlite-vec` Gem](https://rubygems.org/gems/sqlite-vec).
|
||||
|
||||
|
||||
```bash
|
||||
gem install sqlite-vec
|
||||
```
|
||||
|
||||
You can then use `SqliteVss.load()` to load `sqlite-vss` SQL functions in a given SQLite connection.
|
||||
|
||||
```ruby
|
||||
require 'sqlite3'
|
||||
require 'sqlite_vec'
|
||||
|
||||
db = SQLite3::Database.new(':memory:')
|
||||
db.enable_load_extension(true)
|
||||
SqliteVec.load(db)
|
||||
db.enable_load_extension(false)
|
||||
|
||||
result = db.execute('SELECT vec_version()')
|
||||
puts result.first.first
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Working with vectors in Ruby
|
||||
|
||||
If your embeddings are provided as a list of numbers, use `.pack("f*")` to convert them into the compact BLOB format that `sqlite-vec` uses.
|
||||
|
||||
```ruby
|
||||
embedding = [0.1, 0.2, 0.3, 0.4]
|
||||
result = db.execute("SELECT vec_length(?)", [query.pack("f*")]])
|
||||
puts result.first.first # 4
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue