Niansuh commited on
Commit
1da90a6
·
verified ·
1 Parent(s): 7e00b4e

Update api/config.py

Browse files
Files changed (1) hide show
  1. api/config.py +123 -100
api/config.py CHANGED
@@ -1,73 +1,140 @@
 
 
1
  import os
2
  from dotenv import load_dotenv
3
 
 
4
  load_dotenv()
5
 
6
- # Base URL
7
  BASE_URL = "https://www.blackbox.ai"
8
 
9
- # APP_SECRET
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  APP_SECRET = os.getenv("APP_SECRET")
11
 
12
- # Default Model
13
- DEFAULT_MODEL = "blackboxai"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
- # Allowed Models (List of Strings)
 
 
 
 
 
 
 
16
  ALLOWED_MODELS = [
17
- "blackboxai",
18
- "blackboxai-pro",
19
- "gpt-4o",
20
- "gemini-pro",
21
- "gemini-1.5-flash",
22
- "claude-sonnet-3.5",
23
- "Image Generation",
24
- "repomap",
25
- "Python Agent",
26
- "Java Agent",
27
- "JavaScript Agent",
28
- "HTML Agent",
29
- "Google Cloud Agent",
30
- "Android Developer",
31
- "Swift Developer",
32
- "Next.js Agent",
33
- "MongoDB Agent",
34
- "PyTorch Agent",
35
- "React Agent",
36
- "Xcode Agent",
37
- "AngularJS Agent",
38
- "Heroku Agent",
39
- "Godot Agent",
40
- "Go Agent",
41
- "Gitlab Agent",
42
- "Git Agent",
43
- "Flask Agent",
44
- "Firebase Agent",
45
- "FastAPI Agent",
46
- "Erlang Agent",
47
- "Electron Agent",
48
- "Docker Agent",
49
- "DigitalOcean Agent",
50
- "Bitbucket Agent",
51
- "Azure Agent",
52
- "Flutter Agent",
53
- "Youtube Agent",
54
- "builder Agent",
55
  ]
56
 
