ragspark 0.3.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 (43) hide show
  1. ragspark-0.3.0/.github/agents/bmad-agent-analyst.agent.md +5 -0
  2. ragspark-0.3.0/.github/agents/bmad-agent-architect.agent.md +5 -0
  3. ragspark-0.3.0/.github/agents/bmad-agent-builder.agent.md +5 -0
  4. ragspark-0.3.0/.github/agents/bmad-agent-dev.agent.md +5 -0
  5. ragspark-0.3.0/.github/agents/bmad-agent-pm.agent.md +5 -0
  6. ragspark-0.3.0/.github/agents/bmad-agent-ux-designer.agent.md +5 -0
  7. ragspark-0.3.0/.github/agents/bmad-cis-agent-brainstorming-coach.agent.md +5 -0
  8. ragspark-0.3.0/.github/agents/bmad-cis-agent-creative-problem-solver.agent.md +5 -0
  9. ragspark-0.3.0/.github/agents/bmad-cis-agent-design-thinking-coach.agent.md +5 -0
  10. ragspark-0.3.0/.github/agents/bmad-cis-agent-innovation-strategist.agent.md +5 -0
  11. ragspark-0.3.0/.github/agents/bmad-cis-agent-presentation-master.agent.md +5 -0
  12. ragspark-0.3.0/.github/agents/bmad-cis-agent-storyteller.agent.md +5 -0
  13. ragspark-0.3.0/.github/agents/bmad-tea.agent.md +5 -0
  14. ragspark-0.3.0/.gitignore +37 -0
  15. ragspark-0.3.0/PKG-INFO +258 -0
  16. ragspark-0.3.0/RAGSPARK_DOCUMENTATION.md +275 -0
  17. ragspark-0.3.0/README.md +225 -0
  18. ragspark-0.3.0/demo_parser.py +72 -0
  19. ragspark-0.3.0/output/implementation-artifacts/deferred-work.md +4 -0
  20. ragspark-0.3.0/output/implementation-artifacts/spec-raglib-full-rag-suite.md +39 -0
  21. ragspark-0.3.0/pyproject.toml +61 -0
  22. ragspark-0.3.0/ragspark/__init__.py +75 -0
  23. ragspark-0.3.0/ragspark/chunker/__init__.py +878 -0
  24. ragspark-0.3.0/ragspark/cli.py +122 -0
  25. ragspark-0.3.0/ragspark/embedder/__init__.py +335 -0
  26. ragspark-0.3.0/ragspark/llm/__init__.py +812 -0
  27. ragspark-0.3.0/ragspark/parser/__init__.py +147 -0
  28. ragspark-0.3.0/ragspark/parser/cleaner.py +149 -0
  29. ragspark-0.3.0/ragspark/parser/core.py +303 -0
  30. ragspark-0.3.0/ragspark/parser/engines.py +410 -0
  31. ragspark-0.3.0/ragspark/parser/legal_regex.py +635 -0
  32. ragspark-0.3.0/ragspark/parser/models.py +266 -0
  33. ragspark-0.3.0/ragspark/prompt_eng/__init__.py +897 -0
  34. ragspark-0.3.0/ragspark/py.typed +2 -0
  35. ragspark-0.3.0/ragspark/rag/__init__.py +814 -0
  36. ragspark-0.3.0/ragspark/reranker/__init__.py +183 -0
  37. ragspark-0.3.0/ragspark/ui/__init__.py +734 -0
  38. ragspark-0.3.0/ragspark/vectordb/__init__.py +704 -0
  39. ragspark-0.3.0/tests/test_chunker_advanced.py +115 -0
  40. ragspark-0.3.0/tests/test_multilingual.py +91 -0
  41. ragspark-0.3.0/tests/test_new_features.py +87 -0
  42. ragspark-0.3.0/tests/test_parser.py +341 -0
  43. ragspark-0.3.0/uv.lock +5887 -0
