CatPtain commited on
Commit
bbd2fdd
·
verified ·
1 Parent(s): a9a0691

Upload 66 files

Browse files
Files changed (1) hide show
  1. app/config/config.py +16 -2
app/config/config.py CHANGED
@@ -29,7 +29,7 @@ from app.log.logger import Logger
29
 
30
  class Settings(BaseSettings):
31
  # 数据库配置
32
- DATABASE_TYPE: str = "mysql" # sqlite 或 mysql
33
  SQLITE_DATABASE: str = "default_db"
34
  MYSQL_HOST: str = ""
35
  MYSQL_PORT: int = 3306
@@ -52,7 +52,14 @@ class Settings(BaseSettings):
52
 
53
  # API相关配置
54
  API_KEYS: List[str]
55
- ALLOWED_TOKENS: List[str]
 
 
 
 
 
 
 
56
  BASE_URL: str = f"https://generativelanguage.googleapis.com/{API_VERSION}"
57
  AUTH_TOKEN: str = ""
58
  MAX_FAILURES: int = 3
@@ -72,6 +79,13 @@ class Settings(BaseSettings):
72
  IMAGE_MODELS: List[str] = ["gemini-2.0-flash-exp"]
73
  FILTERED_MODELS: List[str] = DEFAULT_FILTER_MODELS
74
  TOOLS_CODE_EXECUTION_ENABLED: bool = False
 
 
 
 
 
 
 
75
  SHOW_SEARCH_LINK: bool = True
76
  SHOW_THINKING_PROCESS: bool = True
77
  THINKING_MODELS: List[str] = []
 
29
 
30
  class Settings(BaseSettings):
31
  # 数据库配置
32
+ DATABASE_TYPE: str = "sqlite" # sqlite 或 mysql
33
  SQLITE_DATABASE: str = "default_db"
34
  MYSQL_HOST: str = ""
35
  MYSQL_PORT: int = 3306
 
52
 
53
  # API相关配置
54
  API_KEYS: List[str]
55
+ ALLOWED_TOKENS: List[str] = []
56
+
57
+ @field_validator("ALLOWED_TOKENS", mode="before")
58
+ @classmethod
59
+ def parse_allowed_tokens(cls, v: Any) -> List[str]:
60
+ if isinstance(v, str):
61
+ return [token.strip() for token in v.split(",") if token.strip()]
62
+ return v
63
  BASE_URL: str = f"https://generativelanguage.googleapis.com/{API_VERSION}"
64
  AUTH_TOKEN: str = ""
65
  MAX_FAILURES: int = 3
 
79
  IMAGE_MODELS: List[str] = ["gemini-2.0-flash-exp"]
80
  FILTERED_MODELS: List[str] = DEFAULT_FILTER_MODELS
81
  TOOLS_CODE_EXECUTION_ENABLED: bool = False
82
+
83
+ @field_validator("TOOLS_CODE_EXECUTION_ENABLED", mode="before")
84
+ @classmethod
85
+ def parse_boolean(cls, v: Any) -> bool:
86
+ if isinstance(v, str):
87
+ return v.lower() == "true"
88
+ return v
89
  SHOW_SEARCH_LINK: bool = True
90
  SHOW_THINKING_PROCESS: bool = True
91
  THINKING_MODELS: List[str] = []