1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//! # daimon-plugin-pgvector
//!
//! A pgvector-backed [`VectorStore`](daimon_core::VectorStore) plugin for
//! the [Daimon](https://docs.rs/daimon) AI agent framework.
//!
//! This crate provides [`PgVectorStore`], which stores document embeddings
//! in PostgreSQL using the [pgvector](https://github.com/pgvector/pgvector)
//! extension. It supports cosine, L2, and inner-product distance metrics
//! with HNSW indexing.
//!
//! ## Quick Start
//!
//! ```ignore
//! 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`]:
//!
//! ```ignore
//! 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.
pub use PgVectorStoreBuilder;
pub use PgVectorStore;
/// Distance metric used for vector similarity search.