refactor(logging): introduce centralized logging and FastAPI lifespan
Some checks failed
Build and Push Docker / build-and-push (push) Failing after 2m38s

This commit is contained in:
gameloader
2025-10-13 10:17:19 +08:00
parent 0e5199d3c0
commit f1a48874d0
5 changed files with 175 additions and 24 deletions

View File

@ -1,11 +1,15 @@
# main.py
import sys
import logging
from haystack import Document
# 需要 OpenAIDocumentEmbedder 来嵌入要写入的文档
from haystack.components.embedders import OpenAIDocumentEmbedder
from haystack.utils import Secret
# 设置logger
logger = logging.getLogger(__name__)
# 导入所需的配置和构建函数
from config import (
DEFAULT_USER_ID,
@ -130,7 +134,7 @@ def run_chat_session(user_id: str):
print(f"Chatbot: {answer} (Tokens: {total_tokens})")
else:
print("Chatbot: Sorry, I couldn't generate an answer for that.")
print("Debug Info (Pipeline Results):", results) # 打印完整结果以供调试
logger.debug(f"Pipeline Results: {results}") # 记录调试信息
except KeyboardInterrupt:
print("\nExiting chat session. Goodbye!")