Spaces:
Sleeping
Sleeping
Claude commited on
Add Render.com deployment configuration for online hosting
Browse files- Add render.yaml for automatic deployment
- Add download_vector_db.sh script to fetch DB from Release
- Add comprehensive DEPLOY_GUIDE.md with step-by-step instructions
- Enable public access for anyone to use the RAG system
- Free tier deployment with automatic HTTPS
- DEPLOY_GUIDE.md +177 -0
- render.yaml +27 -0
- scripts/download_vector_db.sh +34 -0
DEPLOY_GUIDE.md
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# π Render.com λ¬΄λ£ λ°°ν¬ κ°μ΄λ
|
| 2 |
+
|
| 3 |
+
## π λ°°ν¬ κ°μ
|
| 4 |
+
|
| 5 |
+
μ΄ κ°μ΄λλ λ°±μλ APIλ₯Ό **Render.com λ¬΄λ£ νλ**μ λ°°ν¬νμ¬ λꡬλ μ¨λΌμΈμμ μ κ·Ό κ°λ₯νκ² λ§λλ λ°©λ²μ
λλ€.
|
| 6 |
+
|
| 7 |
+
### β¨ Render.com λ¬΄λ£ νλ νΉμ§
|
| 8 |
+
- β
**μμ 무λ£** (μ μ©μΉ΄λ λΆνμ)
|
| 9 |
+
- β
**μλ HTTPS** μ 곡
|
| 10 |
+
- β
**GitHub μ°λ** μλ λ°°ν¬
|
| 11 |
+
- β
**μ 750μκ°** λ¬΄λ£ (μΆ©λΆν¨!)
|
| 12 |
+
- β οΈ 15λΆ idle ν sleep (첫 μμ² μ 10-30μ΄ μμ)
|
| 13 |
+
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
## π§ λ°°ν¬ λ¨κ³
|
| 17 |
+
|
| 18 |
+
### 1οΈβ£ GitHubμ νΈμ
|
| 19 |
+
|
| 20 |
+
```bash
|
| 21 |
+
git add .
|
| 22 |
+
git commit -m "Add Render.com deployment configuration"
|
| 23 |
+
git push origin main # λλ νμ¬ λΈλμΉ
|
| 24 |
+
```
|
| 25 |
+
|
| 26 |
+
### 2οΈβ£ Render.com κ³μ μμ±
|
| 27 |
+
|
| 28 |
+
1. https://render.com μ μ
|
| 29 |
+
2. **"Get Started for Free"** ν΄λ¦
|
| 30 |
+
3. **GitHub κ³μ μΌλ‘ λ‘κ·ΈμΈ**
|
| 31 |
+
|
| 32 |
+
### 3οΈβ£ μ Web Service μμ±
|
| 33 |
+
|
| 34 |
+
1. Dashboardμμ **"New +"** ν΄λ¦
|
| 35 |
+
2. **"Web Service"** μ ν
|
| 36 |
+
3. **GitHub 리ν¬μ§ν 리 μ°κ²°**:
|
| 37 |
+
- `csjjin2025/Hallucination_and_Deception_for_financial_RAG` μ ν
|
| 38 |
+
4. λ€μ μ€μ μ
λ ₯:
|
| 39 |
+
|
| 40 |
+
```
|
| 41 |
+
Name: financial-rag-api (λλ μνλ μ΄λ¦)
|
| 42 |
+
Region: Singapore (κ°μ₯ κ°κΉμ΄ μ§μ)
|
| 43 |
+
Branch: main (λλ νμ¬ λΈλμΉ)
|
| 44 |
+
Runtime: Python 3
|
| 45 |
+
Build Command: (μλ κ°μ§λ¨ - render.yaml μ¬μ©)
|
| 46 |
+
Start Command: (μλ κ°μ§λ¨ - render.yaml μ¬μ©)
|
| 47 |
+
Instance Type: Free
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
### 4οΈβ£ νκ²½λ³μ μ€μ
|
| 51 |
+
|
| 52 |
+
**Environment** νμμ λ€μ λ³μ μΆκ°:
|
| 53 |
+
|
| 54 |
+
```
|
| 55 |
+
ANTHROPIC_API_KEY=sk-ant-api03-your-key-here
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
β οΈ **μ€μ**: Anthropic API ν€λ₯Ό κΌ μ
λ ₯νμΈμ!
|
| 59 |
+
|
| 60 |
+
### 5οΈβ£ λ°°ν¬ μμ
|
| 61 |
+
|
| 62 |
+
**"Create Web Service"** ν΄λ¦νλ©΄ μλμΌλ‘ λ°°ν¬κ° μμλ©λλ€.
|
| 63 |
+
|
| 64 |
+
λ°°ν¬ λ‘κ·Έλ₯Ό νμΈνλ©° λκΈ° (μ½ 5-10λΆ μμ):
|
| 65 |
+
- ν¨ν€μ§ μ€μΉ
|
| 66 |
+
- λ²‘ν° DB λ€μ΄λ‘λ
|
| 67 |
+
- μλ² μμ
|
| 68 |
+
|
| 69 |
+
### 6οΈβ£ λ°°ν¬ μλ£ νμΈ
|
| 70 |
+
|
| 71 |
+
λ°°ν¬κ° μλ£λλ©΄ λ€μκ³Ό κ°μ URLμ΄ μμ±λ©λλ€:
|
| 72 |
+
|
| 73 |
+
```
|
| 74 |
+
https://financial-rag-api-xxxx.onrender.com
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
ν¬μ€ μ²΄ν¬ ν
μ€νΈ:
|
| 78 |
+
```bash
|
| 79 |
+
curl https://your-app-name.onrender.com/health
|
| 80 |
+
```
|
| 81 |
+
|
| 82 |
+
μ±κ³΅ μ:
|
| 83 |
+
```json
|
| 84 |
+
{
|
| 85 |
+
"status": "healthy",
|
| 86 |
+
"vector_store": {
|
| 87 |
+
"total_documents": 15,
|
| 88 |
+
...
|
| 89 |
+
}
|
| 90 |
+
}
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
---
|
| 94 |
+
|
| 95 |
+
## π GitHub Pagesμ μ°κ²°
|
| 96 |
+
|
| 97 |
+
### λ°©λ² 1: νλ‘ νΈμλμ API URL νλμ½λ© (κΆμ₯)
|
| 98 |
+
|
| 99 |
+
GitHub Pagesμ `index.html` λλ JavaScript νμΌμμ:
|
| 100 |
+
|
| 101 |
+
```javascript
|
| 102 |
+
// κΈ°λ³Έ API URL μ€μ
|
| 103 |
+
const DEFAULT_API_URL = "https://your-app-name.onrender.com";
|
| 104 |
+
```
|
| 105 |
+
|
| 106 |
+
### λ°©λ² 2: μ¬μ©μκ° μ§μ μ
λ ₯
|
| 107 |
+
|
| 108 |
+
νμ¬μ²λΌ μ¬μ©μκ° API URLμ μ
λ ₯νλλ‘ μ μ§νλ,
|
| 109 |
+
placeholderμ κΈ°λ³Έ URL νμ:
|
| 110 |
+
|
| 111 |
+
```html
|
| 112 |
+
<input
|
| 113 |
+
type="text"
|
| 114 |
+
placeholder="https://your-app-name.onrender.com"
|
| 115 |
+
id="api-url-input"
|
| 116 |
+
>
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
---
|
| 120 |
+
|
| 121 |
+
## π μλ μ
λ°μ΄νΈ μ€μ
|
| 122 |
+
|
| 123 |
+
GitHubμ μ½λλ₯Ό νΈμνλ©΄ **μλμΌλ‘ μ¬λ°°ν¬**λ©λλ€:
|
| 124 |
+
|
| 125 |
+
```bash
|
| 126 |
+
git add .
|
| 127 |
+
git commit -m "Update backend"
|
| 128 |
+
git push origin main
|
| 129 |
+
```
|
| 130 |
+
|
| 131 |
+
Render.comμ΄ μλμΌλ‘ κ°μ§νκ³ μ¬λ°°ν¬ν©λλ€! π
|
| 132 |
+
|
| 133 |
+
---
|
| 134 |
+
|
| 135 |
+
## β οΈ μ£Όμμ¬ν
|
| 136 |
+
|
| 137 |
+
### 1. Cold Start (첫 μμ² μ§μ°)
|
| 138 |
+
λ¬΄λ£ νλμ 15λΆ idle ν sleep μνκ° λ©λλ€.
|
| 139 |
+
첫 μμ² μ 10-30μ΄ μμλ μ μμ΅λλ€.
|
| 140 |
+
|
| 141 |
+
**ν΄κ²°μ±
**:
|
| 142 |
+
- Render.comμ **Cron Job** κΈ°λ₯μΌλ‘ 5λΆλ§λ€ health check
|
| 143 |
+
- λλ μ
κ·Έλ μ΄λ ($7/μ)
|
| 144 |
+
|
| 145 |
+
### 2. λ²‘ν° DB ν¬κΈ° μ ν
|
| 146 |
+
λ¬΄λ£ νλμ μ€ν λ¦¬μ§ μ νμ΄ μμ΅λλ€.
|
| 147 |
+
- νμ¬: 15κ° ν
μ€νΈ λ¬Έμ (λ§€μ° μμ)
|
| 148 |
+
- μ 체 DB: μμΆ μ ~500MB (λ¬΄λ£ νλ κ°λ₯)
|
| 149 |
+
|
| 150 |
+
### 3. API ν€ λ³΄μ
|
| 151 |
+
- β
νκ²½λ³μλ‘ μ€μ (μμ )
|
| 152 |
+
- β μ½λμ νλμ½λ© κΈμ§
|
| 153 |
+
|
| 154 |
+
---
|
| 155 |
+
|
| 156 |
+
## π λ°°ν¬ ν λͺ¨λν°λ§
|
| 157 |
+
|
| 158 |
+
### Render.com Dashboardμμ νμΈ:
|
| 159 |
+
- **Logs**: μ€μκ° λ‘κ·Έ νμΈ
|
| 160 |
+
- **Metrics**: CPU, λ©λͺ¨λ¦¬ μ¬μ©λ
|
| 161 |
+
- **Events**: λ°°ν¬ μ΄λ ₯
|
| 162 |
+
|
| 163 |
+
### API μλν¬μΈνΈ:
|
| 164 |
+
- Health Check: `GET /health`
|
| 165 |
+
- API Docs: `GET /docs`
|
| 166 |
+
- Query: `POST /query`
|
| 167 |
+
|
| 168 |
+
---
|
| 169 |
+
|
| 170 |
+
## π μλ£!
|
| 171 |
+
|
| 172 |
+
μ΄μ GitHub Pagesμμ:
|
| 173 |
+
1. https://csjjin2025.github.io/Hallucination_and_Deception_for_financial_RAG/ μ μ
|
| 174 |
+
2. API URL μ
λ ₯: `https://your-app-name.onrender.com`
|
| 175 |
+
3. μ§λ¬Έ μ
λ ₯νκ³ ν
μ€νΈ!
|
| 176 |
+
|
| 177 |
+
**μ μΈκ³ λꡬλ μ κ·Ό κ°λ₯ν©λλ€!** π
|
render.yaml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
services:
|
| 2 |
+
- type: web
|
| 3 |
+
name: financial-rag-api
|
| 4 |
+
runtime: python
|
| 5 |
+
buildCommand: |
|
| 6 |
+
pip install -r requirements.txt
|
| 7 |
+
chmod +x scripts/download_vector_db.sh
|
| 8 |
+
./scripts/download_vector_db.sh
|
| 9 |
+
startCommand: uvicorn app.main:app --host 0.0.0.0 --port $PORT
|
| 10 |
+
envVars:
|
| 11 |
+
- key: ANTHROPIC_API_KEY
|
| 12 |
+
sync: false # μλμΌλ‘ μ€μ νμ
|
| 13 |
+
- key: EMBEDDING_MODEL
|
| 14 |
+
value: sentence-transformers
|
| 15 |
+
- key: EMBEDDING_MODEL_NAME
|
| 16 |
+
value: all-MiniLM-L6-v2
|
| 17 |
+
- key: CHROMA_PERSIST_DIRECTORY
|
| 18 |
+
value: ./data/chroma_db
|
| 19 |
+
- key: COLLECTION_NAME
|
| 20 |
+
value: financial_papers
|
| 21 |
+
- key: PDF_SOURCE_PATH
|
| 22 |
+
value: ./data/pdfs
|
| 23 |
+
- key: API_HOST
|
| 24 |
+
value: 0.0.0.0
|
| 25 |
+
- key: API_PORT
|
| 26 |
+
value: $PORT
|
| 27 |
+
healthCheckPath: /health
|
scripts/download_vector_db.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# λ²‘ν° DB μλ λ€μ΄λ‘λ μ€ν¬λ¦½νΈ (Render.com λ°°ν¬μ©)
|
| 3 |
+
|
| 4 |
+
set -e
|
| 5 |
+
|
| 6 |
+
echo "π Checking if vector DB exists..."
|
| 7 |
+
|
| 8 |
+
if [ -d "./data/chroma_db" ] && [ "$(ls -A ./data/chroma_db)" ]; then
|
| 9 |
+
echo "β
Vector DB already exists. Skipping download."
|
| 10 |
+
exit 0
|
| 11 |
+
fi
|
| 12 |
+
|
| 13 |
+
echo "π₯ Downloading vector DB from GitHub Release..."
|
| 14 |
+
|
| 15 |
+
# λλ ν 리 μμ±
|
| 16 |
+
mkdir -p ./data
|
| 17 |
+
|
| 18 |
+
# GitHub Releaseμμ λ€μ΄λ‘λ (μ€ν¨ν΄λ κ³μ μ§ν)
|
| 19 |
+
curl -L -o ./data/chroma_db.tar.gz \
|
| 20 |
+
"https://github.com/csjjin2025/Hallucination_and_Deception_for_financial_RAG/releases/download/v1.0/chroma_db.tar.gz" \
|
| 21 |
+
|| echo "β οΈ Failed to download from Release. Using test DB instead."
|
| 22 |
+
|
| 23 |
+
# λ€μ΄λ‘λ μ±κ³΅ μ μμΆ ν΄μ
|
| 24 |
+
if [ -f "./data/chroma_db.tar.gz" ] && [ -s "./data/chroma_db.tar.gz" ]; then
|
| 25 |
+
echo "π¦ Extracting vector DB..."
|
| 26 |
+
tar -xzf ./data/chroma_db.tar.gz -C ./data/
|
| 27 |
+
rm ./data/chroma_db.tar.gz
|
| 28 |
+
echo "β
Vector DB extracted successfully!"
|
| 29 |
+
else
|
| 30 |
+
echo "β οΈ Download failed or file is empty. Creating test DB..."
|
| 31 |
+
python scripts/quick_setup_test_db.py
|
| 32 |
+
fi
|
| 33 |
+
|
| 34 |
+
echo "β¨ Vector DB setup complete!"
|