添加Ai 能力,重构项目结构
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from .settings import Settings
|
||||
|
||||
_env = os.getenv("ENV", "dev")
|
||||
_env_files = {"dev": ".env", "test": ".env.test", "prod": ".env.prod"}
|
||||
|
||||
# 定位项目根目录(config 上两级)
|
||||
_project_root = Path(__file__).resolve().parent.parent.parent
|
||||
_env_file = _project_root / _env_files.get(_env, ".env")
|
||||
|
||||
if not _env_file.exists():
|
||||
raise FileNotFoundError(f".env 文件不存在: {_env_file}")
|
||||
|
||||
settings = Settings(_env_file=str(_env_file))
|
||||
|
||||
__all__ = ["settings"]
|
||||
@@ -0,0 +1,22 @@
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
"""项目配置,通过环境变量或项目根目录下的 .env 文件覆盖。"""
|
||||
|
||||
env: str = "dev"
|
||||
|
||||
# 火山引擎(OpenAI 兼容风格)
|
||||
volcengine_api_key: str = ""
|
||||
volcengine_base_url: str = "https://ark.cn-beijing.volces.com/api/v3"
|
||||
|
||||
# Claude(Anthropic 风格)
|
||||
anthropic_api_key: str = ""
|
||||
anthropic_base_url: str = ""
|
||||
|
||||
model_config = SettingsConfigDict(
|
||||
env_file=".env",
|
||||
env_file_encoding="utf-8",
|
||||
case_sensitive=False,
|
||||
extra="ignore",
|
||||
)
|
||||
Reference in New Issue
Block a user