Spaces:
Sleeping
Sleeping
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# π ContextHub β Multimodal RAG Intelligence Platform
|
| 2 |
|
| 3 |
<div align="center">
|
| 4 |
|
| 5 |

|
| 6 |
-

|
| 8 |

|
| 9 |

|
| 10 |
|
|
@@ -16,8 +27,9 @@
|
|
| 16 |
|
| 17 |
## π What is ContextHub?
|
| 18 |
|
| 19 |
-
ContextHub is a **Retrieval-Augmented Generation (RAG)** platform
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
---
|
| 23 |
|
|
@@ -25,174 +37,59 @@ Unlike general-purpose AI, ContextHub answers **only from your uploaded content*
|
|
| 25 |
|
| 26 |
| Mode | Input | Model Used |
|
| 27 |
|------|-------|-----------|
|
| 28 |
-
| π PDF Analysis | Upload any PDF | Groq β LLaMA 3.3
|
| 29 |
-
| πΌοΈ Image Intelligence | JPG / PNG | Google Gemini Vision |
|
| 30 |
-
| π Web Intelligence |
|
| 31 |
-
| π₯ YouTube Intelligence | YouTube URL | Groq β LLaMA 3.3
|
| 32 |
|
| 33 |
-
- π§ **Nomic Embeddings** β semantic vector search
|
| 34 |
-
- π¦ **Pinecone** β isolated namespaces per source
|
| 35 |
-
- β‘ **Groq** β ultra-fast LLM inference
|
| 36 |
-
-
|
| 37 |
-
- π₯οΈ **Streamlit** β clean tabbed UI with session management
|
| 38 |
|
| 39 |
---
|
| 40 |
|
| 41 |
-
## π§ Architecture
|
| 42 |
|
| 43 |
-
|
| 44 |
-
```
|
| 45 |
-
Input β Text Extraction β Chunking β Nomic Embeddings
|
| 46 |
-
β Pinecone (isolated namespace) β Similarity Search
|
| 47 |
-
β Top-K Chunks β Groq LLM β Answer
|
| 48 |
-
```
|
| 49 |
-
|
| 50 |
-
### Image β Vision Pipeline
|
| 51 |
-
```
|
| 52 |
-
Image Upload β Base64 Encode β Gemini Vision API β Answer
|
| 53 |
-
```
|
| 54 |
-
|
| 55 |
-
### URL β Web Pipeline
|
| 56 |
-
```
|
| 57 |
-
URL β BeautifulSoup Scraping β Groq LLM β Answer
|
| 58 |
-
```
|
| 59 |
-
|
| 60 |
-
---
|
| 61 |
|
| 62 |
-
##
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
β βββ main.py # FastAPI server β all routes & RAG logic
|
| 69 |
-
β βββ .env # API keys (never commit this)
|
| 70 |
-
β
|
| 71 |
-
βββ frontend/
|
| 72 |
-
β βββ app.py # Streamlit UI β tabs, session state, previews
|
| 73 |
-
β
|
| 74 |
-
βββ requirements.txt # All Python dependencies
|
| 75 |
-
βββ run.sh # One-command startup script
|
| 76 |
-
βββ .gitignore
|
| 77 |
-
βββ README.md
|
| 78 |
-
```
|
| 79 |
|
| 80 |
---
|
| 81 |
|
| 82 |
-
##
|
| 83 |
-
|
| 84 |
-
### 1. Clone the Repository
|
| 85 |
-
|
| 86 |
-
```bash
|
| 87 |
-
git clone https://github.com/varshasharma01/Context-Hub.git
|
| 88 |
-
cd context-hub
|
| 89 |
-
```
|
| 90 |
-
|
| 91 |
-
### 2. Install Dependencies
|
| 92 |
-
|
| 93 |
-
```bash
|
| 94 |
-
pip install -r requirements.txt
|
| 95 |
-
```
|
| 96 |
-
|
| 97 |
-
### 3. Configure Environment Variables
|
| 98 |
-
|
| 99 |
-
Create a `.env` file inside the `backend/` folder:
|
| 100 |
-
|
| 101 |
-
```env
|
| 102 |
-
GROQ_API_KEY=your_groq_api_key
|
| 103 |
-
GEMINI_API_KEY=your_gemini_api_key
|
| 104 |
-
PINECONE_API_KEY=your_pinecone_api_key
|
| 105 |
-
NOMIC_API_KEY=your_nomic_api_key
|
| 106 |
-
```
|
| 107 |
-
|
| 108 |
-
> **Get your keys from:**
|
| 109 |
-
> - Groq β https://console.groq.com
|
| 110 |
-
> - Gemini β https://aistudio.google.com
|
| 111 |
-
> - Pinecone β https://app.pinecone.io
|
| 112 |
-
> - Nomic β https://atlas.nomic.ai
|
| 113 |
|
| 114 |
-
|
| 115 |
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
``
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
- βοΈ FastAPI backend β `http://localhost:8000`
|
| 123 |
-
- π₯οΈ Streamlit frontend β `http://localhost:8501`
|
| 124 |
-
|
| 125 |
-
> **Or run manually in two terminals:**
|
| 126 |
-
> ```bash
|
| 127 |
-
> # Terminal 1
|
| 128 |
-
> uvicorn backend.main:app --reload
|
| 129 |
-
>
|
| 130 |
-
> # Terminal 2
|
| 131 |
-
> streamlit run frontend/app.py
|
| 132 |
-
> ```
|
| 133 |
-
|
| 134 |
-
---
|
| 135 |
-
|
| 136 |
-
## π API Endpoints
|
| 137 |
-
|
| 138 |
-
| Method | Endpoint | Description |
|
| 139 |
-
|--------|----------|-------------|
|
| 140 |
-
| `POST` | `/upload` | Upload & index a PDF |
|
| 141 |
-
| `POST` | `/query` | Query the indexed PDF |
|
| 142 |
-
| `POST` | `/process-image` | Upload & store an image |
|
| 143 |
-
| `POST` | `/query-image` | Query the image via Gemini |
|
| 144 |
-
| `POST` | `/process-url` | Scrape & store a webpage |
|
| 145 |
-
| `POST` | `/query-url` | Query the webpage content |
|
| 146 |
-
| `POST` | `/process-youtube` | Fetch & index YouTube transcript |
|
| 147 |
-
| `POST` | `/query-youtube` | Query the video transcript |
|
| 148 |
|
| 149 |
---
|
| 150 |
|
| 151 |
## π οΈ Tech Stack
|
| 152 |
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
| Embeddings | Nomic Embed Text v1 / Vision v1.5 |
|
| 160 |
-
| Vector Database | Pinecone |
|
| 161 |
-
| PDF Parsing | PyMuPDF (fitz) |
|
| 162 |
-
| Web Scraping | BeautifulSoup4 |
|
| 163 |
-
| Transcripts | youtube-transcript-api |
|
| 164 |
-
|
| 165 |
-
---
|
| 166 |
-
|
| 167 |
-
## β‘ Key Highlights
|
| 168 |
-
|
| 169 |
-
- **True multimodal RAG** β 4 input types in one platform
|
| 170 |
-
- **Namespace isolation** β each source gets its own Pinecone namespace, zero data bleed between uploads
|
| 171 |
-
- **Session-aware UI** β answers clear on new uploads, no stale responses
|
| 172 |
-
- **Dual AI providers** β Groq for speed, Gemini for vision
|
| 173 |
-
- **One-command startup** β `run.sh` boots both servers together
|
| 174 |
-
|
| 175 |
-
---
|
| 176 |
-
|
| 177 |
-
## π Future Improvements
|
| 178 |
-
|
| 179 |
-
- [ ] Chat history with memory
|
| 180 |
-
- [ ] Multi-document support (query across multiple PDFs)
|
| 181 |
-
- [ ] YouTube timestamp-based answers
|
| 182 |
-
- [ ] Streaming responses
|
| 183 |
-
- [ ] Docker containerization
|
| 184 |
-
- [ ] Cloud deployment (Render + Streamlit Cloud)
|
| 185 |
|
| 186 |
---
|
| 187 |
|
| 188 |
## π©βπ» Author
|
| 189 |
|
| 190 |
-
**Varsha Sharma**
|
| 191 |
-
|
| 192 |
-
[](https://github.com/varshasharma01)
|
| 193 |
|
| 194 |
---
|
| 195 |
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
If you found this useful, consider giving it a β on GitHub !
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: ContextHub
|
| 3 |
+
emoji: π€
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: green
|
| 6 |
+
sdk: streamlit
|
| 7 |
+
sdk_version: "1.33.0"
|
| 8 |
+
python_version: "3.10"
|
| 9 |
+
app_file: app.py
|
| 10 |
+
pinned: false
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
# π ContextHub β Multimodal RAG Intelligence Platform
|
| 14 |
|
| 15 |
<div align="center">
|
| 16 |
|
| 17 |

|
| 18 |
+

|
|
|
|
| 19 |

|
| 20 |

|
| 21 |
|
|
|
|
| 27 |
|
| 28 |
## π What is ContextHub?
|
| 29 |
|
| 30 |
+
ContextHub is a **Retrieval-Augmented Generation (RAG)** platform hosted on Hugging Face Spaces. It allows you to upload various data sources and query them using natural language.
|
| 31 |
+
|
| 32 |
+
Unlike general-purpose AI, ContextHub answers **only from your uploaded content** β ensuring zero hallucinations and total data grounding.
|
| 33 |
|
| 34 |
---
|
| 35 |
|
|
|
|
| 37 |
|
| 38 |
| Mode | Input | Model Used |
|
| 39 |
|------|-------|-----------|
|
| 40 |
+
| π **PDF Analysis** | Upload any PDF | Groq β LLaMA 3.3 |
|
| 41 |
+
| πΌοΈ **Image Intelligence** | JPG / PNG | Google Gemini Vision |
|
| 42 |
+
| π **Web Intelligence** | Public URL | Groq β LLaMA 3.3 |
|
| 43 |
+
| π₯ **YouTube Intelligence** | YouTube URL | Groq β LLaMA 3.3 |
|
| 44 |
|
| 45 |
+
- π§ **Nomic Embeddings** β semantic vector search.
|
| 46 |
+
- π¦ **Pinecone** β isolated namespaces per source to prevent data bleed.
|
| 47 |
+
- β‘ **Groq** β ultra-fast LLM inference for near-instant answers.
|
| 48 |
+
- π₯οΈ **Streamlit** β native Hugging Face integration for a smooth UI.
|
|
|
|
| 49 |
|
| 50 |
---
|
| 51 |
|
| 52 |
+
## π§ Architecture on Spaces
|
| 53 |
|
| 54 |
+
Since this is running in a Hugging Face Space, the FastAPI backend has been integrated directly into the Streamlit logic (`app.py`) for optimized performance within a single container.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
+
### The Pipeline:
|
| 57 |
+
1. **Ingestion**: Documents/URLs are parsed and chunked.
|
| 58 |
+
2. **Embedding**: Text is converted to vectors via Nomic.
|
| 59 |
+
3. **Storage**: Vectors are stored in Pinecone using unique session namespaces.
|
| 60 |
+
4. **Retrieval**: Relevant context is pulled based on user queries.
|
| 61 |
+
5. **Generation**: Groq (LLaMA 3.3) generates the final response based *only* on retrieved context.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
---
|
| 64 |
|
| 65 |
+
## π Environment Variables (Required)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
+
To run this Space, you must add the following **Secrets** in your Space Settings:
|
| 68 |
|
| 69 |
+
| Secret Key | Source |
|
| 70 |
+
|----------|----------|
|
| 71 |
+
| `GROQ_API_KEY` | [Groq Console](https://console.groq.com) |
|
| 72 |
+
| `GEMINI_API_KEY` | [Google AI Studio](https://aistudio.google.com) |
|
| 73 |
+
| `PINECONE_API_KEY` | [Pinecone Dashboard](https://app.pinecone.io) |
|
| 74 |
+
| `NOMIC_API_KEY` | [Nomic Atlas](https://atlas.nomic.ai) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
---
|
| 77 |
|
| 78 |
## π οΈ Tech Stack
|
| 79 |
|
| 80 |
+
- **UI Framework:** Streamlit
|
| 81 |
+
- **Orchestration:** LangChain
|
| 82 |
+
- **LLMs:** Groq (LLaMA 3.3 70B), Google Gemini 1.5 Pro
|
| 83 |
+
- **Vector Database:** Pinecone
|
| 84 |
+
- **Embeddings:** Nomic-Embed-Text-v1
|
| 85 |
+
- **Parsing:** BeautifulSoup4, PyPDF, youtube-transcript-api
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
---
|
| 88 |
|
| 89 |
## π©βπ» Author
|
| 90 |
|
| 91 |
+
**Varsha Sharma** [](https://github.com/varshasharma01)
|
|
|
|
|
|
|
| 92 |
|
| 93 |
---
|
| 94 |
|
| 95 |
+
*Note: This Space is strictly for educational purposes and adheres to data grounding principles.*
|
|
|
|
|
|