codemo commited on
Commit
4f9e155
·
verified ·
1 Parent(s): 60e9657

Update config.py

Browse files
Files changed (1) hide show
  1. config.py +42 -42
config.py CHANGED
@@ -1,42 +1,42 @@
1
- import os
2
- from dataclasses import dataclass
3
-
4
-
5
- @dataclass
6
- class Config:
7
- api_key: str
8
- model_path: str
9
- # 视觉语言模型 - 本地
10
- vl_model_path: str
11
- # 视觉语言模型 - 在线 API (DashScope)
12
- vl_api_base: str
13
- vl_api_key: str
14
- vl_api_model: str
15
- vl_use_api: bool
16
- # 在线 API 最大调用次数限制(防止被刷爆,超出后自动降级到本地模型)
17
- vl_api_max_calls: int
18
- # 无论是否使用在线 API,始终加载本地 Qwen3-VL-2B-Instruct 模型
19
- vl_always_load_local: bool
20
- # 服务
21
- host: str
22
- port: int
23
- gradio_port: int
24
- device: str
25
-
26
-
27
- def load_config() -> Config:
28
- return Config(
29
- api_key=os.getenv("XGUARD_API_KEY", "your-api-key"),
30
- model_path=os.getenv("XGUARD_MODEL_PATH", "Alibaba-AAIG/YuFeng-XGuard-Reason-0.6B"),
31
- vl_model_path=os.getenv("XGUARD_VL_MODEL_PATH",""),
32
- vl_api_base=os.getenv("XGUARD_VL_API_BASE", "https://dashscope.aliyuncs.com/compatible-mode/v1"),
33
- vl_api_key=os.getenv("XGUARD_VL_API_KEY", ""),
34
- vl_api_model=os.getenv("XGUARD_VL_API_MODEL", "qwen-vl-max-latest"),
35
- vl_use_api=os.getenv("XGUARD_VL_USE_API", "").lower() in ("true", "1", "yes"),
36
- vl_api_max_calls=int(os.getenv("XGUARD_VL_API_MAX_CALLS", "")),
37
- vl_always_load_local=os.getenv("XGUARD_VL_ALWAYS_LOAD_LOCAL", "true").lower() in ("true", "1", "yes"),
38
- host=os.getenv("XGUARD_HOST", "0.0.0.0"),
39
- port=int(os.getenv("XGUARD_PORT", "8080")),
40
- gradio_port=int(os.getenv("XGUARD_GRADIO_PORT", "7860")),
41
- device=os.getenv("XGUARD_DEVICE", "auto"),
42
- )
 
1
+ import os
2
+ from dataclasses import dataclass
3
+
4
+
5
+ @dataclass
6
+ class Config:
7
+ api_key: str
8
+ model_path: str
9
+ # 视觉语言模型 - 本地
10
+ vl_model_path: str
11
+ # 视觉语言模型 - 在线 API (DashScope)
12
+ vl_api_base: str
13
+ vl_api_key: str
14
+ vl_api_model: str
15
+ vl_use_api: bool
16
+ # 在线 API 最大调用次数限制(防止被刷爆,超出后自动降级到本地模型)
17
+ vl_api_max_calls: int
18
+ # 无论是否使用在线 API,始终加载本地 Qwen3-VL-2B-Instruct 模型
19
+ vl_always_load_local: bool
20
+ # 服务
21
+ host: str
22
+ port: int
23
+ gradio_port: int
24
+ device: str
25
+
26
+
27
+ def load_config() -> Config:
28
+ return Config(
29
+ api_key=os.getenv("XGUARD_API_KEY", "your-api-key"),
30
+ model_path=os.getenv("XGUARD_MODEL_PATH", "Alibaba-AAIG/YuFeng-XGuard-Reason-0.6B"),
31
+ vl_model_path=os.getenv("XGUARD_VL_MODEL_PATH","Qwen/Qwen3-VL-2B-Instruct"),
32
+ vl_api_base=os.getenv("XGUARD_VL_API_BASE", "https://dashscope.aliyuncs.com/compatible-mode/v1"),
33
+ vl_api_key=os.getenv("XGUARD_VL_API_KEY", ""),
34
+ vl_api_model=os.getenv("XGUARD_VL_API_MODEL", "qwen-vl-max-latest"),
35
+ vl_use_api=os.getenv("XGUARD_VL_USE_API", "false").lower() in ("true", "1", "yes"),
36
+ vl_api_max_calls=int(os.getenv("XGUARD_VL_API_MAX_CALLS", "")),
37
+ vl_always_load_local=os.getenv("XGUARD_VL_ALWAYS_LOAD_LOCAL", "true").lower() in ("true", "1", "yes"),
38
+ host=os.getenv("XGUARD_HOST", "0.0.0.0"),
39
+ port=int(os.getenv("XGUARD_PORT", "8080")),
40
+ gradio_port=int(os.getenv("XGUARD_GRADIO_PORT", "7860")),
41
+ device=os.getenv("XGUARD_DEVICE", "auto"),
42
+ )