Complete RAG with built-in Ollama + FastAPI + Swagger - Zero Config!
Project description
🚀 UltraRAG - Complete Unified Package
The ONLY RAG package you need!
✅ Revolutionary RAG engine
✅ Built-in Ollama integration
✅ Built-in FastAPI + Swagger UI
✅ ONE command to start!
✅ Zero configuration needed!
🎯 Quick Start (2 Commands!)
Step 1: Install
pip install ultrarag[server]
Step 2: Start Server
ultrarag serve --ollama-host localhost --ollama-model llama3.2
Open Swagger UI:
http://localhost:8000/docs
🎉 DONE! RAG chatbot ready!
📚 Three Ways to Use
Method 1: Web Server (with Swagger UI)
# Start server
ultrarag serve --ollama-host localhost --ollama-model llama3.2
# Open browser → http://localhost:8000/docs
# Upload documents, ask questions via Swagger!
Method 2: Python Code (Simple)
from ultrarag import RAG
# Create RAG
rag = RAG()
# Add document
rag.add("Python is a programming language created by Guido van Rossum.")
# Ask question
answer = rag.ask("Who created Python?")
print(answer)
# Output: "Python is a programming language created by Guido van Rossum."
Method 3: Python Code (with Ollama)
from ultrarag import RAG, OllamaLLM
# Initialize Ollama
llm = OllamaLLM(host="localhost", port=11434, model="llama3.2")
# Create RAG
rag = RAG()
# Add document
rag.add("Python is used for AI, web development, and data science.")
# Get context
query = "What is Python used for?"
query_analysis = rag.query_processor.analyze(query)
chunks = rag.retriever.retrieve(rag.chunks, query_analysis, top_k=3)
context = " ".join([c.text for c in chunks])
# Generate with LLM
prompt = f"Based on: {context}\n\nQuestion: {query}\n\nAnswer:"
answer = llm.generate(prompt)
print(answer)
🎯 Complete Example (CLI Server)
Prerequisites
# Install Ollama
curl -fsSL https://ollama.com/install.sh | sh
# Start Ollama
ollama serve
# Pull model (in another terminal)
ollama pull llama3.2
Install UltraRAG
pip install ultrarag[server]
Start Server
ultrarag serve --ollama-host localhost --ollama-model llama3.2
Output:
🚀 Starting UltraRAG Server...
📡 Ollama: localhost:11434
🤖 Model: llama3.2
📚 Swagger UI: http://localhost:8000/docs
Use Swagger UI
-
Open:
http://localhost:8000/docs -
Upload document:
- Click
POST /upload - Choose file
- Execute
- Click
-
Ask question:
- Click
POST /query - Enter:
{ "question": "Your question?", "use_llm": true }
- Execute
- Click
-
Get answer! ✅
🔧 Configuration Options
Server Command
ultrarag serve \
--ollama-host localhost \ # Ollama IP
--ollama-port 11434 \ # Ollama port
--ollama-model llama3.2 \ # Model name
--port 8000 # Server port
Different Ollama Machine
ultrarag serve --ollama-host 192.168.1.100 --ollama-model llama3.2
📊 API Endpoints
| Endpoint | Method | Description |
|---|---|---|
/docs |
GET | Swagger UI |
/upload |
POST | Upload file |
/upload-text |
POST | Upload text |
/query |
POST | Ask question |
/stats |
GET | Statistics |
/clear |
DELETE | Clear documents |
💻 Python API
Basic Usage
from ultrarag import RAG
rag = RAG()
rag.add("document text...")
answer = rag.ask("question?")
With Ollama
from ultrarag import RAG, OllamaLLM
llm = OllamaLLM(host="localhost", model="llama3.2")
rag = RAG()
# Test Ollama
if llm.test():
print("✅ Ollama connected")
else:
print("❌ Ollama not available")
# Add documents
rag.add("Your documents...")
# Generate answer
chunks = rag.retriever.retrieve(rag.chunks, query_analysis, top_k=3)
context = " ".join([c.text for c in chunks])
answer = llm.generate(f"Context: {context}\n\nQuestion: {question}")
Advanced Usage
# Custom configuration
rag = RAG(
min_chunk_completeness=0.85,
min_grounding_score=0.85
)
# Add with metadata
rag.add("text...", metadata={"source": "doc1.pdf"})
# Detailed response
response = rag.ask("question?", explain=True)
print(f"Answer: {response.answer}")
print(f"Confidence: {response.confidence}")
print(f"Grounding: {response.grounding_score}")
print(f"Verdict: {response.metadata['verdict']}")
# Statistics
stats = rag.get_stats()
print(f"Total chunks: {stats['total_chunks']}")
🎯 Installation Options
Minimal (RAG only)
pip install ultrarag
Use in Python code only (no web server)
Full (RAG + Web Server)
pip install ultrarag[server]
Includes FastAPI + Swagger UI
From Source
git clone https://github.com/kumar123ips/ultrarag
cd ultrarag
pip install -e .[server]
🔥 Features
Revolutionary RAG Components
✅ AtomicChunk - Guaranteed completeness (ICS ≥ 0.75)
✅ QueryDNA - Multi-dimensional query analysis
✅ AdaptiveRetriever - Intent-based retrieval
✅ ProvenAnswer - Mathematical validation
✅ Zero Dependencies - Core package is pure Python!
Built-in Integrations
✅ Ollama - Local LLM support
✅ FastAPI - Production web server
✅ Swagger UI - Interactive API docs
✅ CLI - One command to start!
📝 License
MIT License - see LICENSE
👤 Author
Abhishek Kumar
Email: ipsabhi420@gmail.com
GitHub: @kumar123ips
🎉 Success!
The ONLY RAG package you need!
pip install ultrarag[server]
ultrarag serve --ollama-model llama3.2
That's it! 🚀
Made with ❤️ by Abhishek Kumar
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ultrarag-1.0.0.tar.gz.
File metadata
- Download URL: ultrarag-1.0.0.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0af3e0d6007efa265e449be13f53bf3b84c8e19dacaad5c747dfae6cf0b5b5ca
|
|
| MD5 |
60cccb322b3c2fe13f8d5179a472d084
|
|
| BLAKE2b-256 |
c4e46461e0c67e5790cc9077a9b74b668f802dd1205281c48cff88365d600252
|
File details
Details for the file ultrarag-1.0.0-py3-none-any.whl.
File metadata
- Download URL: ultrarag-1.0.0-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4337c89cebeb81c9a23c405c1fbbf9c1e2ebdb11c0e70c06b5767fe6c8ea1cb6
|
|
| MD5 |
99fab8d7a9023a75f25929b449c98dfd
|
|
| BLAKE2b-256 |
314f8ecaafbf94b01fddc89cc15b1829173bae3eec0665ae78ca64bf2203bf60
|