Spaces:
Running
Running
File size: 6,416 Bytes
526927a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
# Lily LLM API λ°°ν¬ κ°μ΄λ
## π κ°μ
μ΄ λ¬Έμλ Lily LLM API μλ²μ Docker κΈ°λ° λ°°ν¬ λ°©λ²μ μ€λͺ
ν©λλ€.
## ποΈ μν€ν
μ²
```
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Lily LLM API β β Redis β β Celery Worker β
β (FastAPI) βββββΊβ (Message βββββΊβ (Background β
β Port: 8001 β β Broker) β β Tasks) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
β β β
βΌ βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Flower β β Celery Beat β β Database β
β (Monitoring) β β (Scheduler) β β (SQLite) β
β Port: 5555 β β β β β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
```
## π λΉ λ₯Έ μμ
### 1. μ¬μ μꡬμ¬ν
- Docker
- Docker Compose
- μ΅μ 4GB RAM
- μ΅μ 10GB λμ€ν¬ 곡κ°
### 2. λ°°ν¬ μ€ν
```bash
# μ μ₯μ ν΄λ‘
git clone <repository-url>
cd lily_generate_package
# λ°°ν¬ μ€ν¬λ¦½νΈ μ€ν
chmod +x scripts/deploy.sh
./scripts/deploy.sh deploy
```
### 3. μλΉμ€ νμΈ
```bash
# μλΉμ€ μν νμΈ
./scripts/deploy.sh status
# λ‘κ·Έ νμΈ
./scripts/deploy.sh logs
```
## π¦ Docker 컨ν
μ΄λ
### μ£Όμ μλΉμ€
| μλΉμ€ | ν¬νΈ | μ€λͺ
|
|--------|------|------|
| lily-llm-api | 8001 | FastAPI λ©μΈ μλ² |
| redis | 6379 | λ©μμ§ λΈλ‘컀 λ° μΊμ |
| celery-worker | - | λ°±κ·ΈλΌμ΄λ μμ
μ²λ¦¬ |
| celery-beat | - | μ€μΌμ€λ¬ |
| flower | 5555 | Celery λͺ¨λν°λ§ |
### νκ²½ λ³μ
```yaml
# API μλ²
REDIS_URL: redis://redis:6379
DATABASE_URL: sqlite:///app/data/lily_llm.db
LOG_LEVEL: INFO
CELERY_BROKER_URL: redis://redis:6379/0
CELERY_RESULT_BACKEND: redis://redis:6379/0
```
## π§ λ°°ν¬ μ€ν¬λ¦½νΈ
### μ¬μ© κ°λ₯ν λͺ
λ Ήμ΄
```bash
# μ 체 λ°°ν¬
./scripts/deploy.sh deploy
# μλΉμ€ μμ
./scripts/deploy.sh start
# μλΉμ€ μ€μ§
./scripts/deploy.sh stop
# μλΉμ€ μ¬μμ
./scripts/deploy.sh restart
# λ°°ν¬ μ
λ°μ΄νΈ
./scripts/deploy.sh update
# λ‘κ·Έ νμΈ
./scripts/deploy.sh logs
# μν νμΈ
./scripts/deploy.sh status
# μ 리
./scripts/deploy.sh cleanup
# μ΄λ―Έμ§ λΉλ
./scripts/deploy.sh build
```
## π§ͺ ν
μ€νΈ
### Docker λ°°ν¬ ν
μ€νΈ
```bash
python scripts/test_docker_deployment.py
```
### μλ ν
μ€νΈ
```bash
# API μν νμΈ
curl http://localhost:8001/health
# λͺ¨λΈ λͺ©λ‘ νμΈ
curl http://localhost:8001/models
# ν
μ€νΈ μμ± ν
μ€νΈ
curl -X POST http://localhost:8001/generate \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "prompt=μλ
νμΈμ&model_id=polyglot-ko-1.3b-chat&max_length=50"
```
## π λͺ¨λν°λ§
### Flower (Celery λͺ¨λν°λ§)
- URL: http://localhost:5555
- μμ
μν, μ컀 μν, μ±λ₯ λ©νΈλ¦ νμΈ
### API λͺ¨λν°λ§
```bash
# μ±λ₯ λͺ¨λν°λ§ μμ
curl -X POST http://localhost:8001/monitoring/start
# μ±λ₯ μν νμΈ
curl http://localhost:8001/monitoring/status
# μμ€ν
κ±΄κ° μν
curl http://localhost:8001/monitoring/health
```
## π 보μ
### νκ²½ λ³μ κ΄λ¦¬
```bash
# .env νμΌ μμ±
cat > .env << EOF
SECRET_KEY=your-secret-key-here
JWT_SECRET_KEY=your-jwt-secret-key
DATABASE_URL=sqlite:///app/data/lily_llm.db
REDIS_URL=redis://redis:6379
EOF
```
### λ°©νλ²½ μ€μ
```bash
# νμν ν¬νΈλ§ μ΄κΈ°
sudo ufw allow 8001 # API μλ²
sudo ufw allow 5555 # Flower λͺ¨λν°λ§
```
## π μ±λ₯ μ΅μ ν
### 리μμ€ μ ν
```yaml
# docker-compose.ymlμ μΆκ°
services:
lily-llm-api:
deploy:
resources:
limits:
memory: 4G
cpus: '2.0'
reservations:
memory: 2G
cpus: '1.0'
```
### μΊμ μ€μ
```python
# Redis μΊμ νμ©
import redis
from functools import lru_cache
redis_client = redis.Redis(host='redis', port=6379, db=0)
@lru_cache(maxsize=128)
def cached_model_response(prompt, model_id):
# μΊμλ μλ΅ λ°ν
pass
```
## π¨ λ¬Έμ ν΄κ²°
### μΌλ°μ μΈ λ¬Έμ
#### 1. λ©λͺ¨λ¦¬ λΆμ‘±
```bash
# λ©λͺ¨λ¦¬ μ¬μ©λ νμΈ
docker stats
# λΆνμν 컨ν
μ΄λ μ 리
docker system prune -f
```
#### 2. API μλ΅ μμ
```bash
# 컨ν
μ΄λ μν νμΈ
docker-compose ps
# λ‘κ·Έ νμΈ
docker-compose logs lily-llm-api
# 컨ν
μ΄λ μ¬μμ
docker-compose restart lily-llm-api
```
#### 3. Redis μ°κ²° μ€ν¨
```bash
# Redis 컨ν
μ΄λ μν νμΈ
docker-compose logs redis
# Redis μ¬μμ
docker-compose restart redis
```
### λ‘κ·Έ λΆμ
```bash
# μ€μκ° λ‘κ·Έ νμΈ
docker-compose logs -f
# νΉμ μλΉμ€ λ‘κ·Έ
docker-compose logs -f lily-llm-api
# μ€λ₯ λ‘κ·Έλ§ νμΈ
docker-compose logs | grep ERROR
```
## π μ
λ°μ΄νΈ
### μ½λ μ
λ°μ΄νΈ
```bash
# μ΅μ μ½λ κ°μ Έμ€κΈ°
git pull origin main
# λ°°ν¬ μ
λ°μ΄νΈ
./scripts/deploy.sh update
```
### λͺ¨λΈ μ
λ°μ΄νΈ
```bash
# λͺ¨λΈ νμΌ κ΅μ²΄
cp new_model.safetensors ./models/
# μλΉμ€ μ¬μμ
docker-compose restart lily-llm-api
```
## π μΆκ° λ¬Έμ
- [API λ¬Έμ](http://localhost:8001/docs)
- [μ±λ₯ κ°μ΄λ](./PERFORMANCE.md)
- [보μ κ°μ΄λ](./SECURITY.md)
- [λͺ¨λν°λ§ κ°μ΄λ](./MONITORING.md)
## π€ μ§μ
λ¬Έμ κ° λ°μνλ©΄ λ€μμ νμΈνμΈμ:
1. λ‘κ·Έ νμΌ νμΈ
2. μμ€ν
리μμ€ νμΈ
3. λ€νΈμν¬ μ°κ²° νμΈ
4. νκ²½ λ³μ μ€μ νμΈ
## π λ³κ²½ λ‘κ·Έ
### v1.0.0 (2025-08-04)
- μ΄κΈ° Docker λ°°ν¬ μ€μ
- CI/CD νμ΄νλΌμΈ ꡬμΆ
- λͺ¨λν°λ§ μμ€ν
μΆκ°
- 보μ μ€μ κ°ν |