Phase 27: P2 quality improvements — logging, httpx pooling, validation, tests

- app.py: replace print() with logging, basicConfig with LOG_LEVEL env var
- api_client.py: shared AsyncClient instance (connection pooling), URL-encode
  delete_document path parameter, aclose() for cleanup
- services/document.py: validate file exists and extension before ingest
- tests/: ChatService (4) + DocumentService (6) unit tests via pytest-asyncio
- pyproject.toml: asyncio_mode = auto
- requirements-dev.txt: pytest, pytest-asyncio

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
sal
2026-06-01 17:52:43 +09:00
parent 511c87b290
commit 148211e236
10 changed files with 184 additions and 73 deletions
+10 -2
View File
@@ -8,6 +8,7 @@
YOULBOT_API_TOKEN= ← api.py에 API_TOKEN 설정 시 동일 값
"""
import html as _html
import logging
import os
import gradio as gr
@@ -15,6 +16,13 @@ from dotenv import load_dotenv
load_dotenv()
logging.basicConfig(
level=os.getenv("LOG_LEVEL", "INFO").upper(),
format="%(asctime)s %(levelname)-8s %(name)s%(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
logger = logging.getLogger(__name__)
from config import AppConfig
from container import Container
@@ -136,7 +144,7 @@ async def handle_feedback(like_data: gr.LikeData, history, run_ids, user_id):
try:
await container.chat_service.save_feedback(user_id, user_msg, asst_msg, rating, run_id)
except Exception as e:
print(f"[Feedback] 저장 실패: {e}")
logger.error("피드백 저장 실패: %s", e)
def switch_user(user_id):
@@ -147,7 +155,7 @@ async def reset_chat(user_id):
try:
await container.chat_service.reset(user_id)
except Exception as e:
print(f"[Reset] 실패: {e}")
logger.error("대화 초기화 실패: %s", e)
return [], []