ragmechanic 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. ragmechanic-0.1.0/LICENSE +21 -0
  2. ragmechanic-0.1.0/PKG-INFO +383 -0
  3. ragmechanic-0.1.0/README.md +347 -0
  4. ragmechanic-0.1.0/pyproject.toml +54 -0
  5. ragmechanic-0.1.0/setup.cfg +4 -0
  6. ragmechanic-0.1.0/src/ragmechanic/__init__.py +3 -0
  7. ragmechanic-0.1.0/src/ragmechanic/compression/__init__.py +0 -0
  8. ragmechanic-0.1.0/src/ragmechanic/compression/compressor.py +84 -0
  9. ragmechanic-0.1.0/src/ragmechanic/compression/result.py +9 -0
  10. ragmechanic-0.1.0/src/ragmechanic/embeddings/__init__.py +0 -0
  11. ragmechanic-0.1.0/src/ragmechanic/embeddings/embedding.py +59 -0
  12. ragmechanic-0.1.0/src/ragmechanic/evaluation/__init__.py +0 -0
  13. ragmechanic-0.1.0/src/ragmechanic/evaluation/evaluator.py +67 -0
  14. ragmechanic-0.1.0/src/ragmechanic/evaluation/result.py +10 -0
  15. ragmechanic-0.1.0/src/ragmechanic/ingestion/__init__.py +0 -0
  16. ragmechanic-0.1.0/src/ragmechanic/ingestion/document_loader.py +141 -0
  17. ragmechanic-0.1.0/src/ragmechanic/ingestion/text_splitter.py +31 -0
  18. ragmechanic-0.1.0/src/ragmechanic/llm/__init__.py +0 -0
  19. ragmechanic-0.1.0/src/ragmechanic/llm/manager.py +174 -0
  20. ragmechanic-0.1.0/src/ragmechanic/pipeline.py +261 -0
  21. ragmechanic-0.1.0/src/ragmechanic/report/html_report.py +1450 -0
  22. ragmechanic-0.1.0/src/ragmechanic/report/result.py +73 -0
  23. ragmechanic-0.1.0/src/ragmechanic/retriever/__init__.py +0 -0
  24. ragmechanic-0.1.0/src/ragmechanic/retriever/retriever.py +43 -0
  25. ragmechanic-0.1.0/src/ragmechanic/storage/__init__.py +0 -0
  26. ragmechanic-0.1.0/src/ragmechanic/storage/database.py +600 -0
  27. ragmechanic-0.1.0/src/ragmechanic/vector_store/__init__.py +0 -0
  28. ragmechanic-0.1.0/src/ragmechanic/vector_store/chroma_store.py +38 -0
  29. ragmechanic-0.1.0/src/ragmechanic/vector_store/faiss_store.py +90 -0
  30. ragmechanic-0.1.0/src/ragmechanic/vector_store/pinecone_store.py +64 -0
  31. ragmechanic-0.1.0/src/ragmechanic/vector_store/qdrant_store.py +63 -0
  32. ragmechanic-0.1.0/src/ragmechanic/vector_store/vector_store.py +80 -0
  33. ragmechanic-0.1.0/src/ragmechanic.egg-info/PKG-INFO +383 -0
  34. ragmechanic-0.1.0/src/ragmechanic.egg-info/SOURCES.txt +35 -0
  35. ragmechanic-0.1.0/src/ragmechanic.egg-info/dependency_links.txt +1 -0
  36. ragmechanic-0.1.0/src/ragmechanic.egg-info/requires.txt +26 -0
  37. ragmechanic-0.1.0/src/ragmechanic.egg-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Divyanshu Mathur
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,383 @@
1
+ Metadata-Version: 2.4
2
+ Name: ragmechanic
3
+ Version: 0.1.0
4
+ Summary: A framework for building, evaluating, and diagnosing RAG systems.
5
+ License-Expression: MIT
6
+ Requires-Python: >=3.11
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: langchain-core<2.0,>=1.2
10
+ Requires-Dist: langchain>1.2
11
+ Requires-Dist: langchain-community<0.5,>=0.4
12
+ Requires-Dist: langchain-text-splitters<2.0,>1.0
13
+ Requires-Dist: langchain-classic>1.0.1
14
+ Requires-Dist: pypdf>6.0
15
+ Requires-Dist: docx2txt>=0.9
16
+ Requires-Dist: python-pptx
17
+ Requires-Dist: chardet
18
+ Requires-Dist: tiktoken
19
+ Requires-Dist: python-dotenv
20
+ Requires-Dist: dotenv
21
+ Requires-Dist: tqdm
22
+ Requires-Dist: langchain-huggingface>1.0
23
+ Requires-Dist: sentence-transformers>5.2
24
+ Requires-Dist: chromadb
25
+ Requires-Dist: langchain-chroma
26
+ Requires-Dist: faiss-cpu
27
+ Requires-Dist: langchain-google-genai
28
+ Requires-Dist: langchain-xai
29
+ Requires-Dist: langchain-mistralai
30
+ Requires-Dist: langchain-anthropic
31
+ Requires-Dist: langchain-qdrant
32
+ Requires-Dist: langchain-pinecone
33
+ Requires-Dist: deepeval<5.0.0,>=4.1.5
34
+ Requires-Dist: unstructured
35
+ Dynamic: license-file
36
+
37
+ # RAGMechanic
38
+
39
+ **A modular Python framework for building, evaluating, and diagnosing Retrieval-Augmented Generation (RAG) systems.**
40
+
41
+ RAGMechanic is designed to help developers experiment with RAG pipelines through reusable components for document ingestion, text splitting, embeddings, vector storage, retrieval, contextual compression, LLM integration, evaluation, and reporting.
42
+
43
+ The goal is to make it easier to build RAG applications, compare configurations, identify retrieval and generation issues, and inspect evaluation results without implementing every component from scratch.
44
+
45
+ ## Table of Contents
46
+
47
+ - [Overview](#overview)
48
+ - [Features](#features)
49
+ - [Architecture](#architecture)
50
+ - [Project Structure](#project-structure)
51
+ - [Install](#install)
52
+ - [Installation](#install)
53
+ - [Quick Start](#quick-start)
54
+ - [Core Components](#core-components)
55
+ - [Vector Stores](#vector-stores)
56
+ - [LLM Providers](#llm-providers)
57
+ - [Evaluation and Reporting](#evaluation-and-reporting)
58
+ - [Examples](#Example-Notebook)
59
+
60
+ ## Overview
61
+
62
+ Building a RAG application involves more than connecting a language model to a vector database. Document parsing, chunking, embedding quality, retrieval relevance, context selection, and generation all affect the final result.
63
+
64
+ RAGMechanic organizes these stages into modular components so that developers can build and experiment with different RAG configurations.
65
+
66
+ The framework is intended for:
67
+
68
+ - Developers building document question-answering applications.
69
+ - AI engineers experimenting with retrieval strategies and vector databases.
70
+ - Researchers comparing RAG configurations and evaluation results.
71
+ - Students learning how RAG systems work internally.
72
+ - Contributors building reusable components for retrieval-augmented applications.
73
+
74
+ ## Features
75
+
76
+ ### Document ingestion
77
+
78
+ Load supported document formats and prepare their contents for downstream processing.
79
+
80
+ Potentially supported formats, depending on the installed loaders and current implementation:
81
+
82
+ - PDF
83
+ - DOCX
84
+ - PPTX
85
+ - TXT
86
+
87
+ ### Text splitting
88
+
89
+ Split documents into smaller chunks for embedding and retrieval.
90
+
91
+ Configurable parameters include:
92
+
93
+ - Chunk size
94
+ - Chunk overlap
95
+
96
+ ### Embeddings
97
+
98
+ Generate vector representations of document chunks and queries using supported embedding integrations.
99
+
100
+ The project includes an embeddings module and can be extended to support additional embedding providers.
101
+
102
+ ### Vector storage
103
+
104
+ Modular vector-store implementations are organized under `vector_store/`.
105
+
106
+ The repository currently contains integrations for:
107
+
108
+ - Chroma
109
+ - FAISS
110
+ - Pinecone
111
+ - Qdrant
112
+
113
+ Actual availability depends on the implementation, installed dependencies, provider credentials, and configuration.
114
+
115
+ ### Retrieval
116
+
117
+ Retrieve relevant document chunks based on a user's query.
118
+
119
+ The retrieval component provides the foundation for supplying context to a language model.
120
+
121
+ ### Contextual compression
122
+
123
+ Reduce or refine retrieved context before passing it to the language model.
124
+
125
+ This can help focus generation on relevant information and reduce unnecessary context, depending on the compression strategy and its configuration.
126
+
127
+ ### LLM integration
128
+
129
+ A dedicated LLM manager provides a place to configure language-model integrations.
130
+
131
+ The dependency configuration includes integrations for Google Gemini, xAI, Mistral, and Anthropic.
132
+
133
+ ### Evaluation
134
+
135
+ The evaluation module is designed to assess RAG outputs and store evaluation results.
136
+
137
+ Evaluation metrics and their prerequisites depend on the configured evaluator and supported implementation.
138
+
139
+ ### Persistent result storage
140
+
141
+ The storage module uses a database to persist supported pipeline or evaluation information.
142
+
143
+ ### HTML reports
144
+
145
+ The reporting module generates HTML reports intended to make evaluation results easier to inspect.
146
+
147
+ Report fields and available visualizations depend on the current reporting implementation.
148
+
149
+ ## Architecture
150
+
151
+ A typical RAG workflow follows these stages:
152
+
153
+ 1. **Ingestion:** Load source documents.
154
+ 2. **Splitting:** Divide documents into smaller chunks.
155
+ 3. **Embedding:** Convert chunks into vector representations.
156
+ 4. **Indexing:** Store vectors and associated document information.
157
+ 5. **Retrieval:** Find relevant chunks for a query.
158
+ 6. **Compression:** Refine retrieved context when enabled.
159
+ 7. **Generation:** Send the query and selected context to the language model.
160
+ 8. **Evaluation:** Assess the generated answer using supported metrics.
161
+ 9. **Storage and reporting:** Persist results and generate reports.
162
+
163
+ The exact execution flow depends on the selected components and pipeline configuration.
164
+
165
+ ## Project Structure
166
+
167
+ ```text
168
+ ragmechanic/
169
+ ├── documents/
170
+ ├── output/
171
+ │ ├── database/
172
+ │ └── report/
173
+ ├── src/
174
+ │ └── ragmechanic/
175
+ │ ├── compression/
176
+ │ ├── embeddings/
177
+ │ ├── evaluation/
178
+ │ ├── ingestion/
179
+ │ ├── llm/
180
+ │ ├── report/
181
+ │ ├── retriever/
182
+ │ ├── storage/
183
+ │ ├── vector_store/
184
+ │ └── pipeline.py
185
+ ├── examples.ipynb
186
+ ├── docs/
187
+ ├── pyproject.toml
188
+ ├── README.md
189
+ └── .gitignore
190
+ ```
191
+
192
+ The `documents/` and `output/` directories shown above are useful for local development and examples. They do not necessarily need to be distributed as part of the installed package.
193
+
194
+
195
+ ## Install
196
+
197
+ ### Option 1: Install from PyPI (Recommended)
198
+
199
+ Install the latest published release of RAGMechanic:
200
+
201
+ ```bash
202
+ python -m pip install ragmechanic
203
+ ```
204
+
205
+ ### Option 2: Install from GitHub (Development)
206
+
207
+ To use the latest repository version or contribute to development, clone the repository:
208
+
209
+ ```bash
210
+ git clone https://github.com/Divyanshu-Mathur/RAGMechanic.git
211
+ cd ragmechanic
212
+ ```
213
+
214
+ Create a virtual environment:
215
+
216
+ ```bash
217
+ python -m venv .venv
218
+ ```
219
+
220
+ Activate the environment.
221
+
222
+ **Windows PowerShell:**
223
+
224
+ ```powershell
225
+ .\.venv\Scripts\Activate.ps1
226
+ ```
227
+
228
+ **Linux or macOS:**
229
+
230
+ ```bash
231
+ source .venv/bin/activate
232
+ ```
233
+
234
+ Upgrade pip and install the package in editable mode:
235
+
236
+ ```bash
237
+ python -m pip install --upgrade pip
238
+ python -m pip install -e .
239
+ ```
240
+
241
+ ## Quick Start
242
+
243
+ ```python
244
+ from ragmechanic import RAGPipeline
245
+
246
+ # Configure the pipeline using supported arguments.
247
+ pipeline = RAGPipeline(
248
+ docs="path/to/documents",
249
+ embedding_model="YOUR_EMBEDDING_MODEL",
250
+ llm_provider="YOUR_PROVIDER",
251
+ llm_model="YOUR_MODEL",
252
+ vector_store="chroma",
253
+ chunk_size=800,
254
+ chunk_overlap=150,
255
+ )
256
+
257
+ ```
258
+
259
+ ## Core Components
260
+
261
+ ### Document loading
262
+
263
+ **Module:** `ragmechanic.ingestion`
264
+
265
+ Responsible for loading supported source documents and preparing their content for subsequent processing.
266
+
267
+ ### Text splitting
268
+
269
+ **Module:** `ragmechanic.ingestion`
270
+
271
+ Responsible for creating chunks from document content, using configurable splitting parameters where supported.
272
+
273
+ ### Embeddings
274
+
275
+ **Module:** `ragmechanic.embeddings`
276
+
277
+ Responsible for creating vector representations used in similarity-based retrieval.
278
+
279
+ ### Vector stores
280
+
281
+ **Module:** `ragmechanic.vector_store`
282
+
283
+ Provides the abstraction and implementations for supported vector databases and similarity-search backends.
284
+
285
+ ### Retrieval
286
+
287
+ **Module:** `ragmechanic.retriever`
288
+
289
+ Responsible for finding candidate document chunks relevant to a query.
290
+
291
+ ### Contextual compression
292
+
293
+ **Module:** `ragmechanic.compression`
294
+
295
+ Provides functionality for refining retrieved context before generation.
296
+
297
+ ### Language-model management
298
+
299
+ **Module:** `ragmechanic.llm`
300
+
301
+ Centralizes supported LLM configuration and integration logic.
302
+
303
+ ### Evaluation
304
+
305
+ **Module:** `ragmechanic.evaluation`
306
+
307
+ Provides evaluation-related functionality for assessing supported RAG outputs.
308
+
309
+ ### Storage
310
+
311
+ **Module:** `ragmechanic.storage`
312
+
313
+ Handles persistence of supported data and results.
314
+
315
+ ### Reporting
316
+
317
+ **Module:** `ragmechanic.report`
318
+
319
+ Provides HTML report generation functionality.
320
+
321
+ ## Vector Stores
322
+
323
+ RAGMechanic contains modules for the following vector-store backends:
324
+
325
+ | Backend | Python package |
326
+ |---|---|
327
+ | Chroma | `chromadb`, `langchain-chroma` |
328
+ | FAISS | `faiss-cpu` |
329
+ | Pinecone | `langchain-pinecone` |
330
+ | Qdrant | `langchain-qdrant` |
331
+
332
+ Each backend may have different requirements for persistence, authentication, indexing, and configuration.
333
+
334
+
335
+ ## LLM Providers
336
+
337
+ The project's dependency configuration includes the following LangChain integrations:
338
+
339
+ | Provider | Integration package |
340
+ |---|---|
341
+ | Google Gemini | `langchain-google-genai` |
342
+ | xAI | `langchain-xai` |
343
+ | Mistral | `langchain-mistralai` |
344
+ | Anthropic | `langchain-anthropic` |
345
+
346
+ Provider availability depends on the LLM manager implementation and the installed integration package.
347
+
348
+ Follow each provider's documentation for API-key setup, model availability, rate limits, and pricing.
349
+
350
+ ## Evaluation and Reporting
351
+
352
+ RAGMechanic separates evaluation and reporting into dedicated modules.
353
+
354
+ A typical evaluation workflow may include:
355
+
356
+ 1. Run a query against the configured RAG pipeline.
357
+ 2. Collect the answer and retrieved context.
358
+ 3. Supply the required evaluation inputs.
359
+ 4. Compute the metrics supported by the evaluator.
360
+ 5. Store the results.
361
+ 6. Generate an HTML report.
362
+
363
+ ### Output files
364
+
365
+ For local development, generated artifacts can be organized as follows:
366
+
367
+ ```text
368
+ output/
369
+ ├── database/
370
+ │ └── ragmechanic.db
371
+ └── report/
372
+ └── rag_report.html
373
+ ```
374
+
375
+ These paths are examples of the repository's current local output organization. Actual output paths should be configurable and documented according to the implementation.
376
+
377
+ ## Example Notebook
378
+
379
+ Explore the end-to-end RAG workflow in
380
+ [`examples.ipynb`](./examples.ipynb).
381
+
382
+ The notebook demonstrates pipeline configuration, document querying,
383
+ evaluation, and HTML report generation.