Skip to content

Commit

Permalink
Add sqlite vector store
Browse files Browse the repository at this point in the history
  • Loading branch information
tarrencev committed Nov 25, 2024
1 parent 2cba662 commit 4a778a9
Show file tree
Hide file tree
Showing 7 changed files with 635 additions and 14 deletions.
155 changes: 143 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[workspace]
resolver = "2"
members = [
"rig-core", "rig-lancedb",
"rig-mongodb", "rig-neo4j",
"rig-core",
"rig-lancedb",
"rig-mongodb",
"rig-neo4j",
"rig-qdrant",
"rig-sqlite",
]
24 changes: 24 additions & 0 deletions rig-sqlite/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "rig-sqlite"
version = "0.1.0"
edition = "2021"
description = "SQLite-based vector store implementation for the rig framework"
license = "MIT"

[dependencies]
rig-core = { path = "../rig-core" }
rusqlite = { version = "0.32", features = ["bundled"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
sqlite-vec = "0.1"
tokio-rusqlite = { git = "https://github.com/programatik29/tokio-rusqlite", features = [
"bundled",
] }
tracing = "0.1"
zerocopy = "0.8.10"
chrono = "0.4"

[dev-dependencies]
anyhow = "1.0.86"
tokio = { version = "1.38.0", features = ["macros", "rt-multi-thread"] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
7 changes: 7 additions & 0 deletions rig-sqlite/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright (c) 2024, Playgrounds Analytics Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
46 changes: 46 additions & 0 deletions rig-sqlite/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<div style="display: flex; align-items: center; justify-content: center;">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="../img/rig_logo_dark.svg">
<source media="(prefers-color-scheme: light)" srcset="../img/rig_logo.svg">
<img src="../img/rig_logo.svg" width="200" alt="Rig logo">
</picture>
<span style="font-size: 48px; margin: 0 20px; font-weight: regular; font-family: Open Sans, sans-serif;"> + </span>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://www.sqlite.org/images/sqlite370_banner.gif">
<source media="(prefers-color-scheme: light)" srcset="https://www.sqlite.org/images/sqlite370_banner.gif">
<img src="https://www.sqlite.org/images/sqlite370_banner.gif" width="200" alt="SQLite logo">
</picture>
</div>

<br><br>

## Rig-SQLite

This companion crate implements a Rig vector store based on SQLite.

## Usage

Add the companion crate to your `Cargo.toml`, along with the rig-core crate:

```toml
[dependencies]
rig-sqlite = "0.1.3"
rig-core = "0.4.0"
```

You can also run `cargo add rig-sqlite rig-core` to add the most recent versions of the dependencies to your project.

See the [`/examples`](./examples) folder for usage examples.

## Important Note

Before using the SQLite vector store, you must initialize the SQLite vector extension. Add this code before creating your connection:

```rust
use rusqlite::ffi::sqlite3_auto_extension;
use sqlite_vec::sqlite3_vec_init;

unsafe {
sqlite3_auto_extension(Some(std::mem::transmute(sqlite3_vec_init as *const ())));
}
```
Loading

0 comments on commit 4a778a9

Please sign in to comment.