48 lines
2.2 KiB
Python
48 lines
2.2 KiB
Python
import os
|
||
|
||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||
from pydantic import Field
|
||
|
||
# ⚠️ 注意: 您需要安装 pydantic-settings: pip install pydantic-settings
|
||
DEBUG = os.environ.get("DEBUG", 1)
|
||
|
||
|
||
class Settings(BaseSettings):
|
||
"""
|
||
应用配置类。Pydantic Settings 会自动从环境变量和 .env 文件中加载这些值。
|
||
"""
|
||
model_config = SettingsConfigDict(
|
||
env_file='.env',
|
||
env_file_encoding='utf-8',
|
||
extra='ignore' # 忽略环境变量中多余的键
|
||
)
|
||
# 调试配饰
|
||
LOCAL: int = Field(default=0, description="是否在本地运行,1表示本地运行,0表示生产环境运行")
|
||
|
||
# Redis 配置
|
||
REDIS_HOST: str = Field(default='10.1.1.240', description="Redis服务器地址")
|
||
REDIS_PORT: int = Field(default=6379, description="Redis服务器端口")
|
||
REDIS_DB: int = Field(default=3, description="Redis数据库编号")
|
||
REDIS_HISTORY_KEY_PREFIX: str = Field(default="chat:history:", description="Redis会话历史键的前缀")
|
||
|
||
# LLM 配置
|
||
# GEMINI_API_KEY: str = Field(..., description="Google Gemini API 密钥。必须设置。")
|
||
LLM_MODEL_NAME: str = Field(default="gemini-2.5-flash", description="使用的 LLM 模型名称")
|
||
|
||
# 路径配置参数
|
||
DATA_ROOT: str = Field(default="/workspace/lc_stylist_agent/data", description="数据根目录")
|
||
OUTFIT_OUTPUT_DIR: str = Field(default="/workspace/lc_stylist_agent/data/outfit_output", description="生成的搭配图片输出目录")
|
||
STYLIST_GUIDE_DIR: str = Field(default="/workspace/lc_stylist_agent/data/stylist_guide", description="风格指南文本目录")
|
||
|
||
# 向量数据库配置参数
|
||
if DEBUG == 1:
|
||
VECTOR_DB_DIR: str = Field(default="/workspace/lc_stylist_agent/db", description="向量数据库目录")
|
||
else:
|
||
VECTOR_DB_DIR: str = Field(default="/db", description="向量数据库目录")
|
||
COLLECTION_NAME: str = Field(default="lc_clothing_embedding", description="向量数据库集合名称")
|
||
EMBEDDING_MODEL_NAME: str = Field(default="openai/clip-vit-base-patch32", description="CLIP嵌入模型名称")
|
||
|
||
|
||
# 创建配置实例,供应用其他部分使用
|
||
settings = Settings()
|