Niansuh commited on
Commit
61affc1
·
verified ·
1 Parent(s): ba990bd

Update api/config.py

Browse files
Files changed (1) hide show
  1. api/config.py +85 -6
api/config.py CHANGED
@@ -1,11 +1,15 @@
1
  import os
2
  from dotenv import load_dotenv
 
 
3
 
4
  load_dotenv()
5
 
6
  # Base URL and Common Headers
7
  BASE_URL = "https://www.blackbox.ai"
8
- common_headers = {
 
 
9
  'accept': '*/*',
10
  'accept-language': 'en-US,en;q=0.9',
11
  'cache-control': 'no-cache',
@@ -18,14 +22,35 @@ common_headers = {
18
  'sec-fetch-dest': 'empty',
19
  'sec-fetch-mode': 'cors',
20
  'sec-fetch-site': 'same-origin',
21
- 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
22
- 'AppleWebKit/537.36 (KHTML, like Gecko) '
23
- 'Chrome/130.0.0.0 Safari/537.36',
 
 
24
  }
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  APP_SECRET = os.getenv("APP_SECRET")
27
 
28
- # Allowed Models Configuration
29
  ALLOWED_MODELS = [
30
  {"id": "blackboxai", "name": "blackboxai"},
31
  {"id": "blackboxai-pro", "name": "blackboxai-pro"},
@@ -56,12 +81,15 @@ ALLOWED_MODELS = [
56
  {"id": "GitlabAgent", "name": "GitlabAgent"},
57
  {"id": "GitAgent", "name": "GitAgent"},
58
  {"id": "RepoMap", "name": "RepoMap"},
 
59
  {"id": "gemini-1.5-pro-latest", "name": "gemini-pro"},
60
  {"id": "gemini-1.5-pro", "name": "gemini-1.5-pro"},
61
  {"id": "claude-3-5-sonnet-20240620", "name": "claude-sonnet-3.5"},
62
  {"id": "claude-3-5-sonnet", "name": "claude-sonnet-3.5"},
63
  {"id": "Niansuh", "name": "Niansuh"},
64
  {"id": "o1-preview", "name": "o1-preview"},
 
 
65
  {"id": "FlaskAgent", "name": "FlaskAgent"},
66
  {"id": "FirebaseAgent", "name": "FirebaseAgent"},
67
  {"id": "FastAPIAgent", "name": "FastAPIAgent"},
@@ -76,7 +104,12 @@ ALLOWED_MODELS = [
76
  {"id": "builderAgent", "name": "builderAgent"},
77
  ]
78
 
79
- # Agent modes
 
 
 
 
 
80
  AGENT_MODE = {
81
  'flux': {'mode': True, 'id': "ImageGenerationLV45LJp", 'name': "flux"},
82
  'Niansuh': {'mode': True, 'id': "NiansuhAIk1HgESy", 'name': "Niansuh"},
@@ -109,6 +142,8 @@ TRENDING_AGENT_MODE = {
109
  'GitlabAgent': {'mode': True, 'id': "GitlabAgent"},
110
  'GitAgent': {'mode': True, 'id': "GitAgent"},
111
  'RepoMap': {'mode': True, 'id': "repomap"},
 
 
112
  'FlaskAgent': {'mode': True, 'id': "FlaskAgent"},
113
  'FirebaseAgent': {'mode': True, 'id': "FirebaseAgent"},
114
  'FastAPIAgent': {'mode': True, 'id': "FastAPIAgent"},
@@ -122,3 +157,47 @@ TRENDING_AGENT_MODE = {
122
  'YoutubeAgent': {'mode': True, 'id': "YoutubeAgent"},
123
  'builderAgent': {'mode': True, 'id': "builderAgent"},
124
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import os
2
  from dotenv import load_dotenv
3
+ import random
4
+ import string
5
 
6
  load_dotenv()
7
 
8
  # Base URL and Common Headers
9
  BASE_URL = "https://www.blackbox.ai"
10
+ API_ENDPOINT = "https://www.blackbox.ai/api/chat"
11
+
12
+ COMMON_HEADERS = {
13
  'accept': '*/*',
14
  'accept-language': 'en-US,en;q=0.9',
15
  'cache-control': 'no-cache',
 
22
  'sec-fetch-dest': 'empty',
23
  'sec-fetch-mode': 'cors',
24
  'sec-fetch-site': 'same-origin',
25
+ 'user-agent': (
26
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
27
+ 'AppleWebKit/537.36 (KHTML, like Gecko) '
28
+ 'Chrome/130.0.0.0 Safari/537.36'
29
+ ),
30
  }
31
 
32
+ # Header Configurations for Specific API Calls
33
+ def get_headers_api_chat(referer_url):
34
+ return {
35
+ **COMMON_HEADERS,
36
+ 'Content-Type': 'application/json',
37
+ 'Referer': referer_url
38
+ }
39
+
40
+ def get_headers_chat(chat_url, next_action, next_router_state_tree):
41
+ return {
42
+ **COMMON_HEADERS,
43
+ 'Accept': 'text/x-component',
44
+ 'Content-Type': 'text/plain;charset=UTF-8',
45
+ 'Referer': chat_url,
46
+ 'next-action': next_action,
47
+ 'next-router-state-tree': next_router_state_tree,
48
+ 'next-url': '/',
49
+ }
50
+
51
  APP_SECRET = os.getenv("APP_SECRET")
52
 
53
+ # Model Configurations
54
  ALLOWED_MODELS = [
55
  {"id": "blackboxai", "name": "blackboxai"},
56
  {"id": "blackboxai-pro", "name": "blackboxai-pro"},
 
81
  {"id": "GitlabAgent", "name": "GitlabAgent"},
82
  {"id": "GitAgent", "name": "GitAgent"},
83
  {"id": "RepoMap", "name": "RepoMap"},
84
+ # Additional mappings
85
  {"id": "gemini-1.5-pro-latest", "name": "gemini-pro"},
86
  {"id": "gemini-1.5-pro", "name": "gemini-1.5-pro"},
87
  {"id": "claude-3-5-sonnet-20240620", "name": "claude-sonnet-3.5"},
88
  {"id": "claude-3-5-sonnet", "name": "claude-sonnet-3.5"},
89
  {"id": "Niansuh", "name": "Niansuh"},
90
  {"id": "o1-preview", "name": "o1-preview"},
91
+
92
+ # Added New Agents
93
  {"id": "FlaskAgent", "name": "FlaskAgent"},
94
  {"id": "FirebaseAgent", "name": "FirebaseAgent"},
95
  {"id": "FastAPIAgent", "name": "FastAPIAgent"},
 
104
  {"id": "builderAgent", "name": "builderAgent"},
105
  ]
106
 
107
+ # Model Aliases
108
+ MODEL_MAPPING = {
109
+ model["id"]: model["name"] for model in ALLOWED_MODELS
110
+ }
111
+
112
+ # Agent Modes
113
  AGENT_MODE = {
114
  'flux': {'mode': True, 'id': "ImageGenerationLV45LJp", 'name': "flux"},
115
  'Niansuh': {'mode': True, 'id': "NiansuhAIk1HgESy", 'name': "Niansuh"},
 
142
  'GitlabAgent': {'mode': True, 'id': "GitlabAgent"},
143
  'GitAgent': {'mode': True, 'id': "GitAgent"},
144
  'RepoMap': {'mode': True, 'id': "repomap"},
145
+
146
+ # Added New Agents
147
  'FlaskAgent': {'mode': True, 'id': "FlaskAgent"},
148
  'FirebaseAgent': {'mode': True, 'id': "FirebaseAgent"},
149
  'FastAPIAgent': {'mode': True, 'id': "FastAPIAgent"},
 
157
  'YoutubeAgent': {'mode': True, 'id': "YoutubeAgent"},
158
  'builderAgent': {'mode': True, 'id': "builderAgent"},
159
  }
160
+
161
+ # Model Prefixes
162
+ MODEL_PREFIXES = {
163
+ 'gpt-4o': '@GPT-4o',
164
+ 'gemini-pro': '@Gemini-PRO',
165
+ 'PythonAgent': '@Python Agent',
166
+ 'JavaAgent': '@Java Agent',
167
+ 'JavaScriptAgent': '@JavaScript Agent',
168
+ 'HTMLAgent': '@HTML Agent',
169
+ 'GoogleCloudAgent': '@Google Cloud Agent',
170
+ 'AndroidDeveloper': '@Android Developer',
171
+ 'SwiftDeveloper': '@Swift Developer',
172
+ 'Next.jsAgent': '@Next.js Agent',
173
+ 'MongoDBAgent': '@MongoDB Agent',
174
+ 'PyTorchAgent': '@PyTorch Agent',
175
+ 'ReactAgent': '@React Agent',
176
+ 'XcodeAgent': '@Xcode Agent',
177
+ 'AngularJSAgent': '@AngularJS Agent',
178
+ 'HerokuAgent': '@Heroku Agent',
179
+ 'GodotAgent': '@Godot Agent',
180
+ 'GoAgent': '@Go Agent',
181
+ 'GitlabAgent': '@Gitlab Agent',
182
+ 'GitAgent': '@Gitlab Agent', # Note: Ensure if this is intentional or a typo
183
+ 'blackboxai-pro': '@BLACKBOXAI-PRO',
184
+ 'flux': '@Image Generation',
185
+ # Added New Agents
186
+ 'FlaskAgent': '@Flask Agent',
187
+ 'FirebaseAgent': '@Firebase Agent',
188
+ 'FastAPIAgent': '@FastAPI Agent',
189
+ 'ErlangAgent': '@Erlang Agent',
190
+ 'ElectronAgent': '@Electron Agent',
191
+ 'DockerAgent': '@Docker Agent',
192
+ 'DigitalOceanAgent': '@DigitalOcean Agent',
193
+ 'BitbucketAgent': '@Bitbucket Agent',
194
+ 'AzureAgent': '@Azure Agent',
195
+ 'FlutterAgent': '@Flutter Agent',
196
+ 'YoutubeAgent': '@Youtube Agent',
197
+ 'builderAgent': '@builder Agent',
198
+ }
199
+
200
+ # Generate a random ID
201
+ def generate_id(length=7):
202
+ characters = string.ascii_letters + string.digits
203
+ return ''.join(random.choice(characters) for _ in range(length))