feat: Conversation sqlite 영구화 — 재시작에도 컨텍스트 유지
- db/database.py: conversation_messages 테이블 + save/load/cleanup 헬퍼 - conversation.py: write-through (memory + DB) + lazy load on first access - 메모리 캐시 1시간 TTL, DB 7일 보관 - add/get/format_for_prompt가 async로 변경 - worker.py: 모든 conversation_store 호출에 await 추가 - main.py lifespan에 startup cleanup 호출 (7일 이상 정리) 서버 재시작 후 "방금 그거 더 자세히" 같은 후속 질문이 컨텍스트 유지 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -24,6 +24,15 @@ logging.basicConfig(
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
await init_db()
|
||||
# 7일 이상 오래된 대화 정리
|
||||
try:
|
||||
from db.database import cleanup_old_conversations
|
||||
deleted = await cleanup_old_conversations(days=7)
|
||||
if deleted:
|
||||
import logging
|
||||
logging.getLogger(__name__).info("Cleaned up %d old conversation messages", deleted)
|
||||
except Exception:
|
||||
pass
|
||||
backend_registry.init_from_settings(settings)
|
||||
backend_registry.start_health_loop(settings.health_check_interval)
|
||||
jq_module.init_queue(settings.max_concurrent_jobs)
|
||||
|
||||
Reference in New Issue
Block a user