Spaces:
Sleeping
Sleeping
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,20 +1,238 @@
|
|
| 1 |
---
|
| 2 |
title: VersionRAG
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
-
sdk:
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
- streamlit
|
| 10 |
pinned: false
|
| 11 |
-
short_description: Streamlit template space
|
| 12 |
-
license: mit
|
| 13 |
---
|
| 14 |
|
| 15 |
-
#
|
| 16 |
|
| 17 |
-
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
title: VersionRAG
|
| 3 |
+
emoji: π
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: green
|
| 6 |
+
sdk: streamlit
|
| 7 |
+
sdk_version: 1.28.0
|
| 8 |
+
app_file: app.py
|
|
|
|
| 9 |
pinned: false
|
|
|
|
|
|
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# VersionRAG: Version-Aware RAG System
|
| 13 |
|
| 14 |
+
A proof-of-concept implementation of Version-Aware Retrieval-Augmented Generation (RAG) system for handling versioned documents.
|
| 15 |
|
| 16 |
+
## Features
|
| 17 |
+
- β
Version-aware document retrieval
|
| 18 |
+
- β
Change tracking between versions
|
| 19 |
+
- β
Multi-user support with data isolation
|
| 20 |
+
- β
Interactive Streamlit interface
|
| 21 |
+
|
| 22 |
+
## Usage
|
| 23 |
+
1. Enter your OpenAI API key in the sidebar
|
| 24 |
+
2. Click "π Initialize Systems"
|
| 25 |
+
3. Upload versioned documents
|
| 26 |
+
4. Query using Content Retrieval, Version Inquiry, or Change Retrieval
|
| 27 |
+
|
| 28 |
+
## Requirements
|
| 29 |
+
- OpenAI API key
|
| 30 |
+
|
| 31 |
+
Built with Streamlit, LangChain, and ChromaDB.
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
Save this as `README.md` in your project folder.
|
| 35 |
+
|
| 36 |
+
---
|
| 37 |
+
|
| 38 |
+
## π Part 2: Create Hugging Face Account (3 minutes)
|
| 39 |
+
|
| 40 |
+
### Step 1: Go to Hugging Face
|
| 41 |
+
Open your browser and go to: **https://huggingface.co**
|
| 42 |
+
|
| 43 |
+
### Step 2: Sign Up
|
| 44 |
+
- Click **"Sign Up"** in the top right
|
| 45 |
+
- Use your email
|
| 46 |
+
- Choose a username (e.g., `shahbaz_ai` or whatever you like)
|
| 47 |
+
- Verify your email
|
| 48 |
+
|
| 49 |
+
### Step 3: Verify You're Logged In
|
| 50 |
+
You should see your profile picture in the top right corner.
|
| 51 |
+
|
| 52 |
+
---
|
| 53 |
+
|
| 54 |
+
## π¨ Part 3: Create Your Space (2 minutes)
|
| 55 |
+
|
| 56 |
+
### Step 1: Go to Spaces
|
| 57 |
+
Click on **"Spaces"** in the top menu bar.
|
| 58 |
+
|
| 59 |
+
### Step 2: Create New Space
|
| 60 |
+
- Click the big **"Create new Space"** button
|
| 61 |
+
- You'll see a form
|
| 62 |
+
|
| 63 |
+
### Step 3: Fill Out the Form
|
| 64 |
+
```
|
| 65 |
+
Space name: VersionRAG
|
| 66 |
+
(or whatever name you want - use letters, numbers, hyphens only)
|
| 67 |
+
|
| 68 |
+
License: MIT
|
| 69 |
+
|
| 70 |
+
Select SDK: Streamlit β IMPORTANT!
|
| 71 |
+
|
| 72 |
+
Space hardware: CPU basic - 2 vCPU, 16GB RAM (FREE tier)
|
| 73 |
+
|
| 74 |
+
Visibility: Public (or Private if you prefer)
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
### Step 4: Create!
|
| 78 |
+
Click **"Create Space"** button at the bottom.
|
| 79 |
+
|
| 80 |
+
You'll see a page that says "This Space is empty. Push your first commit to get started."
|
| 81 |
+
|
| 82 |
+
---
|
| 83 |
+
|
| 84 |
+
## π» Part 4: Upload Your Files (10 minutes)
|
| 85 |
+
|
| 86 |
+
You have two options: **Easy way (Web)** or **Git way**. Let's do the **Easy way** first!
|
| 87 |
+
|
| 88 |
+
### π Easy Way: Upload via Web Interface
|
| 89 |
+
|
| 90 |
+
#### Step 1: Click "Files" Tab
|
| 91 |
+
At the top of your Space page, click the **"Files"** tab.
|
| 92 |
+
|
| 93 |
+
#### Step 2: Upload Files One by One
|
| 94 |
+
|
| 95 |
+
Click **"Add file"** β **"Upload files"**
|
| 96 |
+
|
| 97 |
+
Upload these files in this order:
|
| 98 |
+
1. `README.md` (the one you just created)
|
| 99 |
+
2. `requirements.txt`
|
| 100 |
+
3. `app.py`
|
| 101 |
+
4. `version_rag.py`
|
| 102 |
+
5. `evaluation.py`
|
| 103 |
+
6. `graph_manager.py`
|
| 104 |
+
7. `utils.py`
|
| 105 |
+
8. `.gitignore`
|
| 106 |
+
|
| 107 |
+
After each upload, scroll down and click **"Commit changes to main"**.
|
| 108 |
+
|
| 109 |
+
**IMPORTANT:** Do NOT upload:
|
| 110 |
+
- β `.env` file (has your API key)
|
| 111 |
+
- β `venv/` folder
|
| 112 |
+
- β `chroma_db_*` folders
|
| 113 |
+
- β Any `__pycache__` folders
|
| 114 |
+
|
| 115 |
+
---
|
| 116 |
+
|
| 117 |
+
## π Part 5: Add Your OpenAI API Key (CRITICAL!) (2 minutes)
|
| 118 |
+
|
| 119 |
+
### Step 1: Go to Settings
|
| 120 |
+
In your Space, click **"Settings"** tab at the top.
|
| 121 |
+
|
| 122 |
+
### Step 2: Add Secret
|
| 123 |
+
- Scroll down to **"Variables and secrets"** section
|
| 124 |
+
- Click **"New secret"**
|
| 125 |
+
|
| 126 |
+
### Step 3: Fill In Your API Key
|
| 127 |
+
```
|
| 128 |
+
Name: OPENAI_API_KEY
|
| 129 |
+
Value: sk-proj... (paste your actual OpenAI API key here)
|
| 130 |
+
```
|
| 131 |
+
|
| 132 |
+
### Step 4: Save
|
| 133 |
+
Click **"Save"** button.
|
| 134 |
+
|
| 135 |
+
**β οΈ SUPER IMPORTANT:** Without this, your app won't work!
|
| 136 |
+
|
| 137 |
+
---
|
| 138 |
+
|
| 139 |
+
## β³ Part 6: Wait for Build (5-10 minutes)
|
| 140 |
+
|
| 141 |
+
### Step 1: Go to "App" Tab
|
| 142 |
+
Click the **"App"** tab at the top.
|
| 143 |
+
|
| 144 |
+
### Step 2: Watch It Build
|
| 145 |
+
You'll see logs scrolling. This is normal! It's installing all the packages.
|
| 146 |
+
|
| 147 |
+
You'll see messages like:
|
| 148 |
+
```
|
| 149 |
+
Collecting streamlit==1.28.0
|
| 150 |
+
Downloading streamlit-1.28.0...
|
| 151 |
+
Installing...
|
| 152 |
+
```
|
| 153 |
+
|
| 154 |
+
### Step 3: Wait for Success
|
| 155 |
+
When it's done, you'll see:
|
| 156 |
+
```
|
| 157 |
+
β
Space is running!
|
| 158 |
+
|
| 159 |
+
You can now view your Streamlit app in your browser.
|
| 160 |
+
```
|
| 161 |
+
|
| 162 |
+
If you see errors, don't panic! We'll fix them. Take a screenshot and show me.
|
| 163 |
+
|
| 164 |
+
---
|
| 165 |
+
|
| 166 |
+
## π Part 7: Test Your Deployed App! (5 minutes)
|
| 167 |
+
|
| 168 |
+
### Step 1: Your App Should Now Be Live!
|
| 169 |
+
You should see your VersionRAG interface in the "App" tab.
|
| 170 |
+
|
| 171 |
+
### Step 2: Test It
|
| 172 |
+
1. **Initialize Systems**:
|
| 173 |
+
- The OpenAI API key should already be set (from secrets)
|
| 174 |
+
- Click **"π Initialize Systems"** in the sidebar
|
| 175 |
+
- Wait for "β
Systems initialized successfully!"
|
| 176 |
+
|
| 177 |
+
2. **Upload a Document** (optional for testing):
|
| 178 |
+
- Go to **"π€ Document Upload"** tab
|
| 179 |
+
- Create a simple test file on your computer:
|
| 180 |
+
|
| 181 |
+
**test_v1.txt:**
|
| 182 |
+
```
|
| 183 |
+
Test Document v1.0
|
| 184 |
+
This is a test document for version 1.0.
|
| 185 |
+
Feature A is available.
|
| 186 |
+
```
|
| 187 |
+
|
| 188 |
+
- Upload it with Version: `v1.0`, Domain: `Software`
|
| 189 |
+
- Click "Process"
|
| 190 |
+
|
| 191 |
+
3. **Try a Query**:
|
| 192 |
+
- Go to **"π¬ Query Interface"** tab
|
| 193 |
+
- Enter: `What features are available?`
|
| 194 |
+
- Click **"π Search"**
|
| 195 |
+
- You should get a response!
|
| 196 |
+
|
| 197 |
+
### Step 3: Share Your Space!
|
| 198 |
+
Your Space URL is:
|
| 199 |
+
```
|
| 200 |
+
https://huggingface.co/spaces/YOUR_USERNAME/VersionRAG
|
| 201 |
+
```
|
| 202 |
+
|
| 203 |
+
Copy this and share it with anyone! π
|
| 204 |
+
|
| 205 |
+
---
|
| 206 |
+
|
| 207 |
+
## π Common Problems & Fixes
|
| 208 |
+
|
| 209 |
+
### Problem 1: "Space is building..." for more than 15 minutes
|
| 210 |
+
|
| 211 |
+
**Fix:**
|
| 212 |
+
- Refresh the page
|
| 213 |
+
- Check "Logs" tab for errors
|
| 214 |
+
- Common issue: `requirements.txt` has wrong versions
|
| 215 |
+
|
| 216 |
+
### Problem 2: "Import Error" or "Module not found"
|
| 217 |
+
|
| 218 |
+
**Fix:**
|
| 219 |
+
- Go to "Files" tab
|
| 220 |
+
- Click on `requirements.txt`
|
| 221 |
+
- Click "Edit" (pencil icon)
|
| 222 |
+
- Make sure it has all packages:
|
| 223 |
+
```
|
| 224 |
+
streamlit==1.28.0
|
| 225 |
+
chromadb==0.4.22
|
| 226 |
+
langchain==0.1.16
|
| 227 |
+
langchain-community==0.0.38
|
| 228 |
+
langchain-openai==0.1.6
|
| 229 |
+
openai==1.23.0
|
| 230 |
+
PyPDF2==3.0.1
|
| 231 |
+
python-dotenv==1.0.1
|
| 232 |
+
pandas==2.2.1
|
| 233 |
+
plotly==5.20.0
|
| 234 |
+
networkx==3.2.1
|
| 235 |
+
pydantic==2.7.0
|
| 236 |
+
tiktoken==0.6.0
|
| 237 |
+
numpy==1.26.4
|
| 238 |
+
scikit-learn==1.4.2
|