Update api/config.py
Browse files- api/config.py +85 -125
api/config.py
CHANGED
|
@@ -5,37 +5,35 @@ import string
|
|
| 5 |
|
| 6 |
load_dotenv()
|
| 7 |
|
| 8 |
-
# Base URL and
|
| 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',
|
|
|
|
| 16 |
'origin': BASE_URL,
|
| 17 |
'pragma': 'no-cache',
|
| 18 |
'priority': 'u=1, i',
|
| 19 |
-
'
|
|
|
|
| 20 |
'sec-ch-ua-mobile': '?0',
|
| 21 |
-
'sec-ch-ua-platform': '"
|
| 22 |
'sec-fetch-dest': 'empty',
|
| 23 |
'sec-fetch-mode': 'cors',
|
| 24 |
'sec-fetch-site': 'same-origin',
|
| 25 |
'user-agent': (
|
| 26 |
-
'Mozilla/5.0 (
|
| 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(
|
| 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 {
|
|
@@ -62,141 +60,103 @@ ALLOWED_MODELS = [
|
|
| 62 |
{"id": "gemini-pro", "name": "gemini-pro"},
|
| 63 |
{"id": "gemini-1.5-flash", "name": "gemini-1.5-flash"},
|
| 64 |
{"id": "claude-sonnet-3.5", "name": "claude-sonnet-3.5"},
|
| 65 |
-
{"id": "
|
| 66 |
-
{"id": "
|
| 67 |
-
{"id": "
|
| 68 |
-
{"id": "
|
| 69 |
-
{"id": "
|
| 70 |
-
{"id": "
|
| 71 |
-
{"id": "
|
| 72 |
-
{"id": "Next.
|
| 73 |
-
{"id": "
|
| 74 |
-
{"id": "
|
| 75 |
-
{"id": "
|
| 76 |
-
{"id": "
|
| 77 |
-
{"id": "
|
| 78 |
-
{"id": "
|
| 79 |
-
{"id": "
|
| 80 |
-
{"id": "
|
| 81 |
-
{"id": "
|
| 82 |
-
{"id": "
|
| 83 |
-
{"id": "
|
| 84 |
-
|
| 85 |
-
{"id": "
|
| 86 |
-
{"id": "
|
| 87 |
-
{"id": "
|
| 88 |
-
{"id": "
|
| 89 |
-
{"id": "
|
| 90 |
-
{"id": "
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
{"id": "
|
| 94 |
-
{"id": "
|
| 95 |
-
{"id": "
|
| 96 |
-
{"id": "ErlangAgent", "name": "ErlangAgent"},
|
| 97 |
-
{"id": "ElectronAgent", "name": "ElectronAgent"},
|
| 98 |
-
{"id": "DockerAgent", "name": "DockerAgent"},
|
| 99 |
-
{"id": "DigitalOceanAgent", "name": "DigitalOceanAgent"},
|
| 100 |
-
{"id": "BitbucketAgent", "name": "BitbucketAgent"},
|
| 101 |
-
{"id": "AzureAgent", "name": "AzureAgent"},
|
| 102 |
-
{"id": "FlutterAgent", "name": "FlutterAgent"},
|
| 103 |
-
{"id": "YoutubeAgent", "name": "YoutubeAgent"},
|
| 104 |
-
{"id": "builderAgent", "name": "builderAgent"},
|
| 105 |
]
|
| 106 |
|
| 107 |
# Model Aliases
|
| 108 |
-
|
| 109 |
-
|
|
|
|
|
|
|
| 110 |
}
|
| 111 |
|
| 112 |
# Agent Modes
|
| 113 |
AGENT_MODE = {
|
| 114 |
-
'
|
| 115 |
-
'Niansuh': {'mode': True, 'id': "NiansuhAIk1HgESy", 'name': "Niansuh"},
|
| 116 |
-
'o1-preview': {'mode': True, 'id': "o1Dst8La8", 'name': "o1-preview"},
|
| 117 |
}
|
| 118 |
|
|
|
|
| 119 |
TRENDING_AGENT_MODE = {
|
| 120 |
-
"blackboxai": {},
|
| 121 |
"gemini-1.5-flash": {'mode': True, 'id': 'Gemini'},
|
| 122 |
"llama-3.1-8b": {'mode': True, 'id': "llama-3.1-8b"},
|
| 123 |
'llama-3.1-70b': {'mode': True, 'id': "llama-3.1-70b"},
|
| 124 |
'llama-3.1-405b': {'mode': True, 'id': "llama-3.1-405"},
|
| 125 |
'blackboxai-pro': {'mode': True, 'id': "BLACKBOXAI-PRO"},
|
| 126 |
-
'
|
| 127 |
-
'
|
| 128 |
-
'
|
| 129 |
-
'
|
| 130 |
-
'
|
| 131 |
-
'
|
| 132 |
-
'
|
| 133 |
-
'Next.
|
| 134 |
-
'
|
| 135 |
-
'
|
| 136 |
-
'
|
| 137 |
-
'
|
| 138 |
-
'
|
| 139 |
-
'
|
| 140 |
-
'
|
| 141 |
-
'
|
| 142 |
-
'
|
| 143 |
-
'
|
| 144 |
-
'
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
'
|
| 148 |
-
'
|
| 149 |
-
'
|
| 150 |
-
'
|
| 151 |
-
'
|
| 152 |
-
'
|
| 153 |
-
'
|
| 154 |
-
'
|
| 155 |
-
'
|
| 156 |
-
'
|
| 157 |
-
'YoutubeAgent': {'mode': True, 'id': "YoutubeAgent"},
|
| 158 |
-
'builderAgent': {'mode': True, 'id': "builderAgent"},
|
| 159 |
}
|
| 160 |
|
| 161 |
# Model Prefixes
|
| 162 |
MODEL_PREFIXES = {
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 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
|
|
|
|
| 5 |
|
| 6 |
load_dotenv()
|
| 7 |
|
| 8 |
+
# Base URL and API Endpoint
|
| 9 |
BASE_URL = "https://www.blackbox.ai"
|
| 10 |
API_ENDPOINT = "https://www.blackbox.ai/api/chat"
|
| 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 |
+
'referer': f'{BASE_URL}/',
|
| 22 |
+
'sec-ch-ua': '"Not?A_Brand";v="99", "Chromium";v="130"',
|
| 23 |
'sec-ch-ua-mobile': '?0',
|
| 24 |
+
'sec-ch-ua-platform': '"Linux"',
|
| 25 |
'sec-fetch-dest': 'empty',
|
| 26 |
'sec-fetch-mode': 'cors',
|
| 27 |
'sec-fetch-site': 'same-origin',
|
| 28 |
'user-agent': (
|
| 29 |
+
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) '
|
|
|
|
| 30 |
'Chrome/130.0.0.0 Safari/537.36'
|
| 31 |
),
|
| 32 |
}
|
| 33 |
|
| 34 |
# Header Configurations for Specific API Calls
|
| 35 |
+
def get_headers_api_chat():
|
| 36 |
+
return COMMON_HEADERS.copy()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
def get_headers_chat(chat_url, next_action, next_router_state_tree):
|
| 39 |
return {
|
|
|
|
| 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": "Python Agent", "name": "Python Agent"},
|
| 64 |
+
{"id": "Java Agent", "name": "Java Agent"},
|
| 65 |
+
{"id": "JavaScript Agent", "name": "JavaScript Agent"},
|
| 66 |
+
{"id": "HTML Agent", "name": "HTML Agent"},
|
| 67 |
+
{"id": "Google Cloud Agent", "name": "Google Cloud Agent"},
|
| 68 |
+
{"id": "Android Developer", "name": "Android Developer"},
|
| 69 |
+
{"id": "Swift Developer", "name": "Swift Developer"},
|
| 70 |
+
{"id": "Next.js Agent", "name": "Next.js Agent"},
|
| 71 |
+
{"id": "MongoDB Agent", "name": "MongoDB Agent"},
|
| 72 |
+
{"id": "PyTorch Agent", "name": "PyTorch Agent"},
|
| 73 |
+
{"id": "React Agent", "name": "React Agent"},
|
| 74 |
+
{"id": "Xcode Agent", "name": "Xcode Agent"},
|
| 75 |
+
{"id": "AngularJS Agent", "name": "AngularJS Agent"},
|
| 76 |
+
{"id": "repomap", "name": "repomap"},
|
| 77 |
+
{"id": "Heroku Agent", "name": "Heroku Agent"},
|
| 78 |
+
{"id": "Godot Agent", "name": "Godot Agent"},
|
| 79 |
+
{"id": "Go Agent", "name": "Go Agent"},
|
| 80 |
+
{"id": "Gitlab Agent", "name": "Gitlab Agent"},
|
| 81 |
+
{"id": "Git Agent", "name": "Git Agent"},
|
| 82 |
+
{"id": "Flask Agent", "name": "Flask Agent"},
|
| 83 |
+
{"id": "Firebase Agent", "name": "Firebase Agent"},
|
| 84 |
+
{"id": "FastAPI Agent", "name": "FastAPI Agent"},
|
| 85 |
+
{"id": "Erlang Agent", "name": "Erlang Agent"},
|
| 86 |
+
{"id": "Electron Agent", "name": "Electron Agent"},
|
| 87 |
+
{"id": "Docker Agent", "name": "Docker Agent"},
|
| 88 |
+
{"id": "DigitalOcean Agent", "name": "DigitalOcean Agent"},
|
| 89 |
+
{"id": "Bitbucket Agent", "name": "Bitbucket Agent"},
|
| 90 |
+
{"id": "Azure Agent", "name": "Azure Agent"},
|
| 91 |
+
{"id": "Flutter Agent", "name": "Flutter Agent"},
|
| 92 |
+
{"id": "Youtube Agent", "name": "Youtube Agent"},
|
| 93 |
+
{"id": "builder Agent", "name": "builder Agent"},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
]
|
| 95 |
|
| 96 |
# Model Aliases
|
| 97 |
+
MODEL_ALIASES = {
|
| 98 |
+
"gemini-flash": "gemini-1.5-flash",
|
| 99 |
+
"claude-3.5-sonnet": "claude-sonnet-3.5",
|
| 100 |
+
"flux": "Image Generation",
|
| 101 |
}
|
| 102 |
|
| 103 |
# Agent Modes
|
| 104 |
AGENT_MODE = {
|
| 105 |
+
'Image Generation': {'mode': True, 'id': "ImageGenerationLV45LJp", 'name': "Image Generation"},
|
|
|
|
|
|
|
| 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 |
+
'Python Agent': {'mode': True, 'id': "Python Agent"},
|
| 116 |
+
'Java Agent': {'mode': True, 'id': "Java Agent"},
|
| 117 |
+
'JavaScript Agent': {'mode': True, 'id': "JavaScript Agent"},
|
| 118 |
+
'HTML Agent': {'mode': True, 'id': "HTML Agent"},
|
| 119 |
+
'Google Cloud Agent': {'mode': True, 'id': "Google Cloud Agent"},
|
| 120 |
+
'Android Developer': {'mode': True, 'id': "Android Developer"},
|
| 121 |
+
'Swift Developer': {'mode': True, 'id': "Swift Developer"},
|
| 122 |
+
'Next.js Agent': {'mode': True, 'id': "Next.js Agent"},
|
| 123 |
+
'MongoDB Agent': {'mode': True, 'id': "MongoDB Agent"},
|
| 124 |
+
'PyTorch Agent': {'mode': True, 'id': "PyTorch Agent"},
|
| 125 |
+
'React Agent': {'mode': True, 'id': "React Agent"},
|
| 126 |
+
'Xcode Agent': {'mode': True, 'id': "Xcode Agent"},
|
| 127 |
+
'AngularJS Agent': {'mode': True, 'id': "AngularJS Agent"},
|
| 128 |
+
'repomap': {'mode': True, 'id': "repomap"},
|
| 129 |
+
'Heroku Agent': {'mode': True, 'id': "Heroku Agent"},
|
| 130 |
+
'Godot Agent': {'mode': True, 'id': "Godot Agent"},
|
| 131 |
+
'Go Agent': {'mode': True, 'id': "Go Agent"},
|
| 132 |
+
'Gitlab Agent': {'mode': True, 'id': "Gitlab Agent"},
|
| 133 |
+
'Git Agent': {'mode': True, 'id': "Git Agent"},
|
| 134 |
+
'Flask Agent': {'mode': True, 'id': "Flask Agent"},
|
| 135 |
+
'Firebase Agent': {'mode': True, 'id': "Firebase Agent"},
|
| 136 |
+
'FastAPI Agent': {'mode': True, 'id': "FastAPI Agent"},
|
| 137 |
+
'Erlang Agent': {'mode': True, 'id': "Erlang Agent"},
|
| 138 |
+
'Electron Agent': {'mode': True, 'id': "Electron Agent"},
|
| 139 |
+
'Docker Agent': {'mode': True, 'id': "Docker Agent"},
|
| 140 |
+
'DigitalOcean Agent': {'mode': True, 'id': "DigitalOcean Agent"},
|
| 141 |
+
'Bitbucket Agent': {'mode': True, 'id': "Bitbucket Agent"},
|
| 142 |
+
'Azure Agent': {'mode': True, 'id': "Azure Agent"},
|
| 143 |
+
'Flutter Agent': {'mode': True, 'id': "Flutter Agent"},
|
| 144 |
+
'Youtube Agent': {'mode': True, 'id': "Youtube Agent"},
|
| 145 |
+
'builder Agent': {'mode': True, 'id': "builder Agent"},
|
|
|
|
|
|
|
| 146 |
}
|
| 147 |
|
| 148 |
# Model Prefixes
|
| 149 |
MODEL_PREFIXES = {
|
| 150 |
+
mode: f"@{details['id']}"
|
| 151 |
+
for mode, details in TRENDING_AGENT_MODE.items()
|
| 152 |
+
if mode not in ["gemini-1.5-flash", "llama-3.1-8b", "llama-3.1-70b", "llama-3.1-405b", "repomap"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
}
|
| 154 |
|
| 155 |
+
# Consolidate all models
|
| 156 |
+
MODELS = [model["id"] for model in ALLOWED_MODELS]
|
| 157 |
+
|
| 158 |
+
# Remove MODEL_REFERERS as per your request
|
| 159 |
+
|
| 160 |
# Generate a random ID
|
| 161 |
def generate_id(length=7):
|
| 162 |
characters = string.ascii_letters + string.digits
|