57
- # Model Mapping
 
 
 
 
 
 
 
 
58
  MODEL_MAPPING = {
59
  "blackboxai": "blackboxai",
60
- "blackboxai-pro": "blackboxai-pro",
61
  "gpt-4o": "gpt-4o",
62
  "gemini-pro": "gemini-pro",
63
- "gemini-1.5-flash": "gemini-1.5-flash",
64
  "claude-sonnet-3.5": "claude-sonnet-3.5",
65
- "gemini-flash": "gemini-1.5-flash",
66
- "claude-3.5-sonnet": "claude-sonnet-3.5",
67
- "flux": "Image Generation",
68
- # Agent Models
69
- "Image Generation": "Image Generation",
70
  "repomap": "repomap",
 
 
 
 
71
  "Python Agent": "Python Agent",
72
  "Java Agent": "Java Agent",
73
  "JavaScript Agent": "JavaScript Agent",
@@ -100,53 +167,9 @@ MODEL_MAPPING = {
100
  "builder Agent": "builder Agent",
101
  }
102
 
103
- # Agent Modes
104
- AGENT_MODE = {
105
- "Image Generation": {"mode": True, "id": "ImageGenerationLV45LJp", "name": "Image Generation"},
106
- }
107
-
108
- TRENDING_AGENT_MODE = {
109
- "gemini-1.5-flash": {"mode": True, "id": "Gemini"},
110
- "llama-3.1-8b": {"mode": True, "id": "llama-3.1-8b"},
111
- "llama-3.1-70b": {"mode": True, "id": "llama-3.1-70b"},
112
- "llama-3.1-405b": {"mode": True, "id": "llama-3.1-405"},
113
- "Python Agent": {"mode": True, "id": "Python Agent"},
114
- "Java Agent": {"mode": True, "id": "Java Agent"},
115
- "JavaScript Agent": {"mode": True, "id": "JavaScript Agent"},
116
- "HTML Agent": {"mode": True, "id": "HTML Agent"},
117
- "Google Cloud Agent": {"mode": True, "id": "Google Cloud Agent"},
118
- "Android Developer": {"mode": True, "id": "Android Developer"},
119
- "Swift Developer": {"mode": True, "id": "Swift Developer"},
120
- "Next.js Agent": {"mode": True, "id": "Next.js Agent"},
121
- "MongoDB Agent": {"mode": True, "id": "MongoDB Agent"},
122
- "PyTorch Agent": {"mode": True, "id": "PyTorch Agent"},
123
- "React Agent": {"mode": True, "id": "React Agent"},
124
- "Xcode Agent": {"mode": True, "id": "Xcode Agent"},
125
- "AngularJS Agent": {"mode": True, "id": "AngularJS Agent"},
126
- "blackboxai-pro": {"mode": True, "id": "BLACKBOXAI-PRO"},
127
- "repomap": {"mode": True, "id": "repomap"},
128
- "Heroku Agent": {"mode": True, "id": "Heroku Agent"},
129
- "Godot Agent": {"mode": True, "id": "Godot Agent"},
130
- "Go Agent": {"mode": True, "id": "Go Agent"},
131
- "Gitlab Agent": {"mode": True, "id": "Gitlab Agent"},
132
- "Git Agent": {"mode": True, "id": "Git Agent"},
133
- "Flask Agent": {"mode": True, "id": "Flask Agent"},
134
- "Firebase Agent": {"mode": True, "id": "Firebase Agent"},
135
- "FastAPI Agent": {"mode": True, "id": "FastAPI Agent"},
136
- "Erlang Agent": {"mode": True, "id": "Erlang Agent"},
137
- "Electron Agent": {"mode": True, "id": "Electron Agent"},
138
- "Docker Agent": {"mode": True, "id": "Docker Agent"},
139
- "DigitalOcean Agent": {"mode": True, "id": "DigitalOcean Agent"},
140
- "Bitbucket Agent": {"mode": True, "id": "Bitbucket Agent"},
141
- "Azure Agent": {"mode": True, "id": "Azure Agent"},
142
- "Flutter Agent": {"mode": True, "id": "Flutter Agent"},
143
- "Youtube Agent": {"mode": True, "id": "Youtube Agent"},
144
- "builder Agent": {"mode": True, "id": "builder Agent"},
145
- }
146
 
147
- # Model Prefixes
148
- MODEL_PREFIXES = {
149
- mode: f"@{value['id']}"
150
- for mode, value in TRENDING_AGENT_MODE.items()
151
- if mode not in ["gemini-1.5-flash", "llama-3.1-8b", "llama-3.1-70b", "llama-3.1-405b", "repomap"]
152
- }
 
1
+ # api/config.py
2
+
3
  import os
4
  from dotenv import load_dotenv
5
 
6
+ # Load environment variables from .env file
7
  load_dotenv()
8
 
9
+ # Base URL for external API
10
  BASE_URL = "https://www.blackbox.ai"
11
 
12
+ # Common headers for HTTP requests
13
+ headers = {
14
+ 'accept': '*/*',
15
+ 'accept-language': 'zh-CN,zh;q=0.9',
16
+ 'content-type': 'application/json',
17
+ 'origin': 'https://www.blackbox.ai',
18
+ 'priority': 'u=1, i',
19
+ 'sec-ch-ua': '"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',
20
+ 'sec-ch-ua-mobile': '?0',
21
+ 'sec-ch-ua-platform': '"Windows"',
22
+ 'sec-fetch-dest': 'empty',
23
+ 'sec-fetch-mode': 'cors',
24
+ 'sec-fetch-site': 'same-origin',
25
+ 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36',
26
+ }
27
+
28
+ # Application secret key for authentication
29
  APP_SECRET = os.getenv("APP_SECRET")
30
 
31
+ # Default model used by the application
32
+ default_model = 'blackboxai'
33
+
34
+ # Image-related models
35
+ image_models = ['Image Generation', 'repomap']
36
+
37
+ # User-selected models
38
+ userSelectedModel = ['gpt-4o', 'gemini-pro', 'claude-sonnet-3.5', 'blackboxai-pro']
39
+
40
+ # Agent modes with their configurations
41
+ agentMode = {
42
+ 'Image Generation': {'mode': True, 'id': "ImageGenerationLV45LJp", 'name': "Image Generation"},
43
+ }
44
+
45
+ # Trending agent modes with their configurations
46
+ trendingAgentMode = {
47
+ "gemini-1.5-flash": {'mode': True, 'id': 'Gemini'},
48
+ "llama-3.1-8b": {'mode': True, 'id': "llama-3.1-8b"},
49
+ 'llama-3.1-70b': {'mode': True, 'id': "llama-3.1-70b"},
50
+ 'llama-3.1-405b': {'mode': True, 'id': "llama-3.1-405"},
51
+ 'Python Agent': {'mode': True, 'id': "Python Agent"},
52
+ 'Java Agent': {'mode': True, 'id': "Java Agent"},
53
+ 'JavaScript Agent': {'mode': True, 'id': "JavaScript Agent"},
54
+ 'HTML Agent': {'mode': True, 'id': "HTML Agent"},
55
+ 'Google Cloud Agent': {'mode': True, 'id': "Google Cloud Agent"},
56
+ 'Android Developer': {'mode': True, 'id': "Android Developer"},
57
+ 'Swift Developer': {'mode': True, 'id': "Swift Developer"},
58
+ 'Next.js Agent': {'mode': True, 'id': "Next.js Agent"},
59
+ 'MongoDB Agent': {'mode': True, 'id': "MongoDB Agent"},
60
+ 'PyTorch Agent': {'mode': True, 'id': "PyTorch Agent"},
61
+ 'React Agent': {'mode': True, 'id': "React Agent"},
62
+ 'Xcode Agent': {'mode': True, 'id': "Xcode Agent"},
63
+ 'AngularJS Agent': {'mode': True, 'id': "AngularJS Agent"},
64
+ 'repomap': {'mode': True, 'id': "repomap"},
65
+ 'Heroku Agent': {'mode': True, 'id': "Heroku Agent"},
66
+ 'Godot Agent': {'mode': True, 'id': "Godot Agent"},
67
+ 'Go Agent': {'mode': True, 'id': "Go Agent"},
68
+ 'Gitlab Agent': {'mode': True, 'id': "Gitlab Agent"},
69
+ 'Git Agent': {'mode': True, 'id': "Git Agent"},
70
+ 'Flask Agent': {'mode': True, 'id': "Flask Agent"},
71
+ 'Firebase Agent': {'mode': True, 'id': "Firebase Agent"},
72
+ 'FastAPI Agent': {'mode': True, 'id': "FastAPI Agent"},
73
+ 'Erlang Agent': {'mode': True, 'id': "Erlang Agent"},
74
+ 'Electron Agent': {'mode': True, 'id': "Electron Agent"},
75
+ 'Docker Agent': {'mode': True, 'id': "Docker Agent"},
76
+ 'DigitalOcean Agent': {'mode': True, 'id': "DigitalOcean Agent"},
77
+ 'Bitbucket Agent': {'mode': True, 'id': "Bitbucket Agent"},
78
+ 'Azure Agent': {'mode': True, 'id': "Azure Agent"},
79
+ 'Flutter Agent': {'mode': True, 'id': "Flutter Agent"},
80
+ 'Youtube Agent': {'mode': True, 'id': "Youtube Agent"},
81
+ 'builder Agent': {'mode': True, 'id': "builder Agent"},
82
+ }
83
+
84
+ # Prefixes for trending agent modes (excluding specific models)
85
+ model_prefixes = {
86
+ mode: f"@{value['id']}"
87
+ for mode, value in trendingAgentMode.items()
88
+ if mode not in ["gemini-1.5-flash", "llama-3.1-8b", "llama-3.1-70b", "llama-3.1-405b", "repomap"]
89
+ }
90
+
91
+ # Comprehensive list of all models
92
+ models = [
93
+ default_model,
94
+ *userSelectedModel,
95
+ *list(agentMode.keys()),
96
+ *list(trendingAgentMode.keys())
97
+ ]
98
 
99
+ # Aliases for certain models to handle alternative naming
100
+ model_aliases = {
101
+ "gemini-flash": "gemini-1.5-flash",
102
+ "claude-3.5-sonnet": "claude-sonnet-3.5",
103
+ "flux": "Image Generation",
104
+ }
105
+
106
+ # Allowed models for API requests
107
  ALLOWED_MODELS = [
108
+ {"id": default_model, "name": "BlackboxAI"},
109
+ {"id": "gpt-4o", "name": "GPT-4o"},
110
+ {"id": "gemini-pro", "name": "Gemini Pro"},
111
+ {"id": "claude-sonnet-3.5", "name": "Claude Sonnet 3.5"},
112
+ {"id": "blackboxai-pro", "name": "BlackboxAI-Pro"},
113
+ {"id": "Image Generation", "name": "Image Generation"},
114
+ {"id": "repomap", "name": "Repomap"},
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  ]
116
 
117
+ # Add agentMode models to ALLOWED_MODELS
118
+ for model_key, model_info in agentMode.items():
119
+ ALLOWED_MODELS.append({"id": model_info['id'], "name": model_info['name']})
120
+
121
+ # Add trendingAgentMode models to ALLOWED_MODELS
122
+ for model_key, model_info in trendingAgentMode.items():
123
+ ALLOWED_MODELS.append({"id": model_info['id'], "name": model_key})
124
+
125
+ # Mapping from user-provided model identifiers to internal model identifiers
126
  MODEL_MAPPING = {
127
  "blackboxai": "blackboxai",
 
128
  "gpt-4o": "gpt-4o",
129
  "gemini-pro": "gemini-pro",
 
130
  "claude-sonnet-3.5": "claude-sonnet-3.5",
131
+ "blackboxai-pro": "BLACKBOXAI-PRO",
132
+ "Image Generation": "ImageGenerationLV45LJp",
 
 
 
133
  "repomap": "repomap",
134
+ "gemini-1.5-flash": "Gemini",
135
+ "llama-3.1-8b": "llama-3.1-8b",
136
+ "llama-3.1-70b": "llama-3.1-70b",
137
+ "llama-3.1-405b": "llama-3.1-405",
138
  "Python Agent": "Python Agent",
139
  "Java Agent": "Java Agent",
140
  "JavaScript Agent": "JavaScript Agent",
 
167
  "builder Agent": "builder Agent",
168
  }
169
 
170
+ # Reverse mapping for model aliases
171
+ REVERSE_MODEL_MAPPING = {alias: original for alias, original in model_aliases.items()}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
 
173
+ # Function to resolve model aliases
174
+ def resolve_model(model_name: str) -> str:
175
+ return REVERSE_MODEL_MAPPING.get(model_name, model_name)