Skip to main content

Crate graphrt_rag

Crate graphrt_rag 

Source
Expand description

§graphrt-rag

Retrieval building blocks for graphrt workflows and the knowledge-retrieval node.

use std::sync::Arc;
use graphrt_core::{Registry, Services};
use graphrt_rag::{Document, HashEmbedder, KnowledgeBase, MemoryStore};

let kb = KnowledgeBase::new()
    .with_store_dataset("faq", Arc::new(MemoryStore::new()), Arc::new(HashEmbedder::new(256)), None);
kb.ingestor("faq").unwrap().ingest(&Document::new("faq", "returns", "Items can be returned within 30 days.")).await.unwrap();

let mut registry = Registry::with_builtins();
graphrt_rag::register(&mut registry);
let services = Services::new().with(kb);

Structs§

ChunkerConfig
Chunking parameters.
DatasetConfig
One dataset entry.
DatasetInfo
Public description of a dataset.
DocExtractor
Extracts text from any format supported by graphrt-doc.
Document
A document to ingest.
HashEmbedder
Feature-hashing embedder.
Hit
One retrieved chunk with its relevance score (higher is better).
HttpReranker
Reranker for Cohere/Jina/Voyage-compatible APIs.
HttpRerankerConfig
Configuration of a /rerank endpoint (Cohere, Jina, Voyage, vLLM, TEI…).
HttpRetriever
A Retriever that delegates to a remote RAG service.
HttpRetrieverConfig
Configuration of a remote retrieval endpoint.
HttpSettings
Shared HTTP settings.
HybridWeights
How vector and keyword scores are blended.
IngestReport
Outcome of an ingestion.
Ingestor
Chunks, embeds (in batches) and stores documents.
KeywordQuery
Keyword (BM25) query.
KnowledgeBase
Dataset id -> retriever registry.
KnowledgeConfig
Declarative knowledge-base configuration (knowledge.yaml / .json).
KnowledgeRetrievalNode
Retrieves chunks from a KnowledgeBase service.
MemoryStore
In-memory VectorStore with cosine similarity and BM25 keyword search.
MetadataCondition
One metadata condition, e.g. {name: "lang", comparison_operator: "is", value: "en"}.
MetadataFilter
A set of metadata conditions.
OpenAiEmbedder
Embedder for any OpenAI-compatible embeddings API (OpenAI, Azure, Ollama, vLLM, Jina, …).
OpenAiEmbedderConfig
Configuration of an OpenAI-compatible /embeddings endpoint.
PlainTextExtractor
Extractor for UTF-8 text formats (plain text, Markdown, JSON, CSV, HTML as-is).
QdrantConfig
Qdrant connection settings.
QdrantStore
VectorStore backed by Qdrant.
RetrievalRequest
A high-level retrieval request.
Secret
A string that never appears in Debug output.
SqliteStore
VectorStore persisted in one SQLite file, with cosine and BM25 search.
StoreRetriever
A Retriever over a VectorStore + Embedder (+ optional Reranker).
StoredChunk
A chunk as stored in a VectorStore.
TextChunk
One chunk of a document.
UnknownOperator
Error for an unsupported comparison operator.
VectorQuery
Vector similarity query.

Enums§

Logical
How conditions combine.
RagError
Error from an embedder, store, reranker or retriever.

Constants§

KIND
Node kind.

Traits§

Embedder
Turns text into embedding vectors.
Extractor
Turns raw document bytes into text for ingestion (PDF, DOCX, … extractors plug in here).
Reranker
Re-scores documents against a query (cross-encoder style).
Retriever
End-to-end retrieval: query in, ranked hits out. Implement this to plug an external RAG service in place of the built-in store pipeline.
VectorStore
Stores chunks with vectors and answers similarity queries.

Functions§

check_vector
Check that a vector can be stored or searched: non-empty and finite.
chunk_text
Split text into chunks.
content_hash
Stable 64-bit FNV-1a hash rendered as hex.
cosine
Cosine similarity (0 when either vector is zero or lengths differ).
descriptor
Catalog entry for the node.
dot
Dot product written as 8 independent accumulators so the compiler can vectorize it.
finalize
Apply the score threshold, then keep the best top_k.
merge_weighted
Blend vector (cosine, clamped to [0, 1]) and keyword (BM25 divided by the best BM25 score) scores by id: score = wv * vector + wk * keyword, with weights normalized to sum to 1. Missing components count as 0.
register
Register the knowledge-retrieval node.
rerank
Replace scores with reranker scores and re-sort.
tokenize
Lower-cased alphanumeric tokens. CJK characters become one token each so languages without spaces still get a usable keyword index.

Type Aliases§

EnvLookup
Resolves environment variable names to values (std::env::var in production).
Metadata
Free-form chunk / document metadata.