init agent project
This commit is contained in:
35
common/__init__.py
Normal file
35
common/__init__.py
Normal file
@@ -0,0 +1,35 @@
|
||||
"""
|
||||
公共模块
|
||||
|
||||
提供所有 Agent 共用的基础配置和工具:
|
||||
- 环境变量加载(.env)
|
||||
- 日志配置
|
||||
- 模型调用日志回调
|
||||
"""
|
||||
|
||||
import os
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
# ============================================================
|
||||
# 项目根目录 & 环境初始化
|
||||
# ============================================================
|
||||
_PROJECT_ROOT = Path(__file__).parent.parent
|
||||
|
||||
# 加载 .env 文件
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv(_PROJECT_ROOT / ".env")
|
||||
|
||||
# ============================================================
|
||||
# 日志配置
|
||||
# ============================================================
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format="%(asctime)s [%(name)s] %(levelname)s - %(message)s",
|
||||
datefmt="%Y-%m-%d %H:%M:%S",
|
||||
)
|
||||
|
||||
from .logger import get_model_callbacks # noqa: E402
|
||||
|
||||
__all__ = ["get_model_callbacks"]
|
||||
Reference in New Issue
Block a user