53 lines
1.4 KiB
Python
53 lines
1.4 KiB
Python
from pydantic_settings import BaseSettings
|
|
from typing import Optional
|
|
from functools import lru_cache
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
# Japi Server 配置
|
|
host: str = "0.0.0.0"
|
|
port: int = 8113
|
|
debug: bool = False
|
|
|
|
# API路由配置
|
|
router_prefix: str = "/jmidjourney"
|
|
generate_route: str = "/generate" # 保留用于兼容
|
|
api_name: str = "jmidjourney" # 默认API名称
|
|
|
|
upload_url: str = "http://images.jingrow.com:8080/api/v1/image"
|
|
|
|
# VectorEngine API 配置
|
|
vectorengine_api_url: str = "https://api.vectorengine.ai"
|
|
vectorengine_token: Optional[str] = None
|
|
vectorengine_max_polling_attempts: int = 120 # 最大轮询次数
|
|
vectorengine_polling_interval: int = 3 # 轮询间隔(秒)
|
|
|
|
# 图片保存配置
|
|
save_dir: str = "../jfile/files"
|
|
# Japi 静态资源下载URL
|
|
download_url: str = "https://api.jingrow.com/files"
|
|
|
|
# Jingrow Jcloud API 配置
|
|
jingrow_api_url: str = "https://console.jingrow.com"
|
|
jingrow_api_key: Optional[str] = None
|
|
jingrow_api_secret: Optional[str] = None
|
|
|
|
# 代理配置(用于下载外部图片)
|
|
http_proxy: Optional[str] = None
|
|
https_proxy: Optional[str] = None
|
|
|
|
# 超时设置(秒)
|
|
request_timeout: int = 30
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
|
|
|
|
@lru_cache()
|
|
def get_settings() -> Settings:
|
|
return Settings()
|
|
|
|
|
|
# 创建全局配置实例
|
|
settings = get_settings()
|