Update api/config.py
Browse files- api/config.py +188 -95
api/config.py
CHANGED
@@ -1,43 +1,37 @@
|
|
|
|
|
|
1 |
import os
|
2 |
from dotenv import load_dotenv
|
3 |
-
import random
|
4 |
-
import string
|
5 |
|
6 |
load_dotenv()
|
7 |
|
8 |
-
# Base URL and
|
9 |
BASE_URL = "https://www.blackbox.ai"
|
10 |
-
|
11 |
-
|
12 |
-
# Common Headers
|
13 |
-
COMMON_HEADERS = {
|
14 |
'accept': '*/*',
|
15 |
'accept-language': 'en-US,en;q=0.9',
|
16 |
'cache-control': 'no-cache',
|
17 |
-
'content-type': 'application/json',
|
18 |
'origin': BASE_URL,
|
19 |
'pragma': 'no-cache',
|
20 |
'priority': 'u=1, i',
|
21 |
-
'
|
22 |
-
'sec-ch-ua': '"Not?A_Brand";v="99", "Chromium";v="130"',
|
23 |
'sec-ch-ua-mobile': '?0',
|
24 |
-
'sec-ch-ua-platform': '"
|
25 |
'sec-fetch-dest': 'empty',
|
26 |
'sec-fetch-mode': 'cors',
|
27 |
'sec-fetch-site': 'same-origin',
|
28 |
-
'user-agent': (
|
29 |
-
|
30 |
-
|
31 |
-
),
|
32 |
}
|
33 |
|
34 |
# Header Configurations for Specific API Calls
|
35 |
-
def get_headers_api_chat():
|
36 |
-
return
|
37 |
|
38 |
def get_headers_chat(chat_url, next_action, next_router_state_tree):
|
39 |
return {
|
40 |
-
**
|
41 |
'Accept': 'text/x-component',
|
42 |
'Content-Type': 'text/plain;charset=UTF-8',
|
43 |
'Referer': chat_url,
|
@@ -48,7 +42,7 @@ def get_headers_chat(chat_url, next_action, next_router_state_tree):
|
|
48 |
|
49 |
APP_SECRET = os.getenv("APP_SECRET")
|
50 |
|
51 |
-
#
|
52 |
ALLOWED_MODELS = [
|
53 |
{"id": "blackboxai", "name": "blackboxai"},
|
54 |
{"id": "blackboxai-pro", "name": "blackboxai-pro"},
|
@@ -60,102 +54,201 @@ ALLOWED_MODELS = [
|
|
60 |
{"id": "gemini-pro", "name": "gemini-pro"},
|
61 |
{"id": "gemini-1.5-flash", "name": "gemini-1.5-flash"},
|
62 |
{"id": "claude-sonnet-3.5", "name": "claude-sonnet-3.5"},
|
63 |
-
{"id": "
|
64 |
-
{"id": "
|
65 |
-
{"id": "
|
66 |
-
{"id": "
|
67 |
-
{"id": "
|
68 |
-
{"id": "
|
69 |
-
{"id": "
|
70 |
-
{"id": "Next.
|
71 |
-
{"id": "
|
72 |
-
{"id": "
|
73 |
-
{"id": "
|
74 |
-
{"id": "
|
75 |
-
{"id": "
|
76 |
-
{"id": "
|
77 |
-
{"id": "
|
78 |
-
{"id": "
|
79 |
-
{"id": "
|
80 |
-
{"id": "
|
81 |
-
{"id": "
|
82 |
-
{"id": "
|
83 |
-
{"id": "
|
84 |
-
{"id": "
|
85 |
-
{"id": "
|
86 |
-
{"id": "
|
87 |
-
{"id": "
|
88 |
-
|
89 |
-
|
90 |
-
{"id": "
|
91 |
-
{"id": "
|
92 |
-
{"id": "
|
93 |
-
{"id": "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
]
|
95 |
|
96 |
-
# Model Aliases
|
97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
"gemini-flash": "gemini-1.5-flash",
|
99 |
"claude-3.5-sonnet": "claude-sonnet-3.5",
|
100 |
-
"flux": "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
}
|
102 |
|
103 |
# Agent Modes
|
104 |
AGENT_MODE = {
|
105 |
-
'
|
|
|
|
|
106 |
}
|
107 |
|
108 |
# Trending Agent Modes
|
109 |
TRENDING_AGENT_MODE = {
|
|
|
110 |
"gemini-1.5-flash": {'mode': True, 'id': 'Gemini'},
|
111 |
"llama-3.1-8b": {'mode': True, 'id': "llama-3.1-8b"},
|
112 |
'llama-3.1-70b': {'mode': True, 'id': "llama-3.1-70b"},
|
113 |
'llama-3.1-405b': {'mode': True, 'id': "llama-3.1-405"},
|
114 |
'blackboxai-pro': {'mode': True, 'id': "BLACKBOXAI-PRO"},
|
115 |
-
'
|
116 |
-
'
|
117 |
-
'
|
118 |
-
'
|
119 |
-
'
|
120 |
-
'
|
121 |
-
'
|
122 |
-
'Next.
|
123 |
-
'
|
124 |
-
'
|
125 |
-
'
|
126 |
-
'
|
127 |
-
'
|
128 |
-
'
|
129 |
-
'
|
130 |
-
'
|
131 |
-
'
|
132 |
-
'
|
133 |
-
'
|
134 |
-
|
135 |
-
|
136 |
-
'
|
137 |
-
'
|
138 |
-
'
|
139 |
-
'
|
140 |
-
'
|
141 |
-
'
|
142 |
-
'
|
143 |
-
'
|
144 |
-
'
|
145 |
-
'
|
|
|
|
|
146 |
}
|
147 |
|
148 |
# Model Prefixes
|
149 |
MODEL_PREFIXES = {
|
150 |
-
|
151 |
-
|
152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
}
|
154 |
|
155 |
-
#
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
|
|
|
1 |
+
# api/config.py
|
2 |
+
|
3 |
import os
|
4 |
from dotenv import load_dotenv
|
|
|
|
|
5 |
|
6 |
load_dotenv()
|
7 |
|
8 |
+
# Base URL and Common Headers
|
9 |
BASE_URL = "https://www.blackbox.ai"
|
10 |
+
common_headers = {
|
|
|
|
|
|
|
11 |
'accept': '*/*',
|
12 |
'accept-language': 'en-US,en;q=0.9',
|
13 |
'cache-control': 'no-cache',
|
|
|
14 |
'origin': BASE_URL,
|
15 |
'pragma': 'no-cache',
|
16 |
'priority': 'u=1, i',
|
17 |
+
'sec-ch-ua': '"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',
|
|
|
18 |
'sec-ch-ua-mobile': '?0',
|
19 |
+
'sec-ch-ua-platform': '"Windows"',
|
20 |
'sec-fetch-dest': 'empty',
|
21 |
'sec-fetch-mode': 'cors',
|
22 |
'sec-fetch-site': 'same-origin',
|
23 |
+
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
|
24 |
+
'AppleWebKit/537.36 (KHTML, like Gecko) '
|
25 |
+
'Chrome/130.0.0.0 Safari/537.36',
|
|
|
26 |
}
|
27 |
|
28 |
# Header Configurations for Specific API Calls
|
29 |
+
def get_headers_api_chat(referer_url):
|
30 |
+
return {**common_headers, 'Content-Type': 'application/json', 'Referer': referer_url}
|
31 |
|
32 |
def get_headers_chat(chat_url, next_action, next_router_state_tree):
|
33 |
return {
|
34 |
+
**common_headers,
|
35 |
'Accept': 'text/x-component',
|
36 |
'Content-Type': 'text/plain;charset=UTF-8',
|
37 |
'Referer': chat_url,
|
|
|
42 |
|
43 |
APP_SECRET = os.getenv("APP_SECRET")
|
44 |
|
45 |
+
# Allowed Models
|
46 |
ALLOWED_MODELS = [
|
47 |
{"id": "blackboxai", "name": "blackboxai"},
|
48 |
{"id": "blackboxai-pro", "name": "blackboxai-pro"},
|
|
|
54 |
{"id": "gemini-pro", "name": "gemini-pro"},
|
55 |
{"id": "gemini-1.5-flash", "name": "gemini-1.5-flash"},
|
56 |
{"id": "claude-sonnet-3.5", "name": "claude-sonnet-3.5"},
|
57 |
+
{"id": "PythonAgent", "name": "PythonAgent"},
|
58 |
+
{"id": "JavaAgent", "name": "JavaAgent"},
|
59 |
+
{"id": "JavaScriptAgent", "name": "JavaScriptAgent"},
|
60 |
+
{"id": "HTMLAgent", "name": "HTMLAgent"},
|
61 |
+
{"id": "GoogleCloudAgent", "name": "GoogleCloudAgent"},
|
62 |
+
{"id": "AndroidDeveloper", "name": "AndroidDeveloper"},
|
63 |
+
{"id": "SwiftDeveloper", "name": "SwiftDeveloper"},
|
64 |
+
{"id": "Next.jsAgent", "name": "Next.jsAgent"},
|
65 |
+
{"id": "MongoDBAgent", "name": "MongoDBAgent"},
|
66 |
+
{"id": "PyTorchAgent", "name": "PyTorchAgent"},
|
67 |
+
{"id": "ReactAgent", "name": "ReactAgent"},
|
68 |
+
{"id": "XcodeAgent", "name": "XcodeAgent"},
|
69 |
+
{"id": "AngularJSAgent", "name": "AngularJSAgent"},
|
70 |
+
{"id": "HerokuAgent", "name": "HerokuAgent"},
|
71 |
+
{"id": "GodotAgent", "name": "GodotAgent"},
|
72 |
+
{"id": "GoAgent", "name": "GoAgent"},
|
73 |
+
{"id": "GitlabAgent", "name": "GitlabAgent"},
|
74 |
+
{"id": "GitAgent", "name": "GitAgent"},
|
75 |
+
{"id": "RepoMap", "name": "RepoMap"},
|
76 |
+
{"id": "gemini-1.5-pro-latest", "name": "gemini-pro"},
|
77 |
+
{"id": "gemini-1.5-pro", "name": "gemini-1.5-pro"},
|
78 |
+
{"id": "claude-3-5-sonnet-20240620", "name": "claude-sonnet-3.5"},
|
79 |
+
{"id": "claude-3-5-sonnet", "name": "claude-sonnet-3.5"},
|
80 |
+
{"id": "Niansuh", "name": "Niansuh"},
|
81 |
+
{"id": "o1-preview", "name": "o1-preview"},
|
82 |
+
|
83 |
+
# Added New Agents
|
84 |
+
{"id": "FlaskAgent", "name": "FlaskAgent"},
|
85 |
+
{"id": "FirebaseAgent", "name": "FirebaseAgent"},
|
86 |
+
{"id": "FastAPIAgent", "name": "FastAPIAgent"},
|
87 |
+
{"id": "ErlangAgent", "name": "ErlangAgent"},
|
88 |
+
{"id": "ElectronAgent", "name": "ElectronAgent"},
|
89 |
+
{"id": "DockerAgent", "name": "DockerAgent"},
|
90 |
+
{"id": "DigitalOceanAgent", "name": "DigitalOceanAgent"},
|
91 |
+
{"id": "BitbucketAgent", "name": "BitbucketAgent"},
|
92 |
+
{"id": "AzureAgent", "name": "AzureAgent"},
|
93 |
+
{"id": "FlutterAgent", "name": "FlutterAgent"},
|
94 |
+
{"id": "YoutubeAgent", "name": "YoutubeAgent"},
|
95 |
+
{"id": "builderAgent", "name": "builderAgent"},
|
96 |
]
|
97 |
|
98 |
+
# Model Mapping: Aliases to Primary Models
|
99 |
+
MODEL_MAPPING = {
|
100 |
+
"blackboxai": "blackboxai",
|
101 |
+
"blackboxai-pro": "blackboxai-pro",
|
102 |
+
"flux": "flux",
|
103 |
+
"ImageGeneration": "flux",
|
104 |
+
"llama-3.1-8b": "llama-3.1-8b",
|
105 |
+
"llama-3.1-70b": "llama-3.1-70b",
|
106 |
+
"llama-3.1-405b": "llama-3.1-405",
|
107 |
+
"gpt-4o": "gpt-4o",
|
108 |
+
"gemini-pro": "gemini-pro",
|
109 |
+
"gemini-1.5-flash": "gemini-1.5-flash",
|
110 |
+
"claude-sonnet-3.5": "claude-sonnet-3.5",
|
111 |
+
"PythonAgent": "PythonAgent",
|
112 |
+
"JavaAgent": "JavaAgent",
|
113 |
+
"JavaScriptAgent": "JavaScriptAgent",
|
114 |
+
"HTMLAgent": "HTMLAgent",
|
115 |
+
"GoogleCloudAgent": "GoogleCloudAgent",
|
116 |
+
"AndroidDeveloper": "AndroidDeveloper",
|
117 |
+
"SwiftDeveloper": "SwiftDeveloper",
|
118 |
+
"Next.jsAgent": "Next.jsAgent",
|
119 |
+
"MongoDBAgent": "MongoDBAgent",
|
120 |
+
"PyTorchAgent": "PyTorchAgent",
|
121 |
+
"ReactAgent": "ReactAgent",
|
122 |
+
"XcodeAgent": "XcodeAgent",
|
123 |
+
"AngularJSAgent": "AngularJSAgent",
|
124 |
+
"HerokuAgent": "HerokuAgent",
|
125 |
+
"GodotAgent": "GodotAgent",
|
126 |
+
"GoAgent": "GoAgent",
|
127 |
+
"GitlabAgent": "GitlabAgent",
|
128 |
+
"GitAgent": "GitAgent",
|
129 |
+
"RepoMap": "RepoMap",
|
130 |
+
# Additional mappings
|
131 |
"gemini-flash": "gemini-1.5-flash",
|
132 |
"claude-3.5-sonnet": "claude-sonnet-3.5",
|
133 |
+
"flux": "flux",
|
134 |
+
"gemini-1.5-pro-latest": "gemini-pro",
|
135 |
+
"gemini-1.5-pro": "gemini-1.5-pro",
|
136 |
+
"claude-3-5-sonnet-20240620": "claude-sonnet-3.5",
|
137 |
+
"claude-3-5-sonnet": "claude-sonnet-3.5",
|
138 |
+
"Niansuh": "Niansuh",
|
139 |
+
"o1-preview": "o1-preview",
|
140 |
+
|
141 |
+
# Added New Agents
|
142 |
+
"FlaskAgent": "FlaskAgent",
|
143 |
+
"FirebaseAgent": "FirebaseAgent",
|
144 |
+
"FastAPIAgent": "FastAPIAgent",
|
145 |
+
"ErlangAgent": "ErlangAgent",
|
146 |
+
"ElectronAgent": "ElectronAgent",
|
147 |
+
"DockerAgent": "DockerAgent",
|
148 |
+
"DigitalOceanAgent": "DigitalOceanAgent",
|
149 |
+
"BitbucketAgent": "BitbucketAgent",
|
150 |
+
"AzureAgent": "AzureAgent",
|
151 |
+
"FlutterAgent": "FlutterAgent",
|
152 |
+
"YoutubeAgent": "YoutubeAgent",
|
153 |
+
"builderAgent": "builderAgent",
|
154 |
}
|
155 |
|
156 |
# Agent Modes
|
157 |
AGENT_MODE = {
|
158 |
+
'flux': {'mode': True, 'id': "ImageGenerationLV45LJp", 'name': "flux"},
|
159 |
+
'Niansuh': {'mode': True, 'id': "NiansuhAIk1HgESy", 'name': "Niansuh"},
|
160 |
+
'o1-preview': {'mode': True, 'id': "o1Dst8La8", 'name': "o1-preview"},
|
161 |
}
|
162 |
|
163 |
# Trending Agent Modes
|
164 |
TRENDING_AGENT_MODE = {
|
165 |
+
"blackboxai": {},
|
166 |
"gemini-1.5-flash": {'mode': True, 'id': 'Gemini'},
|
167 |
"llama-3.1-8b": {'mode': True, 'id': "llama-3.1-8b"},
|
168 |
'llama-3.1-70b': {'mode': True, 'id': "llama-3.1-70b"},
|
169 |
'llama-3.1-405b': {'mode': True, 'id': "llama-3.1-405"},
|
170 |
'blackboxai-pro': {'mode': True, 'id': "BLACKBOXAI-PRO"},
|
171 |
+
'PythonAgent': {'mode': True, 'id': "Python Agent"},
|
172 |
+
'JavaAgent': {'mode': True, 'id': "Java Agent"},
|
173 |
+
'JavaScriptAgent': {'mode': True, 'id': "JavaScript Agent"},
|
174 |
+
'HTMLAgent': {'mode': True, 'id': "HTML Agent"},
|
175 |
+
'GoogleCloudAgent': {'mode': True, 'id': "Google Cloud Agent"},
|
176 |
+
'AndroidDeveloper': {'mode': True, 'id': "Android Developer"},
|
177 |
+
'SwiftDeveloper': {'mode': True, 'id': "Swift Developer"},
|
178 |
+
'Next.jsAgent': {'mode': True, 'id': "Next.js Agent"},
|
179 |
+
'MongoDBAgent': {'mode': True, 'id': "MongoDB Agent"},
|
180 |
+
'PyTorchAgent': {'mode': True, 'id': "PyTorch Agent"},
|
181 |
+
'ReactAgent': {'mode': True, 'id': "React Agent"},
|
182 |
+
'XcodeAgent': {'mode': True, 'id': "Xcode Agent"},
|
183 |
+
'AngularJSAgent': {'mode': True, 'id': "AngularJS Agent"},
|
184 |
+
'HerokuAgent': {'mode': True, 'id': "HerokuAgent"},
|
185 |
+
'GodotAgent': {'mode': True, 'id': "GodotAgent"},
|
186 |
+
'GoAgent': {'mode': True, 'id': "GoAgent"},
|
187 |
+
'GitlabAgent': {'mode': True, 'id': "GitlabAgent"},
|
188 |
+
'GitAgent': {'mode': True, 'id': "GitAgent"},
|
189 |
+
'RepoMap': {'mode': True, 'id': "repomap"},
|
190 |
+
|
191 |
+
# Added New Agents
|
192 |
+
'FlaskAgent': {'mode': True, 'id': "FlaskAgent"},
|
193 |
+
'FirebaseAgent': {'mode': True, 'id': "FirebaseAgent"},
|
194 |
+
'FastAPIAgent': {'mode': True, 'id': "FastAPIAgent"},
|
195 |
+
'ErlangAgent': {'mode': True, 'id': "ErlangAgent"},
|
196 |
+
'ElectronAgent': {'mode': True, 'id': "ElectronAgent"},
|
197 |
+
'DockerAgent': {'mode': True, 'id': "DockerAgent"},
|
198 |
+
'DigitalOceanAgent': {'mode': True, 'id': "DigitalOceanAgent"},
|
199 |
+
'BitbucketAgent': {'mode': True, 'id': "BitbucketAgent"},
|
200 |
+
'AzureAgent': {'mode': True, 'id': "AzureAgent"},
|
201 |
+
'FlutterAgent': {'mode': True, 'id': "FlutterAgent"},
|
202 |
+
'YoutubeAgent': {'mode': True, 'id': "YoutubeAgent"},
|
203 |
+
'builderAgent': {'mode': True, 'id': "builderAgent"},
|
204 |
}
|
205 |
|
206 |
# Model Prefixes
|
207 |
MODEL_PREFIXES = {
|
208 |
+
'gpt-4o': '@GPT-4o',
|
209 |
+
'gemini-pro': '@Gemini-PRO',
|
210 |
+
'PythonAgent': '@Python Agent',
|
211 |
+
'JavaAgent': '@Java Agent',
|
212 |
+
'JavaScriptAgent': '@JavaScript Agent',
|
213 |
+
'HTMLAgent': '@HTML Agent',
|
214 |
+
'GoogleCloudAgent': '@Google Cloud Agent',
|
215 |
+
'AndroidDeveloper': '@Android Developer',
|
216 |
+
'SwiftDeveloper': '@Swift Developer',
|
217 |
+
'Next.jsAgent': '@Next.js Agent',
|
218 |
+
'MongoDBAgent': '@MongoDB Agent',
|
219 |
+
'PyTorchAgent': '@PyTorch Agent',
|
220 |
+
'ReactAgent': '@React Agent',
|
221 |
+
'XcodeAgent': '@Xcode Agent',
|
222 |
+
'AngularJSAgent': '@AngularJS Agent',
|
223 |
+
'HerokuAgent': '@Heroku Agent',
|
224 |
+
'GodotAgent': '@Godot Agent',
|
225 |
+
'GoAgent': '@Go Agent',
|
226 |
+
'GitlabAgent': '@Gitlab Agent',
|
227 |
+
'GitAgent': '@GitAgent',
|
228 |
+
'blackboxai-pro': '@BLACKBOXAI-PRO',
|
229 |
+
'flux': '@Image Generation',
|
230 |
+
# Add any additional prefixes if necessary
|
231 |
+
|
232 |
+
# Added New Agents
|
233 |
+
'FlaskAgent': '@Flask Agent',
|
234 |
+
'FirebaseAgent': '@Firebase Agent',
|
235 |
+
'FastAPIAgent': '@FastAPI Agent',
|
236 |
+
'ErlangAgent': '@Erlang Agent',
|
237 |
+
'ElectronAgent': '@Electron Agent',
|
238 |
+
'DockerAgent': '@Docker Agent',
|
239 |
+
'DigitalOceanAgent': '@DigitalOcean Agent',
|
240 |
+
'BitbucketAgent': '@Bitbucket Agent',
|
241 |
+
'AzureAgent': '@Azure Agent',
|
242 |
+
'FlutterAgent': '@Flutter Agent',
|
243 |
+
'YoutubeAgent': '@Youtube Agent',
|
244 |
+
'builderAgent': '@builder Agent',
|
245 |
}
|
246 |
|
247 |
+
# Model Referers
|
248 |
+
MODEL_REFERERS = {
|
249 |
+
"blackboxai": "/?model=blackboxai",
|
250 |
+
"gpt-4o": "/?model=gpt-4o",
|
251 |
+
"gemini-pro": "/?model=gemini-pro",
|
252 |
+
"claude-sonnet-3.5": "/?model=claude-sonnet-3.5",
|
253 |
+
# Add any additional referers if necessary
|
254 |
+
}
|