From 5dd7b6d601d9667dbc0f37e17fc7066cc5d8c26d Mon Sep 17 00:00:00 2001 From: gahusb Date: Mon, 13 Apr 2026 02:33:55 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20Ollama=20=ED=83=80=EC=9E=84=EC=95=84?= =?UTF-8?q?=EC=9B=83=2060s->180s=20+=20=EC=97=90=EB=9F=AC=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=20=EB=A1=9C=EA=B9=85=20+=20=ED=85=94=EB=A0=88?= =?UTF-8?q?=EA=B7=B8=EB=9E=A8=20chat.id=20=EB=94=94=EB=B2=84=EA=B7=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- agent-office/app/service_proxy.py | 3 ++- stock-lab/app/ai_summarizer.py | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/agent-office/app/service_proxy.py b/agent-office/app/service_proxy.py index c55b2d2..e954c70 100644 --- a/agent-office/app/service_proxy.py +++ b/agent-office/app/service_proxy.py @@ -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}, diff --git a/stock-lab/app/ai_summarizer.py b/stock-lab/app/ai_summarizer.py index bacadef..cb9eb84 100644 --- a/stock-lab/app/ai_summarizer.py +++ b/stock-lab/app/ai_summarizer.py @@ -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]}")