ragup 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 (44) hide show
  1. ragup-0.1.0/LICENSE +21 -0
  2. ragup-0.1.0/PKG-INFO +224 -0
  3. ragup-0.1.0/README.md +185 -0
  4. ragup-0.1.0/pyproject.toml +82 -0
  5. ragup-0.1.0/ragup/__init__.py +7 -0
  6. ragup-0.1.0/ragup/api/__init__.py +5 -0
  7. ragup-0.1.0/ragup/api/routes.py +7 -0
  8. ragup-0.1.0/ragup/api/schemas.py +15 -0
  9. ragup-0.1.0/ragup/api/server.py +81 -0
  10. ragup-0.1.0/ragup/chunking/__init__.py +9 -0
  11. ragup-0.1.0/ragup/chunking/base.py +36 -0
  12. ragup-0.1.0/ragup/chunking/recursive.py +59 -0
  13. ragup-0.1.0/ragup/config.py +48 -0
  14. ragup-0.1.0/ragup/constants.py +73 -0
  15. ragup-0.1.0/ragup/core/__init__.py +0 -0
  16. ragup-0.1.0/ragup/core/document.py +282 -0
  17. ragup-0.1.0/ragup/embeddings/__init__.py +9 -0
  18. ragup-0.1.0/ragup/embeddings/embedder.py +61 -0
  19. ragup-0.1.0/ragup/embeddings/models.py +22 -0
  20. ragup-0.1.0/ragup/exceptions.py +57 -0
  21. ragup-0.1.0/ragup/llm/__init__.py +9 -0
  22. ragup-0.1.0/ragup/llm/answer.py +54 -0
  23. ragup-0.1.0/ragup/llm/prompt.py +36 -0
  24. ragup-0.1.0/ragup/loaders/__init__.py +62 -0
  25. ragup-0.1.0/ragup/loaders/base.py +31 -0
  26. ragup-0.1.0/ragup/loaders/json_loader.py +44 -0
  27. ragup-0.1.0/ragup/loaders/pdf_loader.py +43 -0
  28. ragup-0.1.0/ragup/loaders/txt_loader.py +45 -0
  29. ragup-0.1.0/ragup/retrieval/__init__.py +11 -0
  30. ragup-0.1.0/ragup/retrieval/retriever.py +41 -0
  31. ragup-0.1.0/ragup/retrieval/search.py +55 -0
  32. ragup-0.1.0/ragup/utils/__init__.py +0 -0
  33. ragup-0.1.0/ragup/utils/helpers.py +0 -0
  34. ragup-0.1.0/ragup/utils/logger.py +47 -0
  35. ragup-0.1.0/ragup/utils/validators.py +0 -0
  36. ragup-0.1.0/ragup/vectordb/__init__.py +9 -0
  37. ragup-0.1.0/ragup/vectordb/chroma.py +101 -0
  38. ragup-0.1.0/ragup/vectordb/manager.py +51 -0
  39. ragup-0.1.0/ragup.egg-info/PKG-INFO +224 -0
  40. ragup-0.1.0/ragup.egg-info/SOURCES.txt +42 -0
  41. ragup-0.1.0/ragup.egg-info/dependency_links.txt +1 -0
  42. ragup-0.1.0/ragup.egg-info/requires.txt +16 -0
  43. ragup-0.1.0/ragup.egg-info/top_level.txt +1 -0
  44. ragup-0.1.0/setup.cfg +4 -0
