feat: new file
This commit is contained in:
42
backend/app/settings.py
Normal file
42
backend/app/settings.py
Normal file
@@ -0,0 +1,42 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore")
|
||||
|
||||
mysql_host: str
|
||||
mysql_port: int = 3306
|
||||
mysql_user: str
|
||||
mysql_password: str
|
||||
mysql_database: str
|
||||
|
||||
openai_api_key: str | None = None
|
||||
openai_model: str = "gpt-4.1-mini"
|
||||
openai_embed_model: str = "text-embedding-3-small"
|
||||
|
||||
milvus_host: str = "localhost"
|
||||
milvus_port: int = 19530
|
||||
milvus_collection: str = "products_v1"
|
||||
|
||||
app_env: str = "dev"
|
||||
app_cors_origins: str = "http://localhost:3000"
|
||||
debug_print_db_sample: bool = False
|
||||
debug_db_sample_limit: int = 10
|
||||
debug_db_sample_max_str_len: int = 120
|
||||
|
||||
@property
|
||||
def mysql_url(self) -> str:
|
||||
return (
|
||||
f"mysql+pymysql://{self.mysql_user}:{self.mysql_password}"
|
||||
f"@{self.mysql_host}:{self.mysql_port}/{self.mysql_database}?charset=utf8mb4"
|
||||
)
|
||||
|
||||
@property
|
||||
def cors_origins_list(self) -> list[str]:
|
||||
return [o.strip() for o in self.app_cors_origins.split(",") if o.strip()]
|
||||
|
||||
|
||||
settings = Settings()
|
||||
|
||||
Reference in New Issue
Block a user