Update config.py
Browse files
config.py
CHANGED
@@ -1,96 +1,96 @@
|
|
1 |
-
"""
|
2 |
-
配置文件 - 存储应用的所有配置参数
|
3 |
-
"""
|
4 |
-
import os
|
5 |
-
import secrets
|
6 |
-
|
7 |
-
# 基本目录配置
|
8 |
-
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
9 |
-
DATA_DIR = os.path.join(BASE_DIR, 'data')
|
10 |
-
os.makedirs(DATA_DIR, exist_ok=True)
|
11 |
-
|
12 |
-
# 数据文件路径
|
13 |
-
API_KEYS_FILE = os.path.join(DATA_DIR, 'api_keys.json') # 保留以供兼容性
|
14 |
-
AUTH_FILE = os.path.join(DATA_DIR, 'auth_tokens.json')
|
15 |
-
|
16 |
-
# SQLite数据库配置
|
17 |
-
DATABASE_PATH = os.path.join(DATA_DIR, 'api_keys.db')
|
18 |
-
|
19 |
-
# 应用密钥配置
|
20 |
-
SECRET_KEY = os.environ.get('SECRET_KEY', secrets.token_hex(16))
|
21 |
-
ADMIN_PASSWORD = os.environ.get('PASSWORD', '123456')
|
22 |
-
|
23 |
-
# 认证配置
|
24 |
-
TOKEN_EXPIRY_DAYS = 30
|
25 |
-
|
26 |
-
# 支持的平台
|
27 |
-
PLATFORMS = [
|
28 |
-
{"id": "anthropic", "name": "Anthropic"},
|
29 |
-
{"id": "openai", "name": "OpenAI"},
|
30 |
-
{"id": "google", "name": "Google"},
|
31 |
-
{"id": "deepseek", "name": "Deepseek"},
|
32 |
-
{"id": "siliconflow", "name": "SiliconFlow"},
|
33 |
-
{"id": "xai", "name": "xAI"},
|
34 |
-
{"id": "groq", "name": "Groq"},
|
35 |
-
{"id": "openrouter", "name": "OpenRouter"}
|
36 |
-
]
|
37 |
-
|
38 |
-
# 平台标签样式
|
39 |
-
PLATFORM_STYLES = {
|
40 |
-
"anthropic": {
|
41 |
-
"background-color": "rgba(217, 119, 87, 0.1)",
|
42 |
-
"border-color": "rgba(217, 119, 87, 0.3)",
|
43 |
-
"color": "#c25032"
|
44 |
-
},
|
45 |
-
"openai": {
|
46 |
-
"background-color": "rgba(16, 163, 127, 0.1)",
|
47 |
-
"border-color": "rgba(16, 163, 127, 0.3)",
|
48 |
-
"color": "#0e8c6b"
|
49 |
-
},
|
50 |
-
"google": {
|
51 |
-
"background-color": "rgba(28, 125, 255, 0.1)",
|
52 |
-
"border-color": "rgba(28, 125, 255, 0.3)",
|
53 |
-
"color": "#0051c3"
|
54 |
-
},
|
55 |
-
"deepseek": {
|
56 |
-
"background-color": "rgba(77, 107, 254, 0.1)",
|
57 |
-
"border-color": "rgba(77, 107, 254, 0.3)",
|
58 |
-
"color": "#3246d3"
|
59 |
-
},
|
60 |
-
"siliconflow": {
|
61 |
-
"background-color": "rgba(124, 58, 237, 0.1)",
|
62 |
-
"border-color": "rgba(124, 58, 237, 0.3)",
|
63 |
-
"color": "#6429c8"
|
64 |
-
},
|
65 |
-
"xai": {
|
66 |
-
"background-color": "rgba(90, 90, 90, 0.1)",
|
67 |
-
"border-color": "rgba(90, 90, 90, 0.3)",
|
68 |
-
"color": "#5A5A5A"
|
69 |
-
},
|
70 |
-
"groq": {
|
71 |
-
"background-color": "rgba(255, 95, 31, 0.1)",
|
72 |
-
"border-color": "rgba(255, 95, 31, 0.3)",
|
73 |
-
"color": "#FF5F1F"
|
74 |
-
},
|
75 |
-
"openrouter": {
|
76 |
-
"background-color": "rgba(61, 88, 171, 0.1)",
|
77 |
-
"border-color": "rgba(61, 88, 171, 0.3)",
|
78 |
-
"color": "#3D58AB"
|
79 |
-
}
|
80 |
-
}
|
81 |
-
|
82 |
-
# API调用节流控制配置
|
83 |
-
PLATFORM_LIMITS = {
|
84 |
-
'openai': 100,
|
85 |
-
'anthropic': 100,
|
86 |
-
'google': 500,
|
87 |
-
'deepseek':
|
88 |
-
'siliconflow': 50,
|
89 |
-
'xai': 50,
|
90 |
-
'groq': 50,
|
91 |
-
'openrouter': 50,
|
92 |
-
'default': 50
|
93 |
-
}
|
94 |
-
|
95 |
-
# 请求节流时间窗口(秒)
|
96 |
-
TIME_WINDOW = 10
|
|
|
1 |
+
"""
|
2 |
+
配置文件 - 存储应用的所有配置参数
|
3 |
+
"""
|
4 |
+
import os
|
5 |
+
import secrets
|
6 |
+
|
7 |
+
# 基本目录配置
|
8 |
+
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
9 |
+
DATA_DIR = os.path.join(BASE_DIR, 'data')
|
10 |
+
os.makedirs(DATA_DIR, exist_ok=True)
|
11 |
+
|
12 |
+
# 数据文件路径
|
13 |
+
API_KEYS_FILE = os.path.join(DATA_DIR, 'api_keys.json') # 保留以供兼容性
|
14 |
+
AUTH_FILE = os.path.join(DATA_DIR, 'auth_tokens.json')
|
15 |
+
|
16 |
+
# SQLite数据库配置
|
17 |
+
DATABASE_PATH = os.path.join(DATA_DIR, 'api_keys.db')
|
18 |
+
|
19 |
+
# 应用密钥配置
|
20 |
+
SECRET_KEY = os.environ.get('SECRET_KEY', secrets.token_hex(16))
|
21 |
+
ADMIN_PASSWORD = os.environ.get('PASSWORD', '123456')
|
22 |
+
|
23 |
+
# 认证配置
|
24 |
+
TOKEN_EXPIRY_DAYS = 30
|
25 |
+
|
26 |
+
# 支持的平台
|
27 |
+
PLATFORMS = [
|
28 |
+
{"id": "anthropic", "name": "Anthropic"},
|
29 |
+
{"id": "openai", "name": "OpenAI"},
|
30 |
+
{"id": "google", "name": "Google"},
|
31 |
+
{"id": "deepseek", "name": "Deepseek"},
|
32 |
+
{"id": "siliconflow", "name": "SiliconFlow"},
|
33 |
+
{"id": "xai", "name": "xAI"},
|
34 |
+
{"id": "groq", "name": "Groq"},
|
35 |
+
{"id": "openrouter", "name": "OpenRouter"}
|
36 |
+
]
|
37 |
+
|
38 |
+
# 平台标签样式
|
39 |
+
PLATFORM_STYLES = {
|
40 |
+
"anthropic": {
|
41 |
+
"background-color": "rgba(217, 119, 87, 0.1)",
|
42 |
+
"border-color": "rgba(217, 119, 87, 0.3)",
|
43 |
+
"color": "#c25032"
|
44 |
+
},
|
45 |
+
"openai": {
|
46 |
+
"background-color": "rgba(16, 163, 127, 0.1)",
|
47 |
+
"border-color": "rgba(16, 163, 127, 0.3)",
|
48 |
+
"color": "#0e8c6b"
|
49 |
+
},
|
50 |
+
"google": {
|
51 |
+
"background-color": "rgba(28, 125, 255, 0.1)",
|
52 |
+
"border-color": "rgba(28, 125, 255, 0.3)",
|
53 |
+
"color": "#0051c3"
|
54 |
+
},
|
55 |
+
"deepseek": {
|
56 |
+
"background-color": "rgba(77, 107, 254, 0.1)",
|
57 |
+
"border-color": "rgba(77, 107, 254, 0.3)",
|
58 |
+
"color": "#3246d3"
|
59 |
+
},
|
60 |
+
"siliconflow": {
|
61 |
+
"background-color": "rgba(124, 58, 237, 0.1)",
|
62 |
+
"border-color": "rgba(124, 58, 237, 0.3)",
|
63 |
+
"color": "#6429c8"
|
64 |
+
},
|
65 |
+
"xai": {
|
66 |
+
"background-color": "rgba(90, 90, 90, 0.1)",
|
67 |
+
"border-color": "rgba(90, 90, 90, 0.3)",
|
68 |
+
"color": "#5A5A5A"
|
69 |
+
},
|
70 |
+
"groq": {
|
71 |
+
"background-color": "rgba(255, 95, 31, 0.1)",
|
72 |
+
"border-color": "rgba(255, 95, 31, 0.3)",
|
73 |
+
"color": "#FF5F1F"
|
74 |
+
},
|
75 |
+
"openrouter": {
|
76 |
+
"background-color": "rgba(61, 88, 171, 0.1)",
|
77 |
+
"border-color": "rgba(61, 88, 171, 0.3)",
|
78 |
+
"color": "#3D58AB"
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
# API调用节流控制配置
|
83 |
+
PLATFORM_LIMITS = {
|
84 |
+
'openai': 100,
|
85 |
+
'anthropic': 100,
|
86 |
+
'google': 500,
|
87 |
+
'deepseek': 200,
|
88 |
+
'siliconflow': 50,
|
89 |
+
'xai': 50,
|
90 |
+
'groq': 50,
|
91 |
+
'openrouter': 50,
|
92 |
+
'default': 50
|
93 |
+
}
|
94 |
+
|
95 |
+
# 请求节流时间窗口(秒)
|
96 |
+
TIME_WINDOW = 10
|