62 lines
2.2 KiB
Python
62 lines
2.2 KiB
Python
"""配置:仓库根 .env 或环境变量。"""
|
||
from __future__ import annotations
|
||
|
||
from functools import lru_cache
|
||
from pathlib import Path
|
||
|
||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||
|
||
# 仓库根(server/ 的上一级)
|
||
ROOT = Path(__file__).resolve().parents[1]
|
||
|
||
|
||
class Settings(BaseSettings):
|
||
model_config = SettingsConfigDict(
|
||
env_file=str(ROOT / ".env"),
|
||
env_file_encoding="utf-8",
|
||
extra="ignore",
|
||
)
|
||
|
||
# ── 服务 ──
|
||
# 不要用 5000/7000:macOS 隔空播放接收器占用(IPv6 localhost 会被截走)
|
||
host: str = "127.0.0.1"
|
||
port: int = 3300
|
||
app_base_url: str = "http://127.0.0.1:3300"
|
||
|
||
# ── 存储 ──
|
||
data_dir: str = str(ROOT / "data")
|
||
|
||
# ── 图像生成 provider:doubao(火山方舟 Seedream)| tongyi(阿里 DashScope)──
|
||
image_provider: str = "doubao"
|
||
request_timeout: int = 300 # 单张生图请求超时(秒)
|
||
poll_max_wait: int = 600 # 异步任务轮询上限(秒)
|
||
|
||
# 豆包 / 火山方舟
|
||
ark_api_key: str = ""
|
||
ark_base_url: str = "https://ark.cn-beijing.volces.com/api/v3/images/generations"
|
||
ark_image_model: str = "doubao-seedream-4-5-251128"
|
||
|
||
# 通义 / DashScope
|
||
dashscope_api_key: str = ""
|
||
dashscope_base_url: str = "" # 留空按模型自动选择万象异步/千问同步端点
|
||
dashscope_model: str = "wan2.7-image-pro"
|
||
|
||
# RightAPI(OpenAI 兼容中转,gpt-image 系列)
|
||
rightapi_api_key: str = ""
|
||
rightapi_base_url: str = "https://rightapi.ai/draw"
|
||
rightapi_image_model: str = "gpt-image-2"
|
||
rightapi_image_quality: str = "high" # auto | low | medium | high
|
||
rightapi_max_retries: int = 3 # 429/5xx/超时的重试次数(1 = 不重试)
|
||
rightapi_retry_wait: int = 60 # 重试基础等待秒数,按 60→120→240 递增
|
||
rightapi_input_fidelity: str = "high" # edits 端点高保真档(high | low,留空关闭)
|
||
|
||
# DeepSeek(出图方案规划器)
|
||
deepseek_api_key: str = ""
|
||
deepseek_base_url: str = "https://api.deepseek.com/v1"
|
||
deepseek_model: str = "deepseek-v4-flash"
|
||
|
||
|
||
@lru_cache
|
||
def get_settings() -> Settings:
|
||
return Settings()
|