feat: AI 서버 관리 페이지 Phase 2 고급 기능 구현

🤖 모델 관리 고도화:
- 모델 다운로드: 인기 모델들 원클릭 설치 (llama, qwen, gemma, codellama, mistral)
- 모델 삭제: 확인 모달과 함께 안전한 삭제 기능
- 사용 가능한 모델 목록: 태그별 분류 (chat, code, lightweight 등)
- 모델 상세 정보: 설명, 크기, 용도별 태그 표시

�� 실시간 시스템 모니터링:
- CPU/메모리/디스크/GPU 사용률 원형 프로그레스바
- 색상 코딩: 사용률에 따른 시각적 구분 (녹색/주황/빨강)
- 실시간 업데이트: 30초마다 자동 새로고침
- 시스템 리소스 상세 정보 (코어 수, 용량, 온도 등)

🎨 고급 UI/UX:
- 모달 창: 부드러운 애니메이션과 블러 효과
- 원형 프로그레스바: CSS 기반 실시간 업데이트
- 반응형 디자인: 모바일 최적화
- 태그 시스템: 모델 분류 및 시각화

🔧 새 API 엔드포인트:
- POST /admin/models/download - 모델 다운로드
- DELETE /admin/models/{model_name} - 모델 삭제
- GET /admin/models/available - 다운로드 가능한 모델 목록
- GET /admin/system/stats - 시스템 리소스 사용률

수정된 파일:
- server/main.py: Phase 2 API 엔드포인트 추가
- test_admin.py: 테스트 모드 Phase 2 기능 추가
- templates/admin.html: 시스템 모니터링 섹션, 모달 창 추가
- static/admin.css: 모니터링 차트, 모달 스타일 추가
- static/admin.js: Phase 2 기능 JavaScript 구현
This commit is contained in:
Hyungi Ahn
2025-08-18 13:45:04 +09:00
parent e102ce6db9
commit b752e56b94
5 changed files with 814 additions and 0 deletions

View File

@@ -191,6 +191,116 @@ async def admin_delete_api_key(key_id: str, api_key: str = Depends(require_api_k
raise HTTPException(status_code=404, detail="API key not found")
# Phase 2: Advanced Model Management (Test Mode)
@app.post("/admin/models/download")
async def admin_download_model(request: dict, api_key: str = Depends(require_api_key)):
"""모델 다운로드 (테스트 모드)"""
model_name = request.get("model")
if not model_name:
raise HTTPException(status_code=400, detail="Model name is required")
# 테스트 모드에서는 시뮬레이션
return {
"success": True,
"message": f"Test mode: Model '{model_name}' download simulation started",
"details": f"In real mode, this would download {model_name} from Ollama registry"
}
@app.delete("/admin/models/{model_name}")
async def admin_delete_model(model_name: str, api_key: str = Depends(require_api_key)):
"""모델 삭제 (테스트 모드)"""
# 테스트 데이터에서 모델 제거
global test_models
test_models = [m for m in test_models if m["name"] != model_name]
return {
"success": True,
"message": f"Test mode: Model '{model_name}' deleted from test data",
"details": f"In real mode, this would delete {model_name} from Ollama"
}
@app.get("/admin/models/available")
async def admin_get_available_models(api_key: str = Depends(require_api_key)):
"""다운로드 가능한 모델 목록"""
available_models = [
{
"name": "llama3.2:1b",
"description": "Meta의 Llama 3.2 1B 모델 - 가벼운 작업용",
"size": "1.3GB",
"tags": ["chat", "lightweight"]
},
{
"name": "llama3.2:3b",
"description": "Meta의 Llama 3.2 3B 모델 - 균형잡힌 성능",
"size": "2.0GB",
"tags": ["chat", "recommended"]
},
{
"name": "qwen2.5:7b",
"description": "Alibaba의 Qwen 2.5 7B 모델 - 다국어 지원",
"size": "4.1GB",
"tags": ["chat", "multilingual"]
},
{
"name": "gemma2:2b",
"description": "Google의 Gemma 2 2B 모델 - 효율적인 추론",
"size": "1.6GB",
"tags": ["chat", "efficient"]
},
{
"name": "codellama:7b",
"description": "Meta의 Code Llama 7B - 코드 생성 특화",
"size": "3.8GB",
"tags": ["code", "programming"]
},
{
"name": "mistral:7b",
"description": "Mistral AI의 7B 모델 - 고성능 추론",
"size": "4.1GB",
"tags": ["chat", "performance"]
}
]
return {"available_models": available_models}
# Phase 2: System Monitoring (Test Mode)
@app.get("/admin/system/stats")
async def admin_get_system_stats(api_key: str = Depends(require_api_key)):
"""시스템 리소스 사용률 조회 (테스트 데이터)"""
import random
# 테스트용 랜덤 데이터 생성
return {
"cpu": {
"usage_percent": round(random.uniform(10, 80), 1),
"core_count": 8
},
"memory": {
"usage_percent": round(random.uniform(30, 90), 1),
"used_gb": round(random.uniform(4, 12), 1),
"total_gb": 16
},
"disk": {
"usage_percent": round(random.uniform(20, 70), 1),
"used_gb": round(random.uniform(50, 200), 1),
"total_gb": 500
},
"gpu": [
{
"name": "Test GPU (Simulated)",
"load": round(random.uniform(0, 100), 1),
"memory_used": round(random.uniform(1000, 8000)),
"memory_total": 8192,
"temperature": round(random.uniform(45, 75))
}
],
"timestamp": datetime.now().isoformat()
}
if __name__ == "__main__":
print("🚀 AI Server Admin Dashboard (Test Mode)")
print(f"📍 Server: http://localhost:{TEST_SERVER_PORT}")