Index
storage
¶
Storage primitive — persistent searchable storage.
Classes¶
MemoryBackend
¶
Bases: ABC
Base class for all memory / retrieval backends.
Subclasses must be registered via
@MemoryRegistry.register("name") to become discoverable.
Functions¶
store
abstractmethod
¶
Persist content and return a unique document id.
retrieve
abstractmethod
¶
retrieve(query: str, *, top_k: int = 5, **kwargs: Any) -> List[RetrievalResult]
delete
abstractmethod
¶
RetrievalResult
dataclass
¶
RetrievalResult(content: str, score: float = 0.0, source: str = '', metadata: Dict[str, Any] = dict())
A single result returned by a memory backend query.
Chunk
dataclass
¶
Chunk(content: str, source: str = '', offset: int = 0, index: int = 0, metadata: Dict[str, Any] = dict())
A single chunk produced by the chunking pipeline.
ChunkConfig
dataclass
¶
Parameters controlling the chunking strategy.
ContextConfig
dataclass
¶
ContextConfig(enabled: bool = True, top_k: int = 5, min_score: float = 0.1, max_context_tokens: int = 2048)
Controls how retrieved context is injected into prompts.
Functions¶
chunk_text
¶
chunk_text(text: str, *, source: str = '', config: Optional[ChunkConfig] = None) -> List[Chunk]
Split text into chunks respecting paragraph boundaries.
| PARAMETER | DESCRIPTION |
|---|---|
text
|
The full document text.
TYPE:
|
source
|
Originating filename or identifier.
TYPE:
|
config
|
Chunking parameters (uses defaults if
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
List of :class:`Chunk` objects, in order.
|
|
Source code in src/openjarvis/tools/storage/chunking.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
inject_context
¶
inject_context(query: str, messages: List[Message], backend: MemoryBackend, *, config: Optional[ContextConfig] = None) -> List[Message]
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.
| PARAMETER | DESCRIPTION |
|---|---|
query
|
The user query to search for.
TYPE:
|
messages
|
The existing message list.
TYPE:
|
backend
|
The memory backend to search.
TYPE:
|
config
|
Context injection settings (uses defaults if
TYPE:
|
Source code in src/openjarvis/tools/storage/context.py
ingest_path
¶
ingest_path(path: Path, *, config: Optional[ChunkConfig] = None) -> List[Chunk]
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.
Source code in src/openjarvis/tools/storage/ingest.py
read_document
¶
read_document(path: Path) -> Tuple[str, DocumentMeta]
Read a file and return (text, metadata).
| RAISES | DESCRIPTION |
|---|---|
ImportError
|
If the file is a PDF and |
FileNotFoundError
|
If path does not exist. |