@@ -0,0 +1,5 @@
1
+ ---
2
+ description: Business analyst for market research, competitive analysis, and requirements. Use when the user asks to talk to Mary or requests the business analyst
3
+ ---
4
+
5
+ LOAD the FULL {project-root}/.agents/skills/bmad-agent-analyst/SKILL.md, READ its entire contents and follow its directions exactly!
@@ -0,0 +1,5 @@
1
+ ---
2
+ description: System architect and technical design leader. Use when the user asks to talk to Winston or requests the architect
3
+ ---
4
+
5
+ LOAD the FULL {project-root}/.agents/skills/bmad-agent-architect/SKILL.md, READ its entire contents and follow its directions exactly!
@@ -0,0 +1,5 @@
1
+ ---
2
+ description: "Builds, edits or analyzes Agent Skills through conversational discovery. Use when the user requests to \"Create an Agent\", \"Analyze an Agent\" or \"Edit an Agent\"."
3
+ ---
4
+
5
+ LOAD the FULL {project-root}/.agents/skills/bmad-agent-builder/SKILL.md, READ its entire contents and follow its directions exactly!
@@ -0,0 +1,5 @@
1
+ ---
2
+ description: Senior software engineer who implements stories and code changes. Use when the user asks to talk to Amelia or requests the developer agent
3
+ ---
4
+
5
+ LOAD the FULL {project-root}/.agents/skills/bmad-agent-dev/SKILL.md, READ its entire contents and follow its directions exactly!
@@ -0,0 +1,5 @@
1
+ ---
2
+ description: Product manager for PRD creation and requirements discovery. Use when the user asks to talk to John or requests the product manager
3
+ ---
4
+
5
+ LOAD the FULL {project-root}/.agents/skills/bmad-agent-pm/SKILL.md, READ its entire contents and follow its directions exactly!
@@ -0,0 +1,5 @@
1
+ ---
2
+ description: UX designer and UI specialist. Use when the user asks to talk to Sally or requests the UX designer
3
+ ---
4
+
5
+ LOAD the FULL {project-root}/.agents/skills/bmad-agent-ux-designer/SKILL.md, READ its entire contents and follow its directions exactly!
@@ -0,0 +1,5 @@
1
+ ---
2
+ description: Elite brainstorming specialist for facilitated ideation sessions. Use when the user asks to talk to Carson or requests the Brainstorming Specialist.
3
+ ---
4
+
5
+ LOAD the FULL {project-root}/.agents/skills/bmad-cis-agent-brainstorming-coach/SKILL.md, READ its entire contents and follow its directions exactly!
@@ -0,0 +1,5 @@
1
+ ---
2
+ description: Master problem solver for systematic problem-solving methodologies. Use when the user asks to talk to Dr. Quinn or requests the Master Problem Solver.
3
+ ---
4
+
5
+ LOAD the FULL {project-root}/.agents/skills/bmad-cis-agent-creative-problem-solver/SKILL.md, READ its entire contents and follow its directions exactly!
@@ -0,0 +1,5 @@
1
+ ---
2
+ description: Design thinking maestro for human-centered design processes. Use when the user asks to talk to Maya or requests the Design Thinking Maestro.
3
+ ---
4
+
5
+ LOAD the FULL {project-root}/.agents/skills/bmad-cis-agent-design-thinking-coach/SKILL.md, READ its entire contents and follow its directions exactly!
@@ -0,0 +1,5 @@
1
+ ---
2
+ description: Disruptive innovation oracle for business model innovation and strategic disruption. Use when the user asks to talk to Victor or requests the Disruptive Innovation Oracle.
3
+ ---
4
+
5
+ LOAD the FULL {project-root}/.agents/skills/bmad-cis-agent-innovation-strategist/SKILL.md, READ its entire contents and follow its directions exactly!
@@ -0,0 +1,5 @@
1
+ ---
2
+ description: Visual communication and presentation expert for slide decks, pitch decks, and visual storytelling. Use when the user asks to talk to Caravaggio or requests the Presentation Expert.
3
+ ---
4
+
5
+ LOAD the FULL {project-root}/.agents/skills/bmad-cis-agent-presentation-master/SKILL.md, READ its entire contents and follow its directions exactly!
@@ -0,0 +1,5 @@
1
+ ---
2
+ description: Master storyteller for compelling narratives using proven frameworks. Use when the user asks to talk to Sophia or requests the Master Storyteller.
3
+ ---
4
+
5
+ LOAD the FULL {project-root}/.agents/skills/bmad-cis-agent-storyteller/SKILL.md, READ its entire contents and follow its directions exactly!
@@ -0,0 +1,5 @@
1
+ ---
2
+ description: Master Test Architect and Quality Advisor. Use when the user asks to talk to Murat or requests the Test Architect.
3
+ ---
4
+
5
+ LOAD the FULL {project-root}/.agents/skills/bmad-tea/SKILL.md, READ its entire contents and follow its directions exactly!
@@ -0,0 +1,37 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # Virtual environments
7
+ .venv/
8
+ venv/
9
+ env/
10
+
11
+ # Distribution / packaging
12
+ dist/
13
+ build/
14
+ *.egg-info/
15
+
16
+ # Pytest / test caches
17
+ .pytest_cache/
18
+ .coverage
19
+
20
+ # Local ChromaDB / generated files
21
+ *.chroma.json
22
+ chroma_db/
23
+ .ragspark_store/
24
+ sample_legal_judgment.pdf
25
+
26
+ # Agent / BMAD local tooling
27
+ .agent/
28
+ .agents/
29
+ .cline/
30
+ .opencode/
31
+ _bmad/
32
+ _bmad-output/
33
+
34
+ # Finetuning specs / proposals
35
+ *FINETUN*
36
+ *.html
37
+
@@ -0,0 +1,258 @@
1
+ Metadata-Version: 2.5
2
+ Name: ragspark
3
+ Version: 0.3.0
4
+ Summary: Unified One-Command Industry RAG Pipeline Library with Hybrid Search, Query Rewriting, Multi-VectorDB, and Studio UI
5
+ License: MIT
6
+ Keywords: chromadb,chunking,hybrid-search,llm,pdf-parser,prompt-engineering,query-rewriting,rag,vector-database
7
+ Classifier: Development Status :: 4 - Beta
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Intended Audience :: Education
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Classifier: Topic :: Text Processing :: Indexing
18
+ Requires-Python: >=3.10
19
+ Requires-Dist: pdfplumber>=0.11.0
20
+ Requires-Dist: pymupdf>=1.24.0
21
+ Requires-Dist: pypdf>=4.0.0
22
+ Provides-Extra: dev
23
+ Requires-Dist: build>=1.2.0; extra == 'dev'
24
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
25
+ Requires-Dist: twine>=5.0.0; extra == 'dev'
26
+ Provides-Extra: full
27
+ Requires-Dist: chromadb>=0.5.0; extra == 'full'
28
+ Requires-Dist: google-genai>=0.3.0; extra == 'full'
29
+ Requires-Dist: ipywidgets>=8.1.0; extra == 'full'
30
+ Requires-Dist: openai>=1.30.0; extra == 'full'
31
+ Requires-Dist: sentence-transformers>=3.0.0; extra == 'full'
32
+ Description-Content-Type: text/markdown
33
+
34
+ # ⚡ `ragspark` — Unified One-Command Industry RAG Pipeline Library
35
+
36
+ [![PyPI version](https://img.shields.io/badge/pypi-v0.3.0-blue.svg)](https://pypi.org/project/ragspark/)
37
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-brightgreen.svg)](https://www.python.org/downloads/)
38
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
39
+
40
+ **`ragspark`** is an enterprise-ready, developer-friendly Python library that collapses the entire Retrieval-Augmented Generation (RAG) stack into **clean 1-line commands**. From multi-format ingestion with 4-layer OCR fallbacks and 15+ chunking strategies, to hybrid BM25+vector search, flash re-ranking, multilingual support, multi-turn chat memory, and sentence-level evidence citations.
41
+
42
+ Works out of the box across any industry domain: Finance, Tech, Healthcare, E-Commerce, Legal, and Customer Support.
43
+
44
+ ---
45
+
46
+ ## 📦 Installation
47
+
48
+ ```bash
49
+ pip install ragspark
50
+ ```
51
+
52
+ To install with all vector database, OCR, and LLM backends:
53
+ ```bash
54
+ pip install "ragspark[full]"
55
+ ```
56
+
57
+ ---
58
+
59
+ ## 🚀 1-Minute Quickstart
60
+
61
+ ```python
62
+ import ragspark
63
+
64
+ # 1. Spin up an entire RAG pipeline from any PDF, Word doc, Markdown, CSV, or JSON
65
+ bot = ragspark.rag.create("annual_report.pdf")
66
+
67
+ # 2. Ask questions with instant retrieval, re-ranking, and grounded generation
68
+ res = bot.ask("What were the key drivers of Q4 revenue growth?")
69
+ print(res.answer)
70
+
71
+ # 3. View sentence-level verifiable evidence citations
72
+ print(res.format_citations())
73
+ ```
74
+
75
+ ---
76
+
77
+ ## âš¡ Core Capabilities & Feature Matrix
78
+
79
+ | Capability | What It Does | Code Example |
80
+ | :--- | :--- | :--- |
81
+ | **15 Chunking Strategies** | Recursive, semantic, table-aware, code-aware, contextual, adaptive, etc. | `chunker.chunk(doc, strategy="table_aware")` |
82
+ | **Multi-Strategy Combinations**| Combine multiple chunkers (multi-resolution, ensemble, chain, interleave) | `chunker.combine([c1, c2], mode="multi_resolution")` |
83
+ | **Multilingual Engine** | One-parameter language switching with automatic script detection | `bot.ask("What is the refund policy?", language="Hindi")` |
84
+ | **Hybrid Retrieval** | BM25 keyword matching fused with dense vector semantic search (RRF) | `bot.ask(q, hybrid=True, alpha=0.65)` |
85
+ | **Flash Cross-Encoder Re-Ranker**| Re-score top candidate passages for maximum relevance before LLM generation | `bot.ask(q, rerank=True, reranker_top_k=3)` |
86
+ | **Multi-Turn Chat Memory** | Stateful conversation tracking with sliding context memory | `bot.chat("What was our profit?"); bot.chat("How does that compare to 2024?")` |
87
+ | **Sentence-Level Citations** | Fine-grained passage verification with exact page, chunk ID, and snippet | `print(res.format_citations())` |
88
+ | **4-Layer OCR Fallback** | Native text $\to$ RapidOCR $\to$ PyTesseract $\to$ Gemini Vision AI | `parser.parse("scanned_receipt.pdf")` |
89
+ | **Instant `<0.05s` Disk Reload** | Auto-persisted indices on disk; reload without re-parsing or re-embedding | `bot = ragspark.rag.load()` |
90
+ | **Built-in UI Studio** | Inline Jupyter/Colab widget or full standalone Streamlit browser app | `ui.notebook_chat(bot)` or `ui.launch()` |
91
+
92
+ ---
93
+
94
+ ## 🛠 Deep Dive: Feature Highlights
95
+
96
+ ### 1. 15 Advanced Chunking Strategies & Combinations
97
+
98
+ No single chunking strategy works for all data types. `ragspark` provides 15 specialized strategies and multi-strategy combiners:
99
+
100
+ ```python
101
+ from ragspark import chunker, parser
102
+
103
+ doc = parser.parse("technical_spec.pdf")
104
+
105
+ # Specialized Strategies
106
+ table_chunks = chunker.chunk(doc, strategy="table_aware") # Preserves Markdown/HTML table integrity
107
+ code_chunks = chunker.chunk(doc, strategy="code_aware") # Preserves AST functions & classes
108
+ ctx_chunks = chunker.chunk(doc, strategy="contextual") # Prepends document-level contextual headers
109
+ adapt_chunks = chunker.chunk(doc, strategy="adaptive") # Dynamically splits based on document density
110
+
111
+ # Multi-Strategy Combinations
112
+ # 1. Multi-Resolution (Hierarchical parent-child indexing for precise search + broad LLM context)
113
+ multi_res = chunker.combine([doc], mode="multi_resolution", small_chunk=150, large_chunk=600)
114
+
115
+ # 2. Ensemble (Union of semantic + recursive chunkers with deduplication)
116
+ ensemble_chunks = chunker.combine([table_chunks, code_chunks], mode="ensemble")
117
+
118
+ # 3. Interleave (Round-robin interleaving across multiple sources)
119
+ interleaved = chunker.combine([table_chunks, code_chunks], mode="interleave")
120
+ ```
121
+
122
+ ### 2. Multilingual RAG in 1 Parameter
123
+
124
+ Deliver localized responses in any language without rebuilding prompt pipelines. `ragspark` detects Unicode scripts and injects native language directives:
125
+
126
+ ```python
127
+ # Force output language explicitly
128
+ res = bot.ask("Summarize the main compliance requirements", language="Spanish")
129
+ print(res.answer)
130
+
131
+ res = bot.ask("Summarize the main compliance requirements", language="Hindi")
132
+ print(res.answer)
133
+
134
+ # Or detect input question language automatically
135
+ res = bot.ask("Comment fonctionne le processus d'onboarding?", language="auto")
136
+ print(res.answer)
137
+ ```
138
+
139
+ ### 3. Hybrid BM25 + Dense Vector Search & Flash Re-Ranker
140
+
141
+ Avoid semantic vector drift on exact acronyms, serial numbers, and entities with Reciprocal Rank Fusion (RRF) and Flash Re-ranking:
142
+
143
+ ```python
144
+ # Hybrid Search + Cross-Encoder Flash Re-ranking in 1 call:
145
+ res = bot.ask(
146
+ "What is error code E-8492 in Section 4.2?",
147
+ hybrid=True, # BM25 + Dense vector search
148
+ alpha=0.65, # Balance between semantic (0.65) and keyword (0.35)
149
+ rerank=True, # Cross-encoder passage re-ranking
150
+ reranker_top_k=3, # Send only the top 3 verified passages to the LLM
151
+ )
152
+ print(res.answer)
153
+ ```
154
+
155
+ ### 4. Stateful Multi-Turn Conversational Chat
156
+
157
+ Build chatbots that remember previous turns and resolve conversational pronouns:
158
+
159
+ ```python
160
+ # Turn 1
161
+ ans1 = bot.chat("Who is the CEO of Acme Corp?")
162
+ print(ans1.answer)
163
+
164
+ # Turn 2 (Resolves 'he' based on conversation history)
165
+ ans2 = bot.chat("When did he join the company?")
166
+ print(ans2.answer)
167
+
168
+ # Reset conversation history anytime
169
+ bot.clear_history()
170
+ ```
171
+
172
+ ### 5. Sentence-Level Evidence Citations
173
+
174
+ Guarantee explainability and prevent hallucination with verifiable sentence-level citations:
175
+
176
+ ```python
177
+ res = bot.ask("What are the quarterly milestone deliverables?")
178
+
179
+ # Formatted citations string
180
+ print(res.format_citations())
181
+ # Output:
182
+ # [1] annual_report.pdf (Page 12, Chunk 84): "Milestone deliverable for Q3 entails API v2 release..."
183
+ # [2] annual_report.pdf (Page 15, Chunk 97): "Q4 milestones target global deployment across 4 regions..."
184
+
185
+ # Structured citation inspection
186
+ for cite in res.citations:
187
+ print(f"Source: {cite['source']} (Page {cite['page']}) -> {cite['sentence']}")
188
+ ```
189
+
190
+ ### 6. Interactive Studio UI (Jupyter & Web)
191
+
192
+ Test and demo your RAG pipelines with zero frontend boilerplate:
193
+
194
+ ```python
195
+ from ragspark import ui
196
+
197
+ # 1. Inside Jupyter Notebook / Google Colab (Interactive widget):
198
+ ui.notebook_chat(bot)
199
+
200
+ # 2. Or launch the standalone web browser app:
201
+ ui.launch(port=8501)
202
+ ```
203
+
204
+ ---
205
+
206
+ ## 💻 Command Line Interface (CLI)
207
+
208
+ `ragspark` comes equipped with a powerful CLI:
209
+
210
+ ```bash
211
+ # Launch interactive web studio
212
+ ragspark ui --port 8501
213
+
214
+ # Ingest and parse any document to clean JSON
215
+ ragspark parse report.pdf --mode auto --out parsed.json
216
+
217
+ # Instant terminal Q&A on any document
218
+ ragspark ask system_manual.pdf "How do I configure the API token?"
219
+ ```
220
+
221
+ ---
222
+
223
+ ## 📑 Modular Architecture
224
+
225
+ If you prefer building custom pipelines step-by-step, all modular components are decoupled:
226
+
227
+ ```python
228
+ from ragspark import parser, chunker, vectordb, prompt_eng, llm, reranker
229
+
230
+ # Step 1: Ingestion
231
+ doc = parser.parse("document.pdf")
232
+
233
+ # Step 2: Chunking
234
+ chunks = chunker.chunk(doc, strategy="table_aware", chunk_size=500)
235
+
236
+ # Step 3: Vector Storage
237
+ db = vectordb.store(chunks, backend="chroma", collection_name="knowledge_base")
238
+
239
+ # Step 4: Hybrid Retrieval
240
+ hits = db.hybrid_search("financial forecast", top_k=10, alpha=0.7)
241
+
242
+ # Step 5: Flash Re-ranking
243
+ ranker = reranker.Reranker()
244
+ top_hits = ranker.rerank("financial forecast", hits, top_k=3)
245
+
246
+ # Step 6: Prompt Engineering
247
+ prompt = prompt_eng.build(top_hits, query="financial forecast", technique="chain_of_thought")
248
+
249
+ # Step 7: Generation
250
+ answer = llm.generate(prompt, provider="gemini", model="gemini 3.8 flash")
251
+ print(answer.text)
252
+ ```
253
+
254
+ ---
255
+
256
+ ## 📄 License
257
+
258
+ MIT License. Built for production-grade Retrieval-Augmented Generation across all domains.