66 lines
2.1 KiB
Python
66 lines
2.1 KiB
Python
from pydantic_settings import BaseSettings
|
|
from typing import Optional, Dict
|
|
from functools import lru_cache
|
|
|
|
class Settings(BaseSettings):
|
|
# Japi Server 配置
|
|
host: str = "0.0.0.0"
|
|
port: int = 8113
|
|
debug: bool = True
|
|
|
|
# API路由配置
|
|
router_prefix: str = "/midjourney"
|
|
generate_route: str = "/generate" # 生成图片的路由
|
|
batch_route: str = "/batch" # 批量处理图片的路由
|
|
api_name: str = "midjourney" # 默认API名称
|
|
|
|
upload_url: str = "http://images.jingrow.com:8080/api/v1/image"
|
|
|
|
# 图片保存配置
|
|
save_dir: str = "../jfile/files"
|
|
# Japi 静态资源下载URL
|
|
download_url: str = "http://api.jingrow.com:9080/files"
|
|
|
|
# Jingrow Jcloud API 配置
|
|
jingrow_api_url: str = "https://cloud.jingrow.com"
|
|
jingrow_api_key: Optional[str] = None
|
|
jingrow_api_secret: Optional[str] = None
|
|
|
|
# Discord Midjourney配置
|
|
midjourney_api_url: str = "https://discord.com/api/v9"
|
|
midjourney_application_id: str = "936929561302675456"
|
|
midjourney_data_id: str = "938956540159881230"
|
|
midjourney_data_version: str = "1237876415471554623"
|
|
midjourney_session_id: str = "a64ede0f3ce497d949e2f6f195c19029"
|
|
midjourney_channel_id: str = "1259838588510670941"
|
|
midjourney_oauth_token: str = "MTA4NzQ0MDY0MTU5MzcxNjc0Ng.GVDauj.6Cwr5EpXOfN9FpQU0-VfteR56XQOwLLUGYovG0"
|
|
midjourney_suffix: str = "mj" # 图片文件名的后缀
|
|
|
|
# 代理配置
|
|
http_proxy: Optional[str] = "http://127.0.0.1:1080" # 默认HTTP代理
|
|
https_proxy: Optional[str] = "http://127.0.0.1:1080" # 默认HTTPS代理
|
|
|
|
# Midjourney默认选项
|
|
midjourney_default_options: Dict = {
|
|
"ar": "1:1",
|
|
"v": "6.1",
|
|
"quality": "1"
|
|
}
|
|
|
|
# 图像设置
|
|
add_title_to_image_name: bool = False # 是否将标题添加到图片名称中
|
|
|
|
# 超时设置(秒)
|
|
request_timeout: int = 30
|
|
max_polling_attempts: int = 60
|
|
polling_interval: int = 3
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
|
|
@lru_cache()
|
|
def get_settings() -> Settings:
|
|
return Settings()
|
|
|
|
# 创建全局配置实例
|
|
settings = get_settings() |