2 unstable releases
Uses new Rust 2024
| new 0.16.0 | Mar 4, 2026 |
|---|---|
| 0.15.0 | Mar 4, 2026 |
#6 in #pgvector
Used in daimon
50KB
881 lines
daimon-plugin-pgvector
A pgvector-backed VectorStore plugin for
the Daimon AI agent framework.
This crate provides PgVectorStore, which stores document embeddings
in PostgreSQL using the pgvector
extension. It supports cosine, L2, and inner-product distance metrics
with HNSW indexing.
Quick Start
use daimon_plugin_pgvector::{PgVectorStoreBuilder, DistanceMetric};
use daimon::retriever::SimpleKnowledgeBase;
use std::sync::Arc;
let store = PgVectorStoreBuilder::new("postgresql://user:pass@localhost/db", 1536)
.table("my_docs")
.distance_metric(DistanceMetric::Cosine)
.build()
.await?;
// Compose with an embedding model for a full RAG pipeline:
let kb = SimpleKnowledgeBase::new(embedding_model, store);
Manual Schema Setup
If you prefer to manage migrations yourself, disable auto-migration
and use the SQL from migrations:
let store = PgVectorStoreBuilder::new(conn_str, 1536)
.auto_migrate(false)
.build()
.await?;
Then run the SQL from migrations::CREATE_EXTENSION,
migrations::create_table_sql, and migrations::create_hnsw_index_sql
against your database.
Dependencies
~12–27MB
~287K SLoC