fix: Ollama 타임아웃 60s->180s + 에러 타입 로깅 + 텔레그램 chat.id 디버그
This commit is contained in:
@@ -22,7 +22,8 @@ async def summarize_stock_news(limit: int = 15) -> Dict[str, Any]:
|
||||
"""stock-lab의 AI 요약 엔드포인트 호출.
|
||||
반환: {"summary": str, "tokens": {...}, "model": str, "duration_ms": int, "article_count": int}
|
||||
"""
|
||||
async with httpx.AsyncClient(timeout=90.0) as client:
|
||||
# stock-lab 내부 Ollama 호출이 180s까지 가능하므로 여유있게 200s
|
||||
async with httpx.AsyncClient(timeout=200.0) as client:
|
||||
resp = await client.post(
|
||||
f"{STOCK_LAB_URL}/api/stock/news/summarize",
|
||||
json={"limit": limit},
|
||||
|
||||
@@ -76,11 +76,14 @@ async def summarize_news(articles: List[Dict[str, Any]]) -> Dict[str, Any]:
|
||||
|
||||
started = time.monotonic()
|
||||
try:
|
||||
async with httpx.AsyncClient(timeout=60.0) as client:
|
||||
# qwen3:14b 첫 모델 로드 + 장문 추론은 60s로는 부족 → 180s로 확장
|
||||
async with httpx.AsyncClient(timeout=180.0) as client:
|
||||
resp = await client.post(url, json=payload)
|
||||
except httpx.HTTPError as e:
|
||||
logger.error(f"Ollama 연결 실패 ({url}): {e}")
|
||||
raise OllamaError(f"Ollama 연결 실패: {e}") from e
|
||||
err_type = type(e).__name__
|
||||
err_msg = str(e) or "(no message)"
|
||||
logger.error(f"Ollama 연결 실패 ({url}): [{err_type}] {err_msg}")
|
||||
raise OllamaError(f"Ollama 연결 실패: [{err_type}] {err_msg}") from e
|
||||
|
||||
if resp.status_code != 200:
|
||||
logger.error(f"Ollama 응답 오류 {resp.status_code}: {resp.text[:200]}")
|
||||
|
||||
Reference in New Issue
Block a user