Expand description
SpireAI — High-level AI SDK for SpireDB.
Build RAG pipelines, semantic code search, and agent memory on top of SpireDB with minimal boilerplate.
§Quick Start
use spire_ai::prelude::*;
#[derive(Doc, Serialize, Deserialize, Clone)]
struct Article {
#[id]
slug: String,
title: String,
content: String,
}
#[tokio::main]
async fn main() -> spire_ai::Result<()> {
let spire = Spire::connect("http://127.0.0.1:50051").await?;
let articles = spire.collection::<Article>("articles");
articles.ensure().await?;
articles.insert(&Article {
slug: "hello".into(),
title: "Hello World".into(),
content: "An introduction to SpireAI.".into(),
}).await?;
let hits = articles.search("introduction").run().await?;
for hit in hits {
println!("{}: {}", hit.score, hit.doc.title);
}
Ok(())
}Re-exports§
pub use client::Spire;pub use client::SpireBuilder;pub use collection::Collection;pub use document::Doc;pub use error::Error;pub use error::Result;pub use filecache::FileCache;pub use search::Filter;pub use search::Hit;pub use search::Search;pub use types::IndexResult;pub use types::IngestResult;pub use watch::Change;pub use watch::WatchStream;
Modules§
- agent
- Agent memory for AI agents.
- client
- Spire client and builder.
- code
- Code indexing and semantic search.
- collection
- Typed document collections with automatic embedding and vector search.
- document
- The
Doctrait for documents stored in spire-ai collections. - embedding
- Embedding providers for spire-ai.
- error
- Error types for spire-ai.
- filecache
- File cache — tracks file content changes via hashing.
- llm
- LLM providers for spire-ai.
- prelude
- Prelude — import everything you need with
use spire_ai::prelude::*. - rag
- RAG (Retrieval-Augmented Generation) pipeline.
- search
- Search and filter builders for collections.
- tool
- Tool trait and registry for agent tool-calling.
- types
- Shared types for spire-ai.
- watch
- CDC-based change watching for collections.
Derive Macros§
- Doc
- Derive the
Doctrait for a struct.