51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
"""全局配置 — 硬编码,个人工具不依赖 .env。"""
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from pydantic import Field
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
model_config = SettingsConfigDict(
|
|
env_file=None, # 不读取 .env
|
|
extra="ignore",
|
|
)
|
|
|
|
# 数据源 API Key(个人工具直接写死;如分享代码请改为空字符串或从环境变量注入)
|
|
tickflow_api_key: str = "tk_94a20304993f45b5b0e376b9767597cc"
|
|
|
|
# AI(可选,留空即关闭)
|
|
ai_provider: str = "openai_compat"
|
|
ai_base_url: str = "https://api.deepseek.com/v1"
|
|
ai_api_key: str = ""
|
|
ai_model: str = "deepseek-chat"
|
|
ai_daily_token_budget: int = 500_000
|
|
|
|
# Server
|
|
host: str = "0.0.0.0"
|
|
port: int = 3018
|
|
log_level: str = "INFO"
|
|
backtest_range_guard: bool = False
|
|
|
|
# 访问门控:留空则不启用,部署时通过 ACCESS_UUID 环境变量注入
|
|
# 优先级:ADMIN_TOKEN > 动态 UUID > ACCESS_UUID
|
|
access_uuid: str = ""
|
|
# 管理员初始令牌,硬编码以便开箱即用;如需更安全可改为空字符串并从环境变量 ADMIN_TOKEN 注入
|
|
admin_token: str = "admin7226132"
|
|
|
|
# 路径 — 硬编码为 Docker 容器内路径,确保数据持久化
|
|
data_dir: Path = Path("/app/data")
|
|
tiers_yaml: Path = Path("/app/tiers.yaml")
|
|
static_dir: Path = Path("/app/static")
|
|
|
|
@property
|
|
def use_free_mode(self) -> bool:
|
|
"""是否走 Free 模式。优先看 secrets.json,其次看 .env。"""
|
|
from app import secrets_store
|
|
return not secrets_store.get_tickflow_key()
|
|
|
|
|
|
settings = Settings()
|