64 lines
1.7 KiB
Python
64 lines
1.7 KiB
Python
from pydantic_settings import BaseSettings
|
||
from functools import lru_cache
|
||
from pathlib import Path
|
||
|
||
|
||
class Settings(BaseSettings):
|
||
"""应用配置"""
|
||
|
||
# Jingrow API配置
|
||
jingrow_server_url: str = ''
|
||
jingrow_api_key: str = ''
|
||
jingrow_api_secret: str = ''
|
||
jingrow_session_cookie: str = ''
|
||
jingrow_site: str = ''
|
||
|
||
# Jingrow Cloud API配置
|
||
jingrow_cloud_url: str = 'https://cloud.jingrow.com'
|
||
jingrow_cloud_api_url: str = 'https://api.jingrow.com'
|
||
jingrow_cloud_api_key: str = ''
|
||
jingrow_cloud_api_secret: str = ''
|
||
|
||
# 数据库配置
|
||
jingrow_db_host: str = 'localhost'
|
||
jingrow_db_port: str = '3306'
|
||
jingrow_db_name: str = 'jingrow_local'
|
||
jingrow_db_user: str = 'root'
|
||
jingrow_db_password: str = ''
|
||
jingrow_db_type: str = 'mariadb'
|
||
|
||
# Qdrant 向量数据库配置
|
||
qdrant_host: str = ''
|
||
qdrant_port: int = 6333
|
||
|
||
# 运行模式
|
||
run_mode: str = 'api'
|
||
# 环境:development/production(控制启动模式、热重载等)
|
||
environment: str = 'development'
|
||
# 日志级别:DEBUG/INFO/WARNING/ERROR/CRITICAL(全局默认级别)
|
||
log_level: str = 'INFO'
|
||
|
||
# 本地后端主机配置
|
||
backend_host: str = '0.0.0.0'
|
||
backend_port: int = 9001
|
||
backend_reload: bool = True
|
||
|
||
# 异步任务队列(Dramatiq)配置
|
||
worker_processes: int = 1
|
||
worker_threads: int = 1
|
||
watch: bool = True
|
||
|
||
class Config:
|
||
env_file = str(Path(__file__).resolve().parents[3] / '.env')
|
||
env_file_encoding = 'utf-8'
|
||
case_sensitive = False
|
||
|
||
|
||
@lru_cache()
|
||
def get_settings() -> Settings:
|
||
"""获取配置实例(单例模式)"""
|
||
return Settings()
|
||
|
||
|
||
# 全局配置实例
|
||
Config = get_settings() |