ractogateway.rag
RactoGateway RAG — production-grade Retrieval-Augmented Generation.
Quick start:
from ractogateway.rag.pipeline import RactoRAG
from ractogateway.rag.embedders.openai_embedder import OpenAIEmbedder
from ractogateway.rag.stores.chroma_store import ChromaStore
rag = RactoRAG(
vector_store=ChromaStore(collection="my_docs"),
embedder=OpenAIEmbedder(),
llm_kit=my_kit,
)
rag.ingest("docs/report.pdf")
response = rag.query("What was the Q3 revenue?")
Components
Readers:
ractogateway.rag.readersChunkers:
ractogateway.rag.chunkersProcessors:
ractogateway.rag.processorsEmbedders:
ractogateway.rag.embeddersStores:
ractogateway.rag.storesPipeline:
RactoRAG
- class ractogateway.rag.RactoRAG(vector_store=None, embedder=None, *, store=None, chunker=None, processors=None, llm_kit=None, context_template=None, reader_registry=None, default_prompt=None)[source]
Bases:
objectProduction-grade RAG pipeline for RactoGateway.
- Parameters:
vector_store (
BaseVectorStore|None) – AnyBaseVectorStoreinstance.embedder (
BaseEmbedder|None) – AnyBaseEmbedderinstance.chunker (
BaseChunker|None) – How to split documents. Defaults toRecursiveChunkerwithchunk_size=512, overlap=50.processors (
list[BaseProcessor] |None) – List of text processors applied to each chunk before embedding. Defaults to[TextCleaner()].llm_kit (
Any|None) – Any developer kit (OpenAIDeveloperKit,GoogleDeveloperKit, orAnthropicDeveloperKit). Required forquery()/aquery().context_template (
str|None) – Template string for injecting retrieved context into the LLM prompt. Must contain{context}and{question}placeholders.reader_registry (
FileReaderRegistry|None) – CustomFileReaderRegistry. Defaults to a registry with all built-in readers.default_prompt (
RactoPrompt|None) – RACTO prompt used for generation. Falls back to a built-in RAG prompt.
- ingest(path, **metadata)[source]
Read, chunk, embed, and store a single file.
- ingest_dir(directory, pattern='**/*', **metadata)[source]
Recursively ingest all supported files in a directory.
- ingest_text(text, source='manual', **metadata)[source]
Ingest a raw text string directly (no file needed).
- async aingest_dir(directory, pattern='**/*', **metadata)[source]
Async variant of
ingest_dir().
- async aingest_text(text, source='manual', **metadata)[source]
Async variant of
ingest_text().
- retrieve(query, top_k=5, filters=None)[source]
Embed query and retrieve the top-k most relevant chunks.
- Parameters:
- Return type:
- Returns:
list[RetrievalResult] – Ranked results (rank 1 = most relevant).
- async aretrieve(query, top_k=5, filters=None)[source]
Async variant of
retrieve().- Return type:
- query(question, top_k=5, filters=None, prompt=None, temperature=0.0, max_tokens=2048)[source]
Retrieve relevant chunks and generate an answer.
- Parameters:
question (
str) – The user’s question.top_k (
int) – Number of context chunks to retrieve.filters (
dict[str,Any] |None) – Optional metadata filters for retrieval.prompt (
RactoPrompt|None) – Override the default RACTO prompt for generation.temperature (
float) – LLM temperature (default0.0for factual answers).max_tokens (
int) – Maximum tokens in the generated answer.
- Return type:
- Returns:
RAGResponse – Contains the generated answer plus the retrieved source chunks.
- Raises:
RuntimeError – If no
llm_kitwas provided.
- async aquery(question, top_k=5, filters=None, prompt=None, temperature=0.0, max_tokens=2048)[source]
Async variant of
query().- Return type:
- property store: BaseVectorStore
The underlying vector store.
- property embedder: BaseEmbedder
The underlying embedder.
- class ractogateway.rag.PageIndexRAG(llm_kit=None, *, processors=None, reader_registry=None, context_template="Use the following retrieved page excerpts to answer the user's question.\\nIf the excerpts do not contain enough information, say so clearly.\\n\\n--- CONTEXT ---\\n{context}\\n--- END CONTEXT ---\\n\\nQuestion: {question}", default_prompt=None, page_size=1000, page_overlap=100, k1=1.5, b=0.75, top_keywords=20, ocr_backend=None, ocr_fallback=True, min_ocr_confidence=0.0)[source]
Bases:
objectVectorless RAG pipeline that indexes documents at the page level.
- Parameters:
llm_kit (
Any) – Any RactoGateway developer kit (OpenAI, Anthropic, Google, Ollama, HuggingFace). Required only forquery()/aquery(). PassNoneto use the pipeline in retrieve-only mode.processors (
Sequence[BaseProcessor] |None) – Text processors applied to each page before indexing. Defaults to[TextCleaner()].reader_registry (
FileReaderRegistry|None) – File reader registry used to load non-PDF documents. Defaults to aFileReaderRegistrywith all built-in readers registered.context_template (
str) – Jinja-style template with{context}and{question}placeholders used when building the LLM prompt.default_prompt (
RactoPrompt|None) –RactoPromptused for generation. Defaults to a built-in factual Q&A prompt.page_size (
int) – Maximum character length of each page window for non-PDF files (default 1 000).page_overlap (
int) – Character overlap between consecutive windows (default 100).k1 (
float) – BM25 term-frequency saturation parameter (default 1.5).b (
float) – BM25 length-normalisation parameter (default 0.75).top_keywords (
int) – Number of top TF-weighted keywords to extract per page for the decision index (default 20).
- retrieve(query, top_k=5)[source]
Retrieve the most relevant pages for query.
Uses two-stage retrieval: decision index (candidate selection) → BM25 scoring (ranking).
- Parameters:
- Return type:
- Returns:
list[PageIndexResult] – Pages ranked by BM25 score (most relevant first).
- async aretrieve(query, top_k=5)[source]
Async variant of
retrieve().- Return type:
- ingest(path, **metadata)[source]
Read a file and add its pages to the index.
PDFs are split page-by-page; all other file types are split into fixed-size character windows.
- ingest_text(text, source='manual', **metadata)[source]
Index raw text directly (no file I/O).
- async aingest_text(text, source='manual', **metadata)[source]
Async variant of
ingest_text().
- ingest_dir(directory, pattern='**/*', *, on_progress=None, **metadata)[source]
Ingest all files matching pattern inside directory.
Files that cannot be read are logged and skipped; the rest are indexed normally.
- Parameters:
directory (
str) – Root directory to search.pattern (
str) – Glob pattern relative to directory (default"**/*").on_progress (
Callable[[int,int],None] |None) – Optional callback(done, total) -> Nonecalled after each file is processed (or skipped). Useful for progress bars.**metadata (
Any) – Forwarded to everyingest()call.
- Return type:
- async aingest_dir(directory, pattern='**/*', *, max_concurrent=4, on_progress=None, **metadata)[source]
Async parallel variant of
ingest_dir().- Parameters:
directory (
str) – Root directory to search.pattern (
str) – Glob pattern relative to directory (default"**/*").max_concurrent (
int) – Maximum number of files ingested concurrently (default 4).on_progress (
Callable[[int,int],None] |None) – Optional callback(done, total) -> Nonecalled after each file finishes (thread-safe; called from the event loop).**metadata (
Any) – Forwarded to everyaingest()call.
- Return type:
- add_texts(texts, source='manual', **metadata)[source]
Ingest a list of text strings.
- search(query, *, top_k=5, prompt=None, temperature=0.0, max_tokens=2048)[source]
Alias for
query().- Return type:
- query(question, *, top_k=5, prompt=None, temperature=0.0, max_tokens=2048)[source]
Retrieve relevant pages and generate an answer with the LLM kit.
- Parameters:
- Return type:
- Returns:
PageIndexResponse – Contains the generated answer, ranked sources, and the context string that was supplied to the model.
- Raises:
ValueError – If no
llm_kitwas provided and generation is requested.
- async aquery(question, *, top_k=5, prompt=None, temperature=0.0, max_tokens=2048)[source]
Async variant of
query().- Return type:
- remove_document(doc_id)[source]
Remove all pages belonging to doc_id from the index.
- save(path)[source]
Serialise the full index to a JSON file.
The saved file contains all
PageEntryrecords, BM25 term weights, and deduplication hashes. Reload withload().
- classmethod load(path, **kwargs)[source]
Load a previously saved index from path.
- Parameters:
- Return type:
- Returns:
PageIndexRAG – A new instance with the index fully restored.
- property entry_count: int
Total number of indexed page entries.
- property document_count: int
Number of distinct documents ingested.
- class ractogateway.rag.PageEntry(**data)[source]
Bases:
BaseModelA single page (or fixed-size window) extracted from a document.
Produced by
PageIndexRAGduring ingestion and stored in the in-process index.Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- entry_id: str
- content: str
- source: str
- doc_id: str
- char_count: int
- ocr_applied: bool
- property text: str
Alias for content.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ractogateway.rag.PageIndexResult(**data)[source]
Bases:
BaseModelA single retrieved page together with its BM25 relevance score.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- entry: PageEntry
- score: float
- rank: int
- property content: str
Alias for entry.content.
- property text: str
Alias for entry.content.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ractogateway.rag.PageIndexResponse(**data)[source]
Bases:
BaseModelFull response from
PageIndexRAG.query()/PageIndexRAG.aquery().Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- answer: LLMResponse | None
- sources: list[PageIndexResult]
- query: str
- context_used: str
- property results: list[PageIndexResult]
Alias for sources.
- property pages: list[PageIndexResult]
Alias for sources.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ractogateway.rag.Chunk(**data)[source]
Bases:
BaseModelA single embeddable slice of a document.
Produced by a
BaseChunkerand enriched with an embedding vector by aBaseEmbedder.Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- chunk_id: str
- doc_id: str
- content: str
- metadata: ChunkMetadata
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ractogateway.rag.ChunkMetadata(**data)[source]
Bases:
BaseModelProvenance and positional data attached to every chunk.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- source: str
- chunk_index: int
- total_chunks: int
- start_char: int
- end_char: int
- doc_id: str
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ractogateway.rag.Document(**data)[source]
Bases:
BaseModelA raw document loaded from a file or supplied as plain text.
- Parameters:
content (str) – The full extracted text of the document.
source (str) – Absolute file path, URL, or a descriptive label (e.g.
"manual").metadata (dict[str, Any]) – Free-form key/value pairs (file size, author, MIME type, …).
doc_id (str) – Auto-generated UUID; override only when you need stable IDs.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- doc_id: str
- content: str
- source: str
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ractogateway.rag.RAGResponse(**data)[source]
Bases:
BaseModelCombined output from a RAG query (retrieval + generation).
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- answer: LLMResponse
- sources: list[RetrievalResult]
- query: str
- context_used: str
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ractogateway.rag.RetrievalConfig(**data)[source]
Bases:
BaseModelInput parameters for a vector-store search.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- query: str
- top_k: int
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ractogateway.rag.RetrievalResult(**data)[source]
Bases:
BaseModelA single retrieved chunk together with its relevance score.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- chunk: Chunk
- score: float
- rank: int
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ractogateway.rag.FixedChunker(chunk_size=512, overlap=50)[source]
Bases:
BaseChunkerSplit text into fixed-size character windows with overlap.
- Parameters:
- class ractogateway.rag.RecursiveChunker(chunk_size=512, overlap=50, separators=None)[source]
Bases:
BaseChunkerSplit text recursively using a priority list of separators.
- Parameters:
- class ractogateway.rag.SemanticChunker(embedder, threshold=0.5, min_chunk_size=2, language='english')[source]
Bases:
BaseChunkerSplit documents where the semantic similarity between adjacent sentences drops below a threshold.
- Parameters:
embedder (
BaseEmbedder) – AnyBaseEmbedderinstance.threshold (
float) – Cosine similarity below which a split is inserted (default:0.5).min_chunk_size (
int) – Minimum number of sentences per chunk (prevents ultra-fine splits).language (
str) – NLTK sentence tokenizer language.
- class ractogateway.rag.SentenceChunker(sentences_per_chunk=5, overlap_sentences=1, language='english')[source]
Bases:
BaseChunkerSplit text into groups of sentences using NLTK.
- Parameters:
- class ractogateway.rag.GoogleEmbedder(model='text-embedding-004', *, api_key=None, task_type=None, batch_size=100)[source]
Bases:
BaseEmbedderEmbed texts using the Google Gemini Embeddings API.
- Parameters:
model (
str) – Gemini embedding model (default"text-embedding-004").api_key (
str|None) – Gemini API key. Falls back toGEMINI_API_KEYenv var.task_type (
str|None) – Gemini task type hint (e.g."RETRIEVAL_DOCUMENT","RETRIEVAL_QUERY").Nonelets the API decide.batch_size (
int) – Maximum number of texts per API call.
- property dimension: int
Dimensionality of the embedding vectors.
Returns
-1if not known until after the first call.
- embed(texts)[source]
Embed texts synchronously.
- class ractogateway.rag.OpenAIEmbedder(model='text-embedding-3-small', *, api_key=None, base_url=None, dimensions=None, batch_size=256)[source]
Bases:
BaseEmbedderEmbed texts using the OpenAI Embeddings API.
- Parameters:
model (
str) – OpenAI embedding model (default"text-embedding-3-small").api_key (
str|None) – OpenAI API key. Falls back toOPENAI_API_KEYenv var.base_url (
str|None) – Custom base URL (Azure OpenAI or proxy).dimensions (
int|None) – Override output dimensionality (supported fortext-embedding-3-*).batch_size (
int) – Maximum number of texts per API call.
- property dimension: int
Dimensionality of the embedding vectors.
Returns
-1if not known until after the first call.
- embed(texts)[source]
Embed texts synchronously.
- class ractogateway.rag.VoyageEmbedder(model='voyage-3', *, api_key=None, input_type='document', batch_size=128)[source]
Bases:
BaseEmbedderEmbed texts using the Voyage AI API.
Voyage AI embeddings are optimised for Anthropic Claude RAG pipelines and are the recommended choice when using Claude as the generation LLM.
- Parameters:
model (
str) – Voyage model name (default"voyage-3").api_key (
str|None) – Voyage API key. Falls back toVOYAGE_API_KEYenv var.input_type (
str|None) –"query"for queries,"document"for documents to index. Using the correct type improves retrieval quality.batch_size (
int) – Maximum texts per API call.
- property dimension: int
Dimensionality of the embedding vectors.
Returns
-1if not known until after the first call.
- embed(texts)[source]
Embed texts synchronously.
- class ractogateway.rag.Lemmatizer(use_pos_tagging=True)[source]
Bases:
BaseProcessorReduce words to their base (lemma) form using NLTK WordNet.
- Parameters:
use_pos_tagging (
bool) – IfTrue, use POS tagging to improve lemmatization accuracy. Slightly slower but produces better results.
- class ractogateway.rag.ProcessingPipeline(processors)[source]
Bases:
BaseProcessorApply a sequence of
BaseProcessorobjects to text.Example:
pipeline = ProcessingPipeline([TextCleaner(), Lemmatizer()]) processed = pipeline.process(" Hello, worlds! ")
- Parameters:
processors (
list[BaseProcessor]) – Ordered list of processors to apply. Each processor receives the output of the previous one.
- class ractogateway.rag.TextCleaner(normalize_unicode=True, strip_html=True, strip_control_chars=True, collapse_whitespace=True, collapse_blank_lines=True)[source]
Bases:
BaseProcessorNormalise text for embedding and retrieval.
Steps applied (all optional via constructor flags):
Unicode normalisation (NFC)
Strip residual HTML tags
Remove control characters
Collapse multiple spaces to one
Collapse runs of blank lines to at most two newlines
Strip leading/trailing whitespace
- Parameters:
normalize_unicode (
bool) – Applyunicodedata.normalize("NFC", text).strip_html (
bool) – Remove<tag>patterns.strip_control_chars (
bool) – Remove non-printable control characters.collapse_whitespace (
bool) – Collapse sequences of spaces/tabs to a single space.collapse_blank_lines (
bool) – Collapse 3+ consecutive newlines to 2.
- class ractogateway.rag.FileReaderRegistry(readers=None)[source]
Bases:
objectRegistry that maps file extensions to
BaseReaderinstances.By default all built-in readers are registered. You can add custom readers with
register().Example:
registry = FileReaderRegistry() doc = registry.read("report.pdf")
- register(reader)[source]
Add reader to the registry for all its supported extensions.
- Return type:
- get_reader(path)[source]
Return the reader for path’s extension.
- Raises:
ValueError – If no reader supports the file’s extension.
- Return type:
- class ractogateway.rag.ChromaStore(collection='ractogateway', *, path=None, host=None, port=8000, distance_function='cosine')[source]
Bases:
BaseVectorStoreVector store backed by ChromaDB.
Supports both in-process (
pathorNonefor ephemeral) and HTTP-client modes (host+port).- Parameters:
collection (
str) – Name of the ChromaDB collection.path (
str|None) – Persist directory for a local persistent client.None= ephemeral.host (
str|None) – ChromaDB server host (enables HTTP client mode).port (
int) – ChromaDB server port (default 8000).distance_function (
str) –"cosine","l2", or"ip"(inner product).
- add(chunks)[source]
Add chunks (with embeddings) to the store.
- Parameters:
chunks (
list[Chunk]) – Chunks to index. Each chunk must have a non-Noneembedding.- Raises:
ValueError – If any chunk has
embedding=None.- Return type:
- search(embedding, top_k=5, filters=None)[source]
Search for the top_k most similar chunks.
- Parameters:
- Return type:
- Returns:
list[RetrievalResult] – Ranked list of results (rank 1 = most similar).
- class ractogateway.rag.FAISSStore(dimension=None, index_type='flat_ip')[source]
Bases:
BaseVectorStoreVector store backed by Facebook AI Similarity Search (FAISS).
Stores embeddings in a flat L2 or cosine (Inner Product) index. All data is in-memory; call
save()/load()to persist.- Parameters:
- add(chunks)[source]
Add chunks (with embeddings) to the store.
- Parameters:
chunks (
list[Chunk]) – Chunks to index. Each chunk must have a non-Noneembedding.- Raises:
ValueError – If any chunk has
embedding=None.- Return type:
- search(embedding, top_k=5, filters=None)[source]
Search for the top_k most similar chunks.
- Parameters:
- Return type:
- Returns:
list[RetrievalResult] – Ranked list of results (rank 1 = most similar).
- save(path)[source]
Persist the FAISS index to path.index and chunks to path.chunks.
- Return type:
- class ractogateway.rag.InMemoryVectorStore(similarity='cosine')[source]
Bases:
BaseVectorStorePure-Python brute-force vector store — no extra dependencies.
This store keeps all chunks and their embeddings in memory. It is not suitable for production-scale corpora but requires no installation.
- Parameters:
similarity (
str) – Similarity function to use. Currently only"cosine"is supported.
- add(chunks)[source]
Add chunks (with embeddings) to the store.
- Parameters:
chunks (
list[Chunk]) – Chunks to index. Each chunk must have a non-Noneembedding.- Raises:
ValueError – If any chunk has
embedding=None.- Return type:
- search(embedding, top_k=5, filters=None)[source]
Search for the top_k most similar chunks.
- Parameters:
- Return type:
- Returns:
list[RetrievalResult] – Ranked list of results (rank 1 = most similar).
- class ractogateway.rag.MilvusStore(collection='ractogateway', *, host='localhost', port=19530, uri=None, token=None, dimension=None, metric_type='IP', batch_size=100)[source]
Bases:
BaseVectorStoreVector store backed by Milvus or Zilliz Cloud.
- Parameters:
collection (
str) – Milvus collection name.host (
str) – Milvus server host (default"localhost").port (
int) – Milvus server port (default19530).uri (
str|None) – Zilliz Cloud URI (overrides host/port when set).dimension (
int|None) – Embedding dimension. Inferred on first add.metric_type (
str) –"IP"(inner product / cosine) or"L2".batch_size (
int) – Vectors per insert batch.
- add(chunks)[source]
Add chunks (with embeddings) to the store.
- Parameters:
chunks (
list[Chunk]) – Chunks to index. Each chunk must have a non-Noneembedding.- Raises:
ValueError – If any chunk has
embedding=None.- Return type:
- search(embedding, top_k=5, filters=None)[source]
Search for the top_k most similar chunks.
- Parameters:
- Return type:
- Returns:
list[RetrievalResult] – Ranked list of results (rank 1 = most similar).
- class ractogateway.rag.PGVectorStore(dsn, *, table='rag_chunks', dimension=None, distance='cosine', batch_size=100)[source]
Bases:
BaseVectorStoreVector store backed by PostgreSQL with the pgvector extension.
- Parameters:
- add(chunks)[source]
Add chunks (with embeddings) to the store.
- Parameters:
chunks (
list[Chunk]) – Chunks to index. Each chunk must have a non-Noneembedding.- Raises:
ValueError – If any chunk has
embedding=None.- Return type:
- search(embedding, top_k=5, filters=None)[source]
Search for the top_k most similar chunks.
- Parameters:
- Return type:
- Returns:
list[RetrievalResult] – Ranked list of results (rank 1 = most similar).
- class ractogateway.rag.PineconeStore(index_name, *, api_key=None, namespace='', batch_size=100)[source]
Bases:
BaseVectorStoreVector store backed by Pinecone cloud.
- Parameters:
index_name (
str) – Name of the Pinecone index (must already exist).api_key (
str|None) – Pinecone API key. Falls back toPINECONE_API_KEYenv var.namespace (
str) – Pinecone namespace for logical data isolation.environment – Deprecated Pinecone environment string (for legacy pod-based indexes).
batch_size (
int) – Number of vectors per upsert batch.
- add(chunks)[source]
Add chunks (with embeddings) to the store.
- Parameters:
chunks (
list[Chunk]) – Chunks to index. Each chunk must have a non-Noneembedding.- Raises:
ValueError – If any chunk has
embedding=None.- Return type:
- search(embedding, top_k=5, filters=None)[source]
Search for the top_k most similar chunks.
- Parameters:
- Return type:
- Returns:
list[RetrievalResult] – Ranked list of results (rank 1 = most similar).
- class ractogateway.rag.QdrantStore(collection='ractogateway', *, url=None, api_key=None, distance='cosine', dimension=None, batch_size=100)[source]
Bases:
BaseVectorStoreVector store backed by Qdrant.
- Parameters:
- add(chunks)[source]
Add chunks (with embeddings) to the store.
- Parameters:
chunks (
list[Chunk]) – Chunks to index. Each chunk must have a non-Noneembedding.- Raises:
ValueError – If any chunk has
embedding=None.- Return type:
- search(embedding, top_k=5, filters=None)[source]
Search for the top_k most similar chunks.
- Parameters:
- Return type:
- Returns:
list[RetrievalResult] – Ranked list of results (rank 1 = most similar).
- class ractogateway.rag.WeaviateStore(class_name='RactoChunk', *, url=None, api_key=None, additional_headers=None, distance_metric='cosine', batch_size=100)[source]
Bases:
BaseVectorStoreVector store backed by Weaviate.
Supports embedded (local, no server needed), local server, and Weaviate Cloud (WCS) connections.
- Parameters:
class_name (
str) – Weaviate class (collection) name.url (
str|None) – Weaviate server URL.None= use embedded Weaviate.additional_headers (
dict[str,str] |None) – Extra HTTP headers (e.g. for OpenAI API key pass-through to Weaviate).distance_metric (
str) –"cosine"or"l2-squared".batch_size (
int) – Objects per batch import.
- add(chunks)[source]
Add chunks (with embeddings) to the store.
- Parameters:
chunks (
list[Chunk]) – Chunks to index. Each chunk must have a non-Noneembedding.- Raises:
ValueError – If any chunk has
embedding=None.- Return type:
- search(embedding, top_k=5, filters=None)[source]
Search for the top_k most similar chunks.
- Parameters:
- Return type:
- Returns:
list[RetrievalResult] – Ranked list of results (rank 1 = most similar).