Spaces:
Running
Running
chore: add .gitignore, remove __pycache__ and temp files from tracking
Browse files- Add .gitignore: excludes __pycache__, .venv, .env, *.pyc, .pytest_cache
- Remove all __pycache__ .pyc files from git tracking (keep on disk)
- Delete DEPLOYMENT_FIXES.md (temp doc)
- Delete upgrade_dependencies.sh (temp script)
- .gitignore +21 -0
- DEPLOYMENT_FIXES.md +0 -151
- src/api/__pycache__/dependencies.cpython-313.pyc +0 -0
- src/core/__pycache__/config.cpython-313.pyc +0 -0
- src/core/__pycache__/security.cpython-313.pyc +0 -0
- src/core/domain/__pycache__/db_models.cpython-313.pyc +0 -0
- src/core/domain/__pycache__/schemas.cpython-313.pyc +0 -0
- src/core/ports/__pycache__/analytics_db_port.cpython-313.pyc +0 -0
- src/core/ports/__pycache__/cache_port.cpython-313.pyc +0 -0
- src/core/ports/__pycache__/chat_history_port.cpython-313.pyc +0 -0
- src/core/ports/__pycache__/embedder_port.cpython-313.pyc +0 -0
- src/core/ports/__pycache__/llm_port.cpython-313.pyc +0 -0
- src/core/ports/__pycache__/reranker_port.cpython-313.pyc +0 -0
- src/core/ports/__pycache__/vector_store_port.cpython-313.pyc +0 -0
- src/core/use_cases/__pycache__/account_use_case.cpython-313.pyc +0 -0
- src/core/use_cases/__pycache__/agent_router_use_case.cpython-313.pyc +0 -0
- src/core/use_cases/__pycache__/analytics_use_case.cpython-313.pyc +0 -0
- src/core/use_cases/__pycache__/rag_chat_use_case.cpython-313.pyc +0 -0
- src/core/use_cases/__pycache__/search_use_case.cpython-313.pyc +0 -0
- src/infrastructure/__pycache__/database.cpython-313.pyc +0 -0
- src/infrastructure/adapters/__pycache__/bge_embedder_adapter.cpython-313.pyc +0 -0
- src/infrastructure/adapters/__pycache__/bge_reranker_adapter.cpython-313.pyc +0 -0
- src/infrastructure/adapters/__pycache__/clickhouse_adapter.cpython-313.pyc +0 -0
- src/infrastructure/adapters/__pycache__/duckduckgo_adapter.cpython-313.pyc +0 -0
- src/infrastructure/adapters/__pycache__/ollama_adapter.cpython-313.pyc +0 -0
- src/infrastructure/adapters/__pycache__/openai_adapter.cpython-313.pyc +0 -0
- src/infrastructure/adapters/__pycache__/postgres_adapter.cpython-313.pyc +0 -0
- src/infrastructure/adapters/__pycache__/qdrant_adapter.cpython-313.pyc +0 -0
- src/infrastructure/adapters/__pycache__/redis_adapter.cpython-313.pyc +0 -0
- upgrade_dependencies.sh +0 -25
.gitignore
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Python bytecode
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.py[cod]
|
| 4 |
+
*.pyo
|
| 5 |
+
*.pyc
|
| 6 |
+
|
| 7 |
+
# Virtual environment
|
| 8 |
+
.venv/
|
| 9 |
+
venv/
|
| 10 |
+
env/
|
| 11 |
+
|
| 12 |
+
# Environment files with secrets
|
| 13 |
+
.env
|
| 14 |
+
|
| 15 |
+
# Test/debug artifacts
|
| 16 |
+
*.log
|
| 17 |
+
.pytest_cache/
|
| 18 |
+
|
| 19 |
+
# IDE
|
| 20 |
+
.vscode/
|
| 21 |
+
.idea/
|
DEPLOYMENT_FIXES.md
DELETED
|
@@ -1,151 +0,0 @@
|
|
| 1 |
-
# Deployment Fixes for RAG API v2.4
|
| 2 |
-
|
| 3 |
-
## Issues Fixed
|
| 4 |
-
|
| 5 |
-
### 1. β
Qdrant `order_by` Error (FIXED IN CODE)
|
| 6 |
-
- **Status:** Fixed in commit `7110008`
|
| 7 |
-
- **Action:** Already deployed, no action needed
|
| 8 |
-
|
| 9 |
-
### 2. β
DuckDuckGo Decode Error (FIXED IN CODE)
|
| 10 |
-
- **Status:** Fixed with better error handling
|
| 11 |
-
- **Action:** Deploy latest code
|
| 12 |
-
- **Details:** System now gracefully handles decode errors and falls back to database
|
| 13 |
-
|
| 14 |
-
### 3. β οΈ Reranker Tokenizer Error (NEEDS DEPLOYMENT)
|
| 15 |
-
- **Status:** Fix ready, needs dependency upgrade
|
| 16 |
-
- **Action:** Run upgrade script (see below)
|
| 17 |
-
|
| 18 |
-
---
|
| 19 |
-
|
| 20 |
-
## Deployment Steps
|
| 21 |
-
|
| 22 |
-
### Option A: Automatic Upgrade (Recommended)
|
| 23 |
-
|
| 24 |
-
```bash
|
| 25 |
-
cd services/apis/rag-api
|
| 26 |
-
chmod +x upgrade_dependencies.sh
|
| 27 |
-
./upgrade_dependencies.sh
|
| 28 |
-
```
|
| 29 |
-
|
| 30 |
-
### Option B: Manual Upgrade
|
| 31 |
-
|
| 32 |
-
```bash
|
| 33 |
-
pip install --upgrade FlagEmbedding>=1.2.11
|
| 34 |
-
pip install --upgrade transformers>=4.45.0
|
| 35 |
-
```
|
| 36 |
-
|
| 37 |
-
### Option C: Fresh Install
|
| 38 |
-
|
| 39 |
-
```bash
|
| 40 |
-
cd services/apis/rag-api
|
| 41 |
-
pip install -r requirements.txt --upgrade
|
| 42 |
-
```
|
| 43 |
-
|
| 44 |
-
---
|
| 45 |
-
|
| 46 |
-
## Verification
|
| 47 |
-
|
| 48 |
-
After deployment, check logs for:
|
| 49 |
-
|
| 50 |
-
### β
Success Indicators:
|
| 51 |
-
```
|
| 52 |
-
# No more Qdrant errors
|
| 53 |
-
β No "order_by not supported" warnings
|
| 54 |
-
|
| 55 |
-
# No more reranker errors
|
| 56 |
-
β No "XLMRobertaTokenizer has no attribute prepare_for_model" errors
|
| 57 |
-
|
| 58 |
-
# DuckDuckGo graceful handling
|
| 59 |
-
β "DuckDuckGo decode error (likely rate limit)" β Falls back to DB
|
| 60 |
-
β System continues working with database results
|
| 61 |
-
```
|
| 62 |
-
|
| 63 |
-
### β If Still Broken:
|
| 64 |
-
```bash
|
| 65 |
-
# Check installed versions
|
| 66 |
-
pip show FlagEmbedding transformers
|
| 67 |
-
|
| 68 |
-
# Should show:
|
| 69 |
-
# FlagEmbedding: 1.2.11 or higher
|
| 70 |
-
# transformers: 4.45.0 or higher
|
| 71 |
-
|
| 72 |
-
# If not, force reinstall:
|
| 73 |
-
pip uninstall FlagEmbedding transformers -y
|
| 74 |
-
pip install FlagEmbedding==1.2.11 transformers==4.45.0
|
| 75 |
-
```
|
| 76 |
-
|
| 77 |
-
---
|
| 78 |
-
|
| 79 |
-
## Testing
|
| 80 |
-
|
| 81 |
-
### Test 1: Check Reranker
|
| 82 |
-
```bash
|
| 83 |
-
# Query the API and check logs
|
| 84 |
-
curl -X POST http://localhost:7860/api/v1/rag/chat/stream \
|
| 85 |
-
-H "Content-Type: application/json" \
|
| 86 |
-
-d '{"query": "Ethiopia news today"}'
|
| 87 |
-
|
| 88 |
-
# Check logs - should NOT see:
|
| 89 |
-
# β "Reranker scoring failed"
|
| 90 |
-
|
| 91 |
-
# Should see:
|
| 92 |
-
# β
"DEBUG: After hybrid ranking: 15 results"
|
| 93 |
-
```
|
| 94 |
-
|
| 95 |
-
### Test 2: Check DuckDuckGo
|
| 96 |
-
```bash
|
| 97 |
-
# Query with temporal intent
|
| 98 |
-
curl -X POST http://localhost:7860/api/v1/rag/chat/stream \
|
| 99 |
-
-H "Content-Type: application/json" \
|
| 100 |
-
-d '{"query": "breaking news today"}'
|
| 101 |
-
|
| 102 |
-
# Check logs:
|
| 103 |
-
# β
"DEBUG: Hybrid search returned X DB + Y live results"
|
| 104 |
-
# If Y=0, check for:
|
| 105 |
-
# β
"DuckDuckGo decode error (likely rate limit)" β Graceful fallback
|
| 106 |
-
```
|
| 107 |
-
|
| 108 |
-
### Test 3: Check News Endpoint
|
| 109 |
-
```bash
|
| 110 |
-
# Test browse endpoint
|
| 111 |
-
curl http://localhost:7860/api/v1/news/latest?limit=10
|
| 112 |
-
|
| 113 |
-
# Should return:
|
| 114 |
-
# β
200 OK with recent articles
|
| 115 |
-
# β
No 400 errors in logs
|
| 116 |
-
```
|
| 117 |
-
|
| 118 |
-
---
|
| 119 |
-
|
| 120 |
-
## Rollback Plan
|
| 121 |
-
|
| 122 |
-
If issues occur after deployment:
|
| 123 |
-
|
| 124 |
-
```bash
|
| 125 |
-
# Rollback to previous versions
|
| 126 |
-
pip install FlagEmbedding==1.2.5 transformers==4.40.0
|
| 127 |
-
|
| 128 |
-
# Or rollback code
|
| 129 |
-
git revert 7110008
|
| 130 |
-
git push
|
| 131 |
-
```
|
| 132 |
-
|
| 133 |
-
---
|
| 134 |
-
|
| 135 |
-
## Support
|
| 136 |
-
|
| 137 |
-
If issues persist:
|
| 138 |
-
1. Check logs for specific error messages
|
| 139 |
-
2. Verify Python version (should be 3.10+)
|
| 140 |
-
3. Check if running in virtual environment
|
| 141 |
-
4. Try fresh install in clean environment
|
| 142 |
-
|
| 143 |
-
---
|
| 144 |
-
|
| 145 |
-
## Version History
|
| 146 |
-
|
| 147 |
-
- **v2.4** (2026-05-04): Fixed Qdrant order_by, DuckDuckGo errors, upgraded reranker
|
| 148 |
-
- **v2.3** (2026-05-04): Interactive thinking indicator with Lucide icons
|
| 149 |
-
- **v2.2** (2026-05-03): Time-based filtering for news endpoint
|
| 150 |
-
- **v2.1** (2026-05-03): Query enhancements and flexible prompting
|
| 151 |
-
- **v2.0** (2026-05-02): Hybrid RAG with live search
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/api/__pycache__/dependencies.cpython-313.pyc
DELETED
|
Binary file (4.35 kB)
|
|
|
src/core/__pycache__/config.cpython-313.pyc
DELETED
|
Binary file (4.02 kB)
|
|
|
src/core/__pycache__/security.cpython-313.pyc
DELETED
|
Binary file (6.26 kB)
|
|
|
src/core/domain/__pycache__/db_models.cpython-313.pyc
DELETED
|
Binary file (3.61 kB)
|
|
|
src/core/domain/__pycache__/schemas.cpython-313.pyc
DELETED
|
Binary file (5.02 kB)
|
|
|
src/core/ports/__pycache__/analytics_db_port.cpython-313.pyc
DELETED
|
Binary file (1.45 kB)
|
|
|
src/core/ports/__pycache__/cache_port.cpython-313.pyc
DELETED
|
Binary file (1.71 kB)
|
|
|
src/core/ports/__pycache__/chat_history_port.cpython-313.pyc
DELETED
|
Binary file (1.72 kB)
|
|
|
src/core/ports/__pycache__/embedder_port.cpython-313.pyc
DELETED
|
Binary file (1.08 kB)
|
|
|
src/core/ports/__pycache__/llm_port.cpython-313.pyc
DELETED
|
Binary file (1.23 kB)
|
|
|
src/core/ports/__pycache__/reranker_port.cpython-313.pyc
DELETED
|
Binary file (1.11 kB)
|
|
|
src/core/ports/__pycache__/vector_store_port.cpython-313.pyc
DELETED
|
Binary file (2.71 kB)
|
|
|
src/core/use_cases/__pycache__/account_use_case.cpython-313.pyc
DELETED
|
Binary file (1.62 kB)
|
|
|
src/core/use_cases/__pycache__/agent_router_use_case.cpython-313.pyc
DELETED
|
Binary file (4.43 kB)
|
|
|
src/core/use_cases/__pycache__/analytics_use_case.cpython-313.pyc
DELETED
|
Binary file (1.62 kB)
|
|
|
src/core/use_cases/__pycache__/rag_chat_use_case.cpython-313.pyc
DELETED
|
Binary file (12.6 kB)
|
|
|
src/core/use_cases/__pycache__/search_use_case.cpython-313.pyc
DELETED
|
Binary file (1.7 kB)
|
|
|
src/infrastructure/__pycache__/database.cpython-313.pyc
DELETED
|
Binary file (1.09 kB)
|
|
|
src/infrastructure/adapters/__pycache__/bge_embedder_adapter.cpython-313.pyc
DELETED
|
Binary file (4.09 kB)
|
|
|
src/infrastructure/adapters/__pycache__/bge_reranker_adapter.cpython-313.pyc
DELETED
|
Binary file (4.42 kB)
|
|
|
src/infrastructure/adapters/__pycache__/clickhouse_adapter.cpython-313.pyc
DELETED
|
Binary file (3.28 kB)
|
|
|
src/infrastructure/adapters/__pycache__/duckduckgo_adapter.cpython-313.pyc
DELETED
|
Binary file (10.4 kB)
|
|
|
src/infrastructure/adapters/__pycache__/ollama_adapter.cpython-313.pyc
DELETED
|
Binary file (4.8 kB)
|
|
|
src/infrastructure/adapters/__pycache__/openai_adapter.cpython-313.pyc
DELETED
|
Binary file (2.17 kB)
|
|
|
src/infrastructure/adapters/__pycache__/postgres_adapter.cpython-313.pyc
DELETED
|
Binary file (2.9 kB)
|
|
|
src/infrastructure/adapters/__pycache__/qdrant_adapter.cpython-313.pyc
DELETED
|
Binary file (9.65 kB)
|
|
|
src/infrastructure/adapters/__pycache__/redis_adapter.cpython-313.pyc
DELETED
|
Binary file (4.06 kB)
|
|
|
upgrade_dependencies.sh
DELETED
|
@@ -1,25 +0,0 @@
|
|
| 1 |
-
#!/bin/bash
|
| 2 |
-
# Upgrade script for fixing reranker tokenizer issue
|
| 3 |
-
# Run this on HF Spaces or production server
|
| 4 |
-
|
| 5 |
-
echo "=========================================="
|
| 6 |
-
echo "Upgrading RAG API Dependencies"
|
| 7 |
-
echo "=========================================="
|
| 8 |
-
|
| 9 |
-
echo ""
|
| 10 |
-
echo "π¦ Upgrading FlagEmbedding (reranker fix)..."
|
| 11 |
-
pip install --upgrade FlagEmbedding>=1.2.11
|
| 12 |
-
|
| 13 |
-
echo ""
|
| 14 |
-
echo "π¦ Upgrading transformers (tokenizer fix)..."
|
| 15 |
-
pip install --upgrade transformers>=4.45.0
|
| 16 |
-
|
| 17 |
-
echo ""
|
| 18 |
-
echo "β
Dependencies upgraded successfully!"
|
| 19 |
-
echo ""
|
| 20 |
-
echo "π Please restart the service for changes to take effect:"
|
| 21 |
-
echo " - HF Spaces: Will auto-restart"
|
| 22 |
-
echo " - Docker: docker-compose restart rag-api"
|
| 23 |
-
echo " - Systemd: systemctl restart rag-api"
|
| 24 |
-
echo ""
|
| 25 |
-
echo "=========================================="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|