Files

51 lines
1.3 KiB
Python
Raw Permalink Normal View History

2026-04-10 16:52:07 +08:00
"""
配置管理模块
"""
from pydantic_settings import BaseSettings
from typing import Optional, List
class Settings(BaseSettings):
"""应用程序配置"""
# DeepSeek配置
deepseek_api_key: str
deepseek_base_url: str = "https://api.deepseek.com"
model_primary: str = "deepseek-chat"
temperature: float = 0.3
max_tokens: int = 4096
# Embedding / 向量检索(编码走远程 API,见 OPENAI_* / MODELSCOPE_* 等)
2026-04-10 16:52:07 +08:00
vector_dim: int = 2048
# Schema配置
schema_dir: str = "./data/schemas"
schema_file: Optional[str] = None # 特定schema文件路径
vector_db_path: str = "./data/embeddings/chroma"
# 验证配置
enable_sql_validation: bool = True
block_dangerous_sql: bool = True
dangerous_keywords: List[str] = ["DROP", "DELETE", "UPDATE", "INSERT", "ALTER", "TRUNCATE"]
# 重试配置
max_retry: int = 2
retry_delay: float = 1.0
# 日志配置
log_level: str = "INFO"
log_file: Optional[str] = None
2026-04-14 10:28:22 +08:00
# 业务库(backend/db:execute_sql / search_objects);与 .env 中 database_url 一致
database_url: Optional[str] = None
sql_max_rows: int = 10000
2026-04-10 16:52:07 +08:00
class Config:
env_file = ".env"
case_sensitive = False
# 全局配置实例
settings = Settings()