2025-10-24 15:33:00 +08:00
|
|
|
|
import os
|
|
|
|
|
|
|
2025-10-16 14:04:42 +08:00
|
|
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
from pydantic import Field
|
|
|
|
|
|
|
2025-12-16 17:29:05 +08:00
|
|
|
|
|
2025-10-16 14:04:42 +08:00
|
|
|
|
# ⚠️ 注意: 您需要安装 pydantic-settings: pip install pydantic-settings
|
2025-10-24 15:33:00 +08:00
|
|
|
|
|
2025-10-16 14:04:42 +08:00
|
|
|
|
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
|
|
|
|
"""
|
|
|
|
|
|
应用配置类。Pydantic Settings 会自动从环境变量和 .env 文件中加载这些值。
|
|
|
|
|
|
"""
|
|
|
|
|
|
model_config = SettingsConfigDict(
|
2025-10-24 10:37:19 +08:00
|
|
|
|
env_file='.env',
|
|
|
|
|
|
env_file_encoding='utf-8',
|
|
|
|
|
|
extra='ignore' # 忽略环境变量中多余的键
|
2025-10-16 14:04:42 +08:00
|
|
|
|
)
|
2025-12-24 11:30:11 +08:00
|
|
|
|
# 启动端口
|
|
|
|
|
|
SERVE_PROD: int = Field(default=8000, description='')
|
2025-12-09 16:06:07 +08:00
|
|
|
|
# 调试配饰
|
|
|
|
|
|
LOCAL: int = Field(default=0, description="是否在本地运行,1表示本地运行,0表示生产环境运行")
|
2025-10-16 14:04:42 +08:00
|
|
|
|
|
|
|
|
|
|
# Redis 配置
|
2025-10-24 10:37:19 +08:00
|
|
|
|
REDIS_HOST: str = Field(default='10.1.1.240', description="Redis服务器地址")
|
2025-10-16 14:04:42 +08:00
|
|
|
|
REDIS_PORT: int = Field(default=6379, description="Redis服务器端口")
|
2025-10-24 10:37:19 +08:00
|
|
|
|
REDIS_DB: int = Field(default=3, description="Redis数据库编号")
|
2025-10-16 14:04:42 +08:00
|
|
|
|
REDIS_HISTORY_KEY_PREFIX: str = Field(default="chat:history:", description="Redis会话历史键的前缀")
|
|
|
|
|
|
|
|
|
|
|
|
# LLM 配置
|
2025-10-24 10:37:19 +08:00
|
|
|
|
# GEMINI_API_KEY: str = Field(..., description="Google Gemini API 密钥。必须设置。")
|
2025-10-16 14:04:42 +08:00
|
|
|
|
LLM_MODEL_NAME: str = Field(default="gemini-2.5-flash", description="使用的 LLM 模型名称")
|
2025-10-24 10:37:19 +08:00
|
|
|
|
|
2025-10-16 14:04:42 +08:00
|
|
|
|
# 路径配置参数
|
2025-12-09 16:06:07 +08:00
|
|
|
|
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="风格指南文本目录")
|
2025-10-24 10:37:19 +08:00
|
|
|
|
|
2025-10-16 14:04:42 +08:00
|
|
|
|
# 向量数据库配置参数
|
2025-12-16 17:29:05 +08:00
|
|
|
|
VECTOR_DB_DIR: str = Field(default="/db", description="向量数据库目录")
|
2025-10-16 14:04:42 +08:00
|
|
|
|
COLLECTION_NAME: str = Field(default="lc_clothing_embedding", description="向量数据库集合名称")
|
|
|
|
|
|
EMBEDDING_MODEL_NAME: str = Field(default="openai/clip-vit-base-patch32", description="CLIP嵌入模型名称")
|
|
|
|
|
|
|
2025-12-16 17:29:05 +08:00
|
|
|
|
# minio配置
|
|
|
|
|
|
MINIO_URL: str = Field(default="", description="URL")
|
|
|
|
|
|
MINIO_ACCESS: str = Field(default="", description="ACCESS")
|
|
|
|
|
|
MINIO_SECRET: str = Field(default="", description="SECRET")
|
|
|
|
|
|
MINIO_SECURE: bool = Field(default=True, description="SECRET")
|
|
|
|
|
|
MINIO_LC_DATA_PATH: str = Field(default="", description="图片数据路径")
|
|
|
|
|
|
|
2025-10-24 10:37:19 +08:00
|
|
|
|
|
2025-10-16 14:04:42 +08:00
|
|
|
|
# 创建配置实例,供应用其他部分使用
|
|
|
|
|
|
settings = Settings()
|