重构代码,统一config配置
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 47m14s

This commit is contained in:
2026-04-21 11:02:16 +08:00
parent 726236eaff
commit 8b354b7ccc
50 changed files with 4025 additions and 6 deletions

View File

@@ -57,6 +57,13 @@ class FrontendConfig:
api_url = os.getenv("API_URL", "http://127.0.0.1:8079")
self.api_base = api_url.replace("/chat", "").rstrip("/")
# 日志配置
self.log_level = os.getenv("LOG_LEVEL", "INFO").upper()
self.debug = os.getenv("DEBUG", "false").lower() == "true"
# 日志配置
self.log_level = os.getenv("LOG_LEVEL", "INFO").upper()
self.debug = os.getenv("DEBUG", "false").lower() == "true"
# 全局配置实例(单例模式)
config = FrontendConfig()

View File

@@ -4,6 +4,7 @@
"""
import os
from .config import config
import logging
from typing import Any
from dotenv import load_dotenv
@@ -14,10 +15,10 @@ load_dotenv()
# ==================== 日志配置 ====================
# 从环境变量读取日志级别,默认 INFO
LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO").upper()
LOG_LEVEL = config.log_level
# 根据环境变量控制是否显示详细调试信息
DEBUG_MODE = os.getenv("DEBUG", "false").lower() == "true"
DEBUG_MODE = config.debug
# 创建统一的日志器
logger = logging.getLogger("ai_agent_frontend")