## Summary - 2D 픽셀아트 가상 오피스에서 AI 에이전트(Stock, Music)가 실제 작업 수행 - FastAPI + WebSocket 실시간 상태 동기화 + 텔레그램 봇 양방향 알림/승인 - BaseAgent FSM (idle/working/waiting/reporting/break), 서비스 프록시 패턴 - Docker Compose 서비스 (port 18900) + Nginx WebSocket 프록시 ## Changes (13 commits) - Backend scaffold: config, db, models, Dockerfile - WebSocket manager + Service proxy - BaseAgent FSM + StockAgent + MusicAgent - Telegram bot + Scheduler - FastAPI main (REST + WS endpoints) - Infrastructure: docker-compose + nginx - Code review fixes: HTTPException, async polling, input validation Reviewed-on: #2
35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
import httpx
|
|
from typing import Any, Dict, List, Optional
|
|
|
|
from .config import STOCK_LAB_URL, MUSIC_LAB_URL
|
|
|
|
_client = httpx.AsyncClient(timeout=30.0)
|
|
|
|
async def fetch_stock_news(limit: int = 10, category: str = None) -> List[Dict[str, Any]]:
|
|
params = {"limit": limit}
|
|
if category:
|
|
params["category"] = category
|
|
resp = await _client.get(f"{STOCK_LAB_URL}/api/stock/news", params=params)
|
|
resp.raise_for_status()
|
|
return resp.json()
|
|
|
|
async def fetch_stock_indices() -> Dict[str, Any]:
|
|
resp = await _client.get(f"{STOCK_LAB_URL}/api/stock/indices")
|
|
resp.raise_for_status()
|
|
return resp.json()
|
|
|
|
async def generate_music(payload: dict) -> Dict[str, Any]:
|
|
resp = await _client.post(f"{MUSIC_LAB_URL}/api/music/generate", json=payload)
|
|
resp.raise_for_status()
|
|
return resp.json()
|
|
|
|
async def get_music_status(task_id: str) -> Dict[str, Any]:
|
|
resp = await _client.get(f"{MUSIC_LAB_URL}/api/music/status/{task_id}")
|
|
resp.raise_for_status()
|
|
return resp.json()
|
|
|
|
async def get_music_credits() -> Dict[str, Any]:
|
|
resp = await _client.get(f"{MUSIC_LAB_URL}/api/music/credits")
|
|
resp.raise_for_status()
|
|
return resp.json()
|