2025-11-02 01:25:30 +08:00

64 lines
1.6 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.

from pydantic_settings import BaseSettings
from functools import lru_cache
from jingrow.utils.path import get_root_path
class Settings(BaseSettings):
"""应用配置"""
# Jingrow API配置
jingrow_server_url: str = ''
jingrow_api_key: str = ''
jingrow_api_secret: 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 = ''
# 本地后端主机配置
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
# Qdrant 向量数据库配置
qdrant_host: str = ''
qdrant_port: int = 6333
# 数据库配置
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'
# 运行模式
run_mode: str = 'api'
# 环境development/production控制启动模式、热重载等
environment: str = 'development'
# 日志级别DEBUG/INFO/WARNING/ERROR/CRITICAL全局默认级别
log_level: str = 'INFO'
class Config:
env_file = str(get_root_path() / '.env')
env_file_encoding = 'utf-8'
case_sensitive = False
@lru_cache()
def get_settings() -> Settings:
"""获取配置实例(单例模式)"""
return Settings()
# 全局配置实例
Config = get_settings()