Skip to main content

synaptic_sqlite/
lib.rs

1//! SQLite integration for the Synaptic framework.
2//!
3//! This crate provides:
4//! - [`SqliteCache`]: A SQLite-backed implementation of the [`LlmCache`](synaptic_core::LlmCache)
5//!   trait for caching LLM responses with optional TTL expiration.
6//! - [`SqliteCheckpointer`]: A SQLite-backed implementation of the
7//!   [`Checkpointer`](synaptic_graph::Checkpointer) trait for persisting graph
8//!   state between executions.
9//! - [`SqliteStore`]: A SQLite-backed implementation of the [`Store`](synaptic_core::Store)
10//!   trait with FTS5 full-text search.
11//! - [`SqliteVectorStore`]: A SQLite-backed implementation of the
12//!   [`VectorStore`](synaptic_core::VectorStore) trait with FTS5 hybrid search.
13//!
14//! # Quick start
15//!
16//! ```rust,no_run
17//! use synaptic_sqlite::{SqliteCache, SqliteCacheConfig};
18//!
19//! # fn example() -> Result<(), Box<dyn std::error::Error>> {
20//! // In-memory cache (great for testing)
21//! let cache = SqliteCache::new(SqliteCacheConfig::in_memory())?;
22//!
23//! // File-based cache with 1-hour TTL
24//! let config = SqliteCacheConfig::new("/tmp/llm_cache.db").with_ttl(3600);
25//! let cache = SqliteCache::new(config)?;
26//! # Ok(())
27//! # }
28//! ```
29
30mod cache;
31pub mod checkpointer;
32mod store;
33mod vectorstore;
34
35pub use cache::{SqliteCache, SqliteCacheConfig};
36pub use checkpointer::SqliteCheckpointer;
37pub use store::{SqliteStore, SqliteStoreConfig};
38pub use vectorstore::{SqliteVectorStore, SqliteVectorStoreConfig};
39
40// Re-export core traits for convenience.
41pub use synaptic_core::{ChatResponse, Document, Embeddings, Item, LlmCache, Store, VectorStore};
42pub use synaptic_graph::Checkpointer;