first commit
This commit is contained in:
26
src/core/config.py
Normal file
26
src/core/config.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
from pydantic import Field
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
"""
|
||||
应用配置类。Pydantic Settings 会自动从环境变量和 .env 文件中加载这些值。
|
||||
"""
|
||||
model_config = SettingsConfigDict(
|
||||
env_file='.env',
|
||||
env_file_encoding='utf-8',
|
||||
extra='ignore' # 忽略环境变量中多余的键
|
||||
)
|
||||
# --- google api 配置信息 ---
|
||||
GOOGLE_GENAI_USE_VERTEXAI: str = Field(default="", description="")
|
||||
GOOGLE_API_KEY: str = Field(default="", description="")
|
||||
|
||||
# --- mongodb配置信息 ---
|
||||
MONGODB_USERNAME: str = Field(default="", description="")
|
||||
MONGODB_PASSWORD: str = Field(default="", description="")
|
||||
MONGODB_HOST: str = Field(default="localhost", description="")
|
||||
MONGODB_PORT: int = Field(default=27017, description="")
|
||||
|
||||
|
||||
settings = Settings()
|
||||
MONGO_URI = f"mongodb://{settings.MONGODB_USERNAME}:{settings.MONGODB_PASSWORD}@{settings.MONGODB_HOST}:{settings.MONGODB_PORT}"
|
||||
Reference in New Issue
Block a user