Skip to content

Index

diapason.tools.storage

Storage primitive — persistent searchable storage.

Chunk dataclass

A single chunk produced by the chunking pipeline.

ChunkConfig dataclass

Parameters controlling the chunking strategy.

ContextConfig dataclass

Controls how retrieved context is injected into prompts.

MemoryBackend

Bases: ABC

Base class for all memory / retrieval backends.

Subclasses must be registered via @MemoryRegistry.register("name") to become discoverable.

clear() abstractmethod

Remove all stored documents.

delete(doc_id) abstractmethod

Delete a document by id. Return True if it existed.

retrieve(query, *, top_k=5, **kwargs) abstractmethod

Search for query and return the top-k results.

store(content, *, source='', metadata=None) abstractmethod

Persist content and return a unique document id.

RetrievalResult dataclass

A single result returned by a memory backend query.

chunk_text(text, *, source='', config=None)

Split text into chunks respecting paragraph boundaries.

Parameters

text: The full document text. source: Originating filename or identifier. config: Chunking parameters (uses defaults if None).

Returns

List of :class:Chunk objects, in order.

ingest_path(path, *, config=None)

Ingest a file or directory into chunks.

If path is a file, reads and chunks it. If path is a directory, recursively walks it (skipping hidden and common non-content directories) and chunks each file.

inject_context(query, messages, backend, *, config=None)

Retrieve relevant context and prepend it to messages.

Returns a new list — the original list is not mutated. If no results pass the score threshold, returns the original messages unchanged.

Parameters

query: The user query to search for. messages: The existing message list. backend: The memory backend to search. config: Context injection settings (uses defaults if None).

read_document(path)

Read a file and return (text, metadata).

Raises

ImportError If the file is a PDF and pdfplumber is not installed. FileNotFoundError If path does not exist.