Files
image-suite-studio/server/config.py
T
2026-08-17 17:28:02 +08:00

59 lines
1.9 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""配置:仓库根 .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/7000macOS 隔空播放接收器占用(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")
# ── 图像生成 providerdoubao(火山方舟 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"
# RightAPIOpenAI 兼容中转,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
# 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()