Skip to main content

synaptic_pgvector/
lib.rs

1//! PostgreSQL + pgvector integration for the Synaptic framework.
2//!
3//! This crate provides [`PgVectorStore`], an implementation of the
4//! [`VectorStore`](synaptic_core::VectorStore) trait backed by PostgreSQL with
5//! the [pgvector](https://github.com/pgvector/pgvector) extension. It stores
6//! document content, metadata (as JSONB), and embedding vectors in a single
7//! table, using cosine distance (`<=>`) for similarity search.
8//!
9//! # Quick start
10//!
11//! ```rust,no_run
12//! use sqlx::postgres::PgPoolOptions;
13//! use synaptic_pgvector::{PgVectorConfig, PgVectorStore};
14//!
15//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
16//! let pool = PgPoolOptions::new()
17//!     .max_connections(5)
18//!     .connect("postgres://user:pass@localhost/mydb")
19//!     .await?;
20//!
21//! let config = PgVectorConfig::new("documents", 1536);
22//! let store = PgVectorStore::new(pool, config);
23//! store.initialize().await?;
24//! # Ok(())
25//! # }
26//! ```
27
28mod vector_store;
29
30pub use vector_store::{PgVectorConfig, PgVectorStore};
31
32// Re-export core traits/types for convenience.
33pub use synaptic_core::{Document, Embeddings, VectorStore};