ragup-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mehul Dewan
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.
ragup-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,224 @@
1
+ Metadata-Version: 2.4
2
+ Name: ragup
3
+ Version: 0.1.0
4
+ Summary: Build semantic search, question answering, and FastAPI-powered RAG applications in just a few lines of Python.
5
+ Author-email: Mehul Dewan <mehul.work.17@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/mehuldewan17/RagUp
8
+ Project-URL: Repository, https://github.com/mehuldewan17/RagUp
9
+ Project-URL: Issues, https://github.com/mehuldewan17/RagUp/issues
10
+ Keywords: rag,genai,llm,embeddings,semantic-search,vector-database,chromadb,fastapi,ai,python
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Intended Audience :: Developers
18
+ Classifier: Topic :: Software Development :: Libraries
19
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: pymupdf>=1.24.0
24
+ Requires-Dist: chromadb>=0.5.0
25
+ Requires-Dist: sentence-transformers>=3.0.0
26
+ Requires-Dist: fastapi>=0.115.0
27
+ Requires-Dist: uvicorn>=0.30.0
28
+ Requires-Dist: litellm>=1.40.0
29
+ Requires-Dist: pydantic>=2.8.0
30
+ Requires-Dist: numpy>=1.26.0
31
+ Requires-Dist: tqdm>=4.66.0
32
+ Requires-Dist: typing_extensions>=4.12.0
33
+ Provides-Extra: dev
34
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
35
+ Requires-Dist: black>=24.0.0; extra == "dev"
36
+ Requires-Dist: isort>=5.13.0; extra == "dev"
37
+ Requires-Dist: mypy>=1.10.0; extra == "dev"
38
+ Dynamic: license-file
39
+
40
+ # 🚀 RagUp
41
+
42
+ > Build semantic search, AI-powered question answering, and FastAPI APIs from your documents in just a few lines of Python.
43
+
44
+ RagUp is an opinionated Python library that lets you turn documents into searchable AI knowledge bases with almost no setup.
45
+
46
+ ---
47
+
48
+ ## ✨ Features
49
+
50
+ - 📄 Supports PDF, TXT and JSON documents
51
+ - 🧠 Local embeddings using Sentence Transformers
52
+ - 🔍 Semantic Search
53
+ - 🤖 AI-powered Question Answering (Gemini)
54
+ - ⚡ FastAPI server with automatic Swagger UI
55
+ - 💾 Persistent indexing (no re-indexing if nothing changes)
56
+ - 🐍 Simple Python API
57
+
58
+ ---
59
+
60
+ ## 📦 Installation
61
+
62
+ ```bash
63
+ pip install ragup
64
+ ```
65
+
66
+ ---
67
+
68
+ ## ⚡ Quick Start
69
+
70
+ ```python
71
+ from ragup import Document
72
+
73
+ doc = Document("policy.pdf")
74
+
75
+ # Build the index
76
+ doc.ragup()
77
+
78
+ # Semantic Search
79
+ results = doc.search(
80
+ "refund policy"
81
+ )
82
+
83
+ print(results)
84
+
85
+ # AI Question Answering
86
+ answer = doc.ask(
87
+ "What is the refund policy?",
88
+ api_key="YOUR_GEMINI_API_KEY"
89
+ )
90
+
91
+ print(answer)
92
+
93
+ # Launch FastAPI
94
+ doc.serve(
95
+ api_key="YOUR_GEMINI_API_KEY"
96
+ )
97
+ ```
98
+
99
+ Open
100
+
101
+ ```
102
+ http://localhost:8085/docs
103
+ ```
104
+
105
+ to access the interactive Swagger UI.
106
+
107
+ ---
108
+
109
+ # 📚 Supported Documents
110
+
111
+ | Format | Supported |
112
+ |---------|-----------|
113
+ | PDF | ✅ |
114
+ | TXT | ✅ |
115
+ | JSON | ✅ |
116
+
117
+ ---
118
+
119
+ # 🔍 Semantic Search
120
+
121
+ ```python
122
+ results = doc.search(
123
+ "shipping charges",
124
+ top_k=3
125
+ )
126
+ ```
127
+
128
+ Returns the most relevant chunks from your document.
129
+
130
+ ---
131
+
132
+ # 🤖 AI Question Answering
133
+
134
+ ```python
135
+ answer = doc.ask(
136
+ "Summarize this document",
137
+ api_key="YOUR_GEMINI_API_KEY"
138
+ )
139
+ ```
140
+
141
+ RagUp retrieves relevant chunks and asks Gemini to answer using only the document context.
142
+
143
+ ---
144
+
145
+ # 🌐 FastAPI Server
146
+
147
+ ```python
148
+ doc.serve(
149
+ api_key="YOUR_GEMINI_API_KEY"
150
+ )
151
+ ```
152
+
153
+ Available endpoints
154
+
155
+ ```
156
+ POST /search
157
+ POST /ask
158
+ GET /health
159
+ GET /docs
160
+ ```
161
+
162
+ If no API key is supplied,
163
+
164
+ ```python
165
+ doc.serve()
166
+ ```
167
+
168
+ the `/ask` endpoint is automatically disabled.
169
+
170
+ ---
171
+
172
+ # 💾 Persistent Indexing
173
+
174
+ The first time you call
175
+
176
+ ```python
177
+ doc.ragup()
178
+ ```
179
+
180
+ RagUp creates a local index.
181
+
182
+ Subsequent calls reuse the cached index automatically if the document hasn't changed, making startup almost instantaneous.
183
+
184
+ ---
185
+
186
+ # 🛣 Roadmap
187
+
188
+ ### v0.1.0
189
+
190
+ - ✅ PDF Support
191
+ - ✅ TXT Support
192
+ - ✅ JSON Support
193
+ - ✅ Semantic Search
194
+ - ✅ Gemini Question Answering
195
+ - ✅ FastAPI Server
196
+ - ✅ Persistent Indexing
197
+
198
+ ### Upcoming
199
+
200
+ - DOCX Support
201
+ - Markdown Support
202
+ - HTML Support
203
+ - Multi-document collections
204
+ - Multiple LLM providers
205
+ - Better chunking strategies
206
+ - CLI Support
207
+
208
+ ---
209
+
210
+ # 🤝 Contributing
211
+
212
+ Contributions, feature requests and bug reports are welcome.
213
+
214
+ Feel free to open an issue or submit a pull request.
215
+
216
+ ---
217
+
218
+ # 📄 License
219
+
220
+ MIT License
221
+
222
+ ---
223
+
224
+ 🧠 Built by the brain of **Mehul Dewan**. Powered by caffeine.
ragup-0.1.0/README.md ADDED
@@ -0,0 +1,185 @@
1
+ # 🚀 RagUp
2
+
3
+ > Build semantic search, AI-powered question answering, and FastAPI APIs from your documents in just a few lines of Python.
4
+
5
+ RagUp is an opinionated Python library that lets you turn documents into searchable AI knowledge bases with almost no setup.
6
+
7
+ ---
8
+
9
+ ## ✨ Features
10
+
11
+ - 📄 Supports PDF, TXT and JSON documents
12
+ - 🧠 Local embeddings using Sentence Transformers
13
+ - 🔍 Semantic Search
14
+ - 🤖 AI-powered Question Answering (Gemini)
15
+ - ⚡ FastAPI server with automatic Swagger UI
16
+ - 💾 Persistent indexing (no re-indexing if nothing changes)
17
+ - 🐍 Simple Python API
18
+
19
+ ---
20
+
21
+ ## 📦 Installation
22
+
23
+ ```bash
24
+ pip install ragup
25
+ ```
26
+
27
+ ---
28
+
29
+ ## ⚡ Quick Start
30
+
31
+ ```python
32
+ from ragup import Document
33
+
34
+ doc = Document("policy.pdf")
35
+
36
+ # Build the index
37
+ doc.ragup()
38
+
39
+ # Semantic Search
40
+ results = doc.search(
41
+ "refund policy"
42
+ )
43
+
44
+ print(results)
45
+
46
+ # AI Question Answering
47
+ answer = doc.ask(
48
+ "What is the refund policy?",
49
+ api_key="YOUR_GEMINI_API_KEY"
50
+ )
51
+
52
+ print(answer)
53
+
54
+ # Launch FastAPI
55
+ doc.serve(
56
+ api_key="YOUR_GEMINI_API_KEY"
57
+ )
58
+ ```
59
+
60
+ Open
61
+
62
+ ```
63
+ http://localhost:8085/docs
64
+ ```
65
+
66
+ to access the interactive Swagger UI.
67
+
68
+ ---
69
+
70
+ # 📚 Supported Documents
71
+
72
+ | Format | Supported |
73
+ |---------|-----------|
74
+ | PDF | ✅ |
75
+ | TXT | ✅ |
76
+ | JSON | ✅ |
77
+
78
+ ---
79
+
80
+ # 🔍 Semantic Search
81
+
82
+ ```python
83
+ results = doc.search(
84
+ "shipping charges",
85
+ top_k=3
86
+ )
87
+ ```
88
+
89
+ Returns the most relevant chunks from your document.
90
+
91
+ ---
92
+
93
+ # 🤖 AI Question Answering
94
+
95
+ ```python
96
+ answer = doc.ask(
97
+ "Summarize this document",
98
+ api_key="YOUR_GEMINI_API_KEY"
99
+ )
100
+ ```
101
+
102
+ RagUp retrieves relevant chunks and asks Gemini to answer using only the document context.
103
+
104
+ ---
105
+
106
+ # 🌐 FastAPI Server
107
+
108
+ ```python
109
+ doc.serve(
110
+ api_key="YOUR_GEMINI_API_KEY"
111
+ )
112
+ ```
113
+
114
+ Available endpoints
115
+
116
+ ```
117
+ POST /search
118
+ POST /ask
119
+ GET /health
120
+ GET /docs
121
+ ```
122
+
123
+ If no API key is supplied,
124
+
125
+ ```python
126
+ doc.serve()
127
+ ```
128
+
129
+ the `/ask` endpoint is automatically disabled.
130
+
131
+ ---
132
+
133
+ # 💾 Persistent Indexing
134
+
135
+ The first time you call
136
+
137
+ ```python
138
+ doc.ragup()
139
+ ```
140
+
141
+ RagUp creates a local index.
142
+
143
+ Subsequent calls reuse the cached index automatically if the document hasn't changed, making startup almost instantaneous.
144
+
145
+ ---
146
+
147
+ # 🛣 Roadmap
148
+
149
+ ### v0.1.0
150
+
151
+ - ✅ PDF Support
152
+ - ✅ TXT Support
153
+ - ✅ JSON Support
154
+ - ✅ Semantic Search
155
+ - ✅ Gemini Question Answering
156
+ - ✅ FastAPI Server
157
+ - ✅ Persistent Indexing
158
+
159
+ ### Upcoming
160
+
161
+ - DOCX Support
162
+ - Markdown Support
163
+ - HTML Support
164
+ - Multi-document collections
165
+ - Multiple LLM providers
166
+ - Better chunking strategies
167
+ - CLI Support
168
+
169
+ ---
170
+
171
+ # 🤝 Contributing
172
+
173
+ Contributions, feature requests and bug reports are welcome.
174
+
175
+ Feel free to open an issue or submit a pull request.
176
+
177
+ ---
178
+
179
+ # 📄 License
180
+
181
+ MIT License
182
+
183
+ ---
184
+
185
+ 🧠 Built by the brain of **Mehul Dewan**. Powered by caffeine.
@@ -0,0 +1,82 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "ragup"
7
+ version = "0.1.0"
8
+ description = "Build semantic search, question answering, and FastAPI-powered RAG applications in just a few lines of Python."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { text = "MIT" }
12
+
13
+ authors = [
14
+ { name="Mehul Dewan", email="mehul.work.17@gmail.com" }
15
+ ]
16
+
17
+ keywords = [
18
+ "rag",
19
+ "genai",
20
+ "llm",
21
+ "embeddings",
22
+ "semantic-search",
23
+ "vector-database",
24
+ "chromadb",
25
+ "fastapi",
26
+ "ai",
27
+ "python"
28
+ ]
29
+
30
+ classifiers = [
31
+ "Programming Language :: Python :: 3",
32
+ "Programming Language :: Python :: 3.10",
33
+ "Programming Language :: Python :: 3.11",
34
+ "Programming Language :: Python :: 3.12",
35
+ "License :: OSI Approved :: MIT License",
36
+ "Operating System :: OS Independent",
37
+ "Intended Audience :: Developers",
38
+ "Topic :: Software Development :: Libraries",
39
+ "Topic :: Scientific/Engineering :: Artificial Intelligence"
40
+ ]
41
+
42
+ dependencies = [
43
+ "pymupdf>=1.24.0",
44
+ "chromadb>=0.5.0",
45
+ "sentence-transformers>=3.0.0",
46
+ "fastapi>=0.115.0",
47
+ "uvicorn>=0.30.0",
48
+ "litellm>=1.40.0",
49
+ "pydantic>=2.8.0",
50
+ "numpy>=1.26.0",
51
+ "tqdm>=4.66.0",
52
+ "typing_extensions>=4.12.0"
53
+ ]
54
+
55
+ [project.optional-dependencies]
56
+ dev = [
57
+ "pytest>=8.0.0",
58
+ "black>=24.0.0",
59
+ "isort>=5.13.0",
60
+ "mypy>=1.10.0"
61
+ ]
62
+
63
+ [project.urls]
64
+ Homepage = "https://github.com/mehuldewan17/RagUp"
65
+ Repository = "https://github.com/mehuldewan17/RagUp"
66
+ Issues = "https://github.com/mehuldewan17/RagUp/issues"
67
+
68
+ [tool.setuptools]
69
+ include-package-data = true
70
+
71
+ [tool.setuptools.packages.find]
72
+ include = ["ragup*"]
73
+
74
+ [tool.black]
75
+ line-length = 88
76
+
77
+ [tool.isort]
78
+ profile = "black"
79
+
80
+ [tool.pytest.ini_options]
81
+ testpaths = ["tests"]
82
+ python_files = ["test_*.py"]
@@ -0,0 +1,7 @@
1
+ from .core.document import Document
2
+
3
+ __version__ = "1.0.0"
4
+
5
+ __all__ = [
6
+ "Document",
7
+ ]
@@ -0,0 +1,5 @@
1
+ from .server import RagUpServer
2
+
3
+ __all__ = [
4
+ "RagUpServer",
5
+ ]
@@ -0,0 +1,7 @@
1
+ """
2
+ FastAPI routes.
3
+ """
4
+
5
+ from fastapi import APIRouter
6
+
7
+ router = APIRouter()
@@ -0,0 +1,15 @@
1
+ """
2
+ Pydantic request models.
3
+ """
4
+
5
+ from pydantic import BaseModel
6
+
7
+
8
+ class SearchRequest(BaseModel):
9
+ query: str
10
+ top_k: int = 5
11
+
12
+
13
+ class AskRequest(BaseModel):
14
+ question: str
15
+ top_k: int = 5
@@ -0,0 +1,81 @@
1
+ """
2
+ FastAPI server for RagUp.
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ import uvicorn
8
+
9
+ from fastapi import FastAPI
10
+
11
+ from ..constants import (
12
+ DEFAULT_HOST,
13
+ DEFAULT_PORT,
14
+ )
15
+ from .schemas import (
16
+ AskRequest,
17
+ SearchRequest,
18
+ )
19
+
20
+
21
+ class RagUpServer:
22
+
23
+ def __init__(
24
+ self,
25
+ document,
26
+ api_key: str | None = None,
27
+ ):
28
+
29
+ self.document = document
30
+ self.api_key = api_key
31
+
32
+ self.app = FastAPI(
33
+ title="RagUp API",
34
+ version="1.0.0",
35
+ )
36
+
37
+ self._register_routes()
38
+
39
+ def _register_routes(self):
40
+
41
+ @self.app.get("/health")
42
+ def health():
43
+
44
+ return {
45
+ "status": "healthy"
46
+ }
47
+
48
+ @self.app.post("/search")
49
+ def search(request: SearchRequest):
50
+
51
+ return self.document.search(
52
+ query=request.query,
53
+ top_k=request.top_k,
54
+ )
55
+
56
+ if self.api_key:
57
+
58
+ @self.app.post("/ask")
59
+ def ask(request: AskRequest):
60
+
61
+ answer = self.document.ask(
62
+ question=request.question,
63
+ api_key=self.api_key,
64
+ top_k=request.top_k,
65
+ )
66
+
67
+ return {
68
+ "answer": answer
69
+ }
70
+
71
+ def run(
72
+ self,
73
+ host: str = DEFAULT_HOST,
74
+ port: int = DEFAULT_PORT,
75
+ ):
76
+
77
+ uvicorn.run(
78
+ self.app,
79
+ host=host,
80
+ port=port,
81
+ )
@@ -0,0 +1,9 @@
1
+
2
+
3
+ from .base import BaseChunker
4
+ from .recursive import RecursiveChunker
5
+
6
+ __all__ = [
7
+ "BaseChunker",
8
+ "RecursiveChunker",
9
+ ]
@@ -0,0 +1,36 @@
1
+ """
2
+ Base interface for all text chunkers.
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ from abc import ABC, abstractmethod
8
+
9
+
10
+ class BaseChunker(ABC):
11
+ """
12
+ Base class for all chunking strategies.
13
+ """
14
+
15
+ def __init__(
16
+ self,
17
+ chunk_size: int = 500,
18
+ overlap: int = 50,
19
+ ):
20
+ self.chunk_size = chunk_size
21
+ self.overlap = overlap
22
+
23
+ @abstractmethod
24
+ def split(self, text: str) -> list[str]:
25
+ """
26
+ Split text into chunks.
27
+
28
+ Parameters
29
+ ----------
30
+ text : str
31
+
32
+ Returns
33
+ -------
34
+ list[str]
35
+ """
36
+ raise NotImplementedError