rag-python 0.1.0__py3-none-any.whl
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.
- rag_python/__init__.py +39 -0
- rag_python/chunking.py +181 -0
- rag_python/cleaning.py +102 -0
- rag_python/cli.py +77 -0
- rag_python/client.py +190 -0
- rag_python/config.py +37 -0
- rag_python/document_loaders.py +74 -0
- rag_python/evaluation.py +105 -0
- rag_python/generation.py +35 -0
- rag_python/guardrails.py +66 -0
- rag_python/options.py +68 -0
- rag_python/providers/__init__.py +5 -0
- rag_python/providers/anthropic_provider.py +41 -0
- rag_python/providers/azure_openai_provider.py +62 -0
- rag_python/providers/base.py +24 -0
- rag_python/providers/factory.py +53 -0
- rag_python/providers/gemini_provider.py +45 -0
- rag_python/providers/ollama_provider.py +56 -0
- rag_python/providers/openai_provider.py +46 -0
- rag_python/py.typed +0 -0
- rag_python/query_rewriting.py +65 -0
- rag_python/rag_pipeline.py +241 -0
- rag_python/reranker.py +64 -0
- rag_python/retrieval.py +61 -0
- rag_python/vector_store.py +91 -0
- rag_python-0.1.0.dist-info/LICENSE +22 -0
- rag_python-0.1.0.dist-info/METADATA +158 -0
- rag_python-0.1.0.dist-info/RECORD +31 -0
- rag_python-0.1.0.dist-info/WHEEL +5 -0
- rag_python-0.1.0.dist-info/entry_points.txt +2 -0
- rag_python-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: rag-python
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Production-grade RAG for Python: multi-LLM, query rewriting, reranking, guardrails, and evaluation.
|
|
5
|
+
Author-email: Raghav Singla <04raghavsingla28@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/RaghavOG/rag-python
|
|
8
|
+
Project-URL: Repository, https://github.com/RaghavOG/rag-python
|
|
9
|
+
Project-URL: Documentation, https://github.com/RaghavOG/rag-python#readme
|
|
10
|
+
Project-URL: Issues, https://github.com/RaghavOG/rag-python/issues
|
|
11
|
+
Keywords: rag,llm,embeddings,chromadb,openai,rag-python,retrieval-augmented-generation
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: openai>=1.12.0
|
|
25
|
+
Requires-Dist: tiktoken>=0.5.0
|
|
26
|
+
Requires-Dist: chromadb>=0.4.22
|
|
27
|
+
Requires-Dist: pypdf>=3.17.0
|
|
28
|
+
Requires-Dist: python-docx>=1.1.0
|
|
29
|
+
Requires-Dist: langdetect>=1.0.9
|
|
30
|
+
Requires-Dist: regex>=2023.0.0
|
|
31
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
32
|
+
Requires-Dist: requests>=2.31.0
|
|
33
|
+
Provides-Extra: rerank
|
|
34
|
+
Requires-Dist: sentence-transformers>=2.2.0; extra == "rerank"
|
|
35
|
+
Requires-Dist: torch>=2.0.0; extra == "rerank"
|
|
36
|
+
Provides-Extra: anthropic
|
|
37
|
+
Requires-Dist: anthropic>=0.20.0; extra == "anthropic"
|
|
38
|
+
Provides-Extra: gemini
|
|
39
|
+
Requires-Dist: google-genai>=0.3.0; extra == "gemini"
|
|
40
|
+
Provides-Extra: dev
|
|
41
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
42
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
43
|
+
Requires-Dist: build; extra == "dev"
|
|
44
|
+
Requires-Dist: twine; extra == "dev"
|
|
45
|
+
Provides-Extra: all
|
|
46
|
+
Requires-Dist: rag-python[anthropic,gemini,rerank]; extra == "all"
|
|
47
|
+
|
|
48
|
+
# rag-python
|
|
49
|
+
|
|
50
|
+
[](https://www.python.org/downloads/)
|
|
51
|
+
[](LICENSE)
|
|
52
|
+
[](https://github.com/RaghavOG/rag-python)
|
|
53
|
+
|
|
54
|
+
**rag-python** is a production-oriented Python library for **Retrieval-Augmented Generation (RAG)**.
|
|
55
|
+
|
|
56
|
+
Ingest your documents, ask questions, get grounded answers — with query rewriting, multi-query retrieval, reranking, guardrails, and multi-LLM support.
|
|
57
|
+
|
|
58
|
+
**Author:** [Raghav Singla](https://github.com/RaghavOG)
|
|
59
|
+
**Repository:** [github.com/RaghavOG/rag-python](https://github.com/RaghavOG/rag-python)
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Features
|
|
64
|
+
|
|
65
|
+
- Document pipeline: loaders → cleaning → chunking → embeddings → ChromaDB
|
|
66
|
+
- Query pipeline: rewriting → multi-query retrieval → reranking
|
|
67
|
+
- Generation with guardrails (prompt injection + hallucination checks)
|
|
68
|
+
- Evaluation scores + self-correction retry loop
|
|
69
|
+
- **LLM providers:** OpenAI, Azure OpenAI, Anthropic, Gemini, Ollama
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Install
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pip install rag-python
|
|
77
|
+
# or from source
|
|
78
|
+
pip install -e .
|
|
79
|
+
# with reranking + extra providers
|
|
80
|
+
pip install -e ".[rerank,anthropic,gemini,all]"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Quickstart
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from rag_python import RAG
|
|
89
|
+
|
|
90
|
+
rag = RAG(
|
|
91
|
+
llm_provider="openai",
|
|
92
|
+
llm_model="gpt-4o-mini",
|
|
93
|
+
embedding_provider="openai",
|
|
94
|
+
embedding_model="text-embedding-3-small",
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
rag.ingest(["./data"], reindex=True)
|
|
98
|
+
answer = rag.query("How many days of annual leave?")
|
|
99
|
+
print(answer.text)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### CLI
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
export OPENAI_API_KEY=sk-...
|
|
106
|
+
rag-python ingest ./data --reindex
|
|
107
|
+
rag-python query "How many days of annual leave?" -v
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Environment variables
|
|
113
|
+
|
|
114
|
+
| Variable | Required | Description |
|
|
115
|
+
|----------|----------|-------------|
|
|
116
|
+
| `OPENAI_API_KEY` | For OpenAI | Default LLM + embeddings |
|
|
117
|
+
| `ANTHROPIC_API_KEY` | For Claude | LLM only |
|
|
118
|
+
| `GEMINI_API_KEY` | For Gemini | LLM only |
|
|
119
|
+
| `AZURE_OPENAI_ENDPOINT` | For Azure | Azure OpenAI |
|
|
120
|
+
| `AZURE_OPENAI_API_KEY` | For Azure | Azure OpenAI |
|
|
121
|
+
| `OPENAI_API_VERSION` | Azure | Default `2023-09-01-preview` |
|
|
122
|
+
| `OLLAMA_BASE_URL` | Ollama | Default `http://localhost:11434` |
|
|
123
|
+
| `RAG_PYTHON_DATA_DIR` | Optional | Default `./data` |
|
|
124
|
+
| `RAG_PYTHON_CHROMA_DIR` | Optional | Default `./chroma_db` |
|
|
125
|
+
|
|
126
|
+
See [`.env.example`](.env.example) for all tuning options.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Project structure
|
|
131
|
+
|
|
132
|
+
```text
|
|
133
|
+
.
|
|
134
|
+
├── src/rag_python/ # Installable package (PyPI: rag-python)
|
|
135
|
+
│ ├── client.py # High-level RAG API
|
|
136
|
+
│ ├── rag_pipeline.py # Full pipeline
|
|
137
|
+
│ └── providers/ # OpenAI, Azure, Anthropic, Gemini, Ollama
|
|
138
|
+
├── tests/
|
|
139
|
+
├── examples/
|
|
140
|
+
├── docs/
|
|
141
|
+
├── data/ # Sample documents
|
|
142
|
+
├── pyproject.toml
|
|
143
|
+
└── main.py # Local dev CLI wrapper
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Docs
|
|
149
|
+
|
|
150
|
+
- [Usage](docs/USAGE.md)
|
|
151
|
+
- [Providers](docs/PROVIDERS.md)
|
|
152
|
+
- [Changelog](CHANGELOG.md)
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## License
|
|
157
|
+
|
|
158
|
+
MIT © [Raghav Singla](https://github.com/RaghavOG)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
rag_python/__init__.py,sha256=0mdBYu9JmPzQBOX947S5tdk5KuNU3JNO-y5GsDZsFlY,834
|
|
2
|
+
rag_python/chunking.py,sha256=P1dbZ8ZY7487MxrWe2cypCiKhzIJ8zBPCTVz20vt8fo,6204
|
|
3
|
+
rag_python/cleaning.py,sha256=fSux4T0pg7Xe_8NUP2pgzuForyRk1i2VPYIXSzRajzs,3193
|
|
4
|
+
rag_python/cli.py,sha256=UlCnI6Ah7pmyZwCEP1c-gt5XDOhFzLOvnsk2vKxvp-A,3126
|
|
5
|
+
rag_python/client.py,sha256=MhWAm92Ic2FQ1DTej4EhAlT9UoPN-GjxA0xrHIvwNA8,7656
|
|
6
|
+
rag_python/config.py,sha256=Zw8TjQFKRvOUHpIb7kjEb7DtPFoYPzdQyOPzSXTqDcc,1389
|
|
7
|
+
rag_python/document_loaders.py,sha256=izguVJjPq8v4hDWC8wGP2-LwiYUJbVe-DOsIX6n9J9E,2429
|
|
8
|
+
rag_python/evaluation.py,sha256=gTiXMaAtTUIsV6Ffhywz829BhfR8YhfJFkYZYrD9WYI,3561
|
|
9
|
+
rag_python/generation.py,sha256=t6aSct2vZELIf20JDwRVt8UTwPnTXx0bU3TKoliiwVg,1108
|
|
10
|
+
rag_python/guardrails.py,sha256=hJLXvpPNI9o8emyipSy5PpePofGzktlDLyMAXfAxUXs,2520
|
|
11
|
+
rag_python/options.py,sha256=QvangjsYbct204_p_avraAuw_Ry2mcjhxby2Sx96dE0,1858
|
|
12
|
+
rag_python/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
+
rag_python/query_rewriting.py,sha256=og_XWai2-08C7W67mFndA3k-aTxMdqGnu70qHi1Ohgc,2293
|
|
14
|
+
rag_python/rag_pipeline.py,sha256=R8roEc-OSFPqrjZmvJXp7IhYaOdqd6kZ63otN1PUKTI,8747
|
|
15
|
+
rag_python/reranker.py,sha256=8RxCPfgp80c-KSKojllGzbpZ7iSku-i7VLgPHa1a3rk,2181
|
|
16
|
+
rag_python/retrieval.py,sha256=A9ZMIkrifyDF1rhtgNt_uR09o1_hCkywIuODjvLaY6Q,2261
|
|
17
|
+
rag_python/vector_store.py,sha256=16I9g7Q8bMjwpxhTNv0nCq2WXQwftjZdSaxFNteVsH4,2909
|
|
18
|
+
rag_python/providers/__init__.py,sha256=SjhMvYoA30EY5VUYVXhEGwcmQnIU2tUomcNE0_0NFho,215
|
|
19
|
+
rag_python/providers/anthropic_provider.py,sha256=dSiCdM4F90jI9w7z_wS10XuVsX-pR733-cAgJHtVV2Q,1493
|
|
20
|
+
rag_python/providers/azure_openai_provider.py,sha256=8SbI7rDzQgvC4ZXP89Q8kjfqeWuBfX1KKgExGLFkmx0,1940
|
|
21
|
+
rag_python/providers/base.py,sha256=M9DYowQvNvRuATaM6944CWovK0awJ0buBmbnQfroJos,593
|
|
22
|
+
rag_python/providers/factory.py,sha256=uD0Hqrzyj9R88vNVN-95Fn2gj28hUIVNXuKe0G1R5wo,2522
|
|
23
|
+
rag_python/providers/gemini_provider.py,sha256=OZzs1YJQSZituoxS5Gk8yv3jYNIFY1SVovWUu7lz5Z4,1842
|
|
24
|
+
rag_python/providers/ollama_provider.py,sha256=DDhDriB6-Ob0r2-M-P3SvIFG37ruDAErtU7LWDK8xh0,1958
|
|
25
|
+
rag_python/providers/openai_provider.py,sha256=oR7rCCaxCtirAVetJrR4oC3UrWySuqLc9kbosydoQAQ,1585
|
|
26
|
+
rag_python-0.1.0.dist-info/LICENSE,sha256=PZ61Z6ve0hBHgztaC1rPgnxQTRXRkeHKASlnKkX2pvc,1079
|
|
27
|
+
rag_python-0.1.0.dist-info/METADATA,sha256=R0dvEMcDKMgUDxImAEwmBeHMYcmR46NjPl31lhoBJw4,5199
|
|
28
|
+
rag_python-0.1.0.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
|
|
29
|
+
rag_python-0.1.0.dist-info/entry_points.txt,sha256=558Rd4GWV_6mIyqdRSVNE4ZZi0-KdblTZhcMbIn3ryY,51
|
|
30
|
+
rag_python-0.1.0.dist-info/top_level.txt,sha256=SrgudPwkJWfJ3gUn2n-dhrt9vN2XbQcaZ3wLQZed4Z4,11
|
|
31
|
+
rag_python-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
rag_python
|