|
@@ -2,7 +2,7 @@
|
|
|
应用配置模块
|
|
应用配置模块
|
|
|
"""
|
|
"""
|
|
|
from typing import List, Optional
|
|
from typing import List, Optional
|
|
|
-from pydantic import field_validator
|
|
|
|
|
|
|
+from pydantic import field_validator, Field
|
|
|
from pydantic_settings import BaseSettings
|
|
from pydantic_settings import BaseSettings
|
|
|
from functools import lru_cache
|
|
from functools import lru_cache
|
|
|
import os
|
|
import os
|
|
@@ -52,17 +52,17 @@ class Settings(BaseSettings):
|
|
|
# 文件上传配置
|
|
# 文件上传配置
|
|
|
UPLOAD_DIR: str = "./uploads"
|
|
UPLOAD_DIR: str = "./uploads"
|
|
|
MAX_FILE_SIZE: int = 5242880 # 5MB
|
|
MAX_FILE_SIZE: int = 5242880 # 5MB
|
|
|
- ALLOWED_EXTENSIONS: str = "jpg,jpeg,png,gif"
|
|
|
|
|
|
|
+ ALLOWED_EXTENSIONS: list[str] = Field(default_factory=lambda: ["jpg", "jpeg", "png", "gif"])
|
|
|
|
|
|
|
|
# 日志配置
|
|
# 日志配置
|
|
|
LOG_LEVEL: str = "INFO"
|
|
LOG_LEVEL: str = "INFO"
|
|
|
LOG_FILE: str = "./logs/app.log"
|
|
LOG_FILE: str = "./logs/app.log"
|
|
|
|
|
|
|
|
# CORS配置
|
|
# CORS配置
|
|
|
- CORS_ORIGINS: str = "http://localhost:3000,http://localhost:8080,http://localhost:3001"
|
|
|
|
|
|
|
+ CORS_ORIGINS: list[str] = Field(default_factory=list)
|
|
|
CORS_CREDENTIALS: bool = True
|
|
CORS_CREDENTIALS: bool = True
|
|
|
- CORS_METHODS: str = "*"
|
|
|
|
|
- CORS_HEADERS: str = "*"
|
|
|
|
|
|
|
+ CORS_METHODS: list[str] = Field(default_factory=lambda: ["*"])
|
|
|
|
|
+ CORS_HEADERS: list[str] = Field(default_factory=lambda: ["*"])
|
|
|
|
|
|
|
|
# 安全配置
|
|
# 安全配置
|
|
|
BCRYPT_ROUNDS: int = 12
|
|
BCRYPT_ROUNDS: int = 12
|
|
@@ -78,6 +78,13 @@ class Settings(BaseSettings):
|
|
|
CELERY_BROKER_URL: str = "redis://localhost:6379/1"
|
|
CELERY_BROKER_URL: str = "redis://localhost:6379/1"
|
|
|
CELERY_RESULT_BACKEND: str = "redis://localhost:6379/2"
|
|
CELERY_RESULT_BACKEND: str = "redis://localhost:6379/2"
|
|
|
|
|
|
|
|
|
|
+ # Milvus配置
|
|
|
|
|
+ MILVUS_HOST: str = "192.168.92.61"
|
|
|
|
|
+ MILVUS_PORT: int = 19530
|
|
|
|
|
+ MILVUS_DB: str = "lq_db"
|
|
|
|
|
+ MILVUS_USER: Optional[str] = "lq"
|
|
|
|
|
+ MILVUS_PASSWORD: Optional[str] = "lq123456!"
|
|
|
|
|
+
|
|
|
@field_validator("ALLOWED_EXTENSIONS", mode="before")
|
|
@field_validator("ALLOWED_EXTENSIONS", mode="before")
|
|
|
@classmethod
|
|
@classmethod
|
|
|
def parse_allowed_extensions(cls, v):
|
|
def parse_allowed_extensions(cls, v):
|