Skip to main content

Crate daimon_plugin_pgvector

Crate daimon_plugin_pgvector 

Source
Expand description

§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.

Modules§

migrations
SQL migration strings for manual schema setup.

Structs§

PgVectorStore
A VectorStore backed by PostgreSQL with the pgvector extension.
PgVectorStoreBuilder
Builds a PgVectorStore with connection pooling and optional auto-migration.

Enums§

DistanceMetric
Distance metric used for vector similarity search.