Update api/config.py
Browse files- api/config.py +49 -23
api/config.py
CHANGED
|
@@ -1,32 +1,45 @@
|
|
| 1 |
-
# config.py
|
| 2 |
-
|
| 3 |
import os
|
| 4 |
from dotenv import load_dotenv
|
| 5 |
|
| 6 |
load_dotenv()
|
| 7 |
|
| 8 |
-
# Base URL
|
| 9 |
BASE_URL = "https://www.blackbox.ai"
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
'
|
| 14 |
-
'
|
| 15 |
-
'
|
| 16 |
-
'
|
| 17 |
-
'
|
| 18 |
-
'
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
'
|
|
|
|
|
|
|
| 24 |
}
|
| 25 |
|
| 26 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
APP_SECRET = os.getenv("APP_SECRET")
|
| 28 |
|
| 29 |
-
# Allowed Models
|
| 30 |
ALLOWED_MODELS = [
|
| 31 |
{"id": "blackboxai", "name": "blackboxai"},
|
| 32 |
{"id": "blackboxai-pro", "name": "blackboxai-pro"},
|
|
@@ -79,12 +92,11 @@ ALLOWED_MODELS = [
|
|
| 79 |
{"id": "builderAgent", "name": "builderAgent"},
|
| 80 |
]
|
| 81 |
|
| 82 |
-
# Model Mapping for Aliases
|
| 83 |
MODEL_MAPPING = {
|
| 84 |
"blackboxai": "blackboxai",
|
| 85 |
"blackboxai-pro": "blackboxai-pro",
|
| 86 |
"flux": "flux",
|
| 87 |
-
"
|
| 88 |
"llama-3.1-8b": "llama-3.1-8b",
|
| 89 |
"llama-3.1-70b": "llama-3.1-70b",
|
| 90 |
"llama-3.1-405b": "llama-3.1-405",
|
|
@@ -111,6 +123,7 @@ MODEL_MAPPING = {
|
|
| 111 |
"GitlabAgent": "GitlabAgent",
|
| 112 |
"GitAgent": "GitAgent",
|
| 113 |
"RepoMap": "RepoMap",
|
|
|
|
| 114 |
"gemini-flash": "gemini-1.5-flash",
|
| 115 |
"claude-3.5-sonnet": "claude-sonnet-3.5",
|
| 116 |
"flux": "flux",
|
|
@@ -136,14 +149,13 @@ MODEL_MAPPING = {
|
|
| 136 |
"builderAgent": "builderAgent",
|
| 137 |
}
|
| 138 |
|
| 139 |
-
# Agent
|
| 140 |
AGENT_MODE = {
|
| 141 |
'flux': {'mode': True, 'id': "ImageGenerationLV45LJp", 'name': "flux"},
|
| 142 |
'Niansuh': {'mode': True, 'id': "NiansuhAIk1HgESy", 'name': "Niansuh"},
|
| 143 |
'o1-preview': {'mode': True, 'id': "o1Dst8La8", 'name': "o1-preview"},
|
| 144 |
}
|
| 145 |
|
| 146 |
-
# Trending Agent Modes
|
| 147 |
TRENDING_AGENT_MODE = {
|
| 148 |
"blackboxai": {},
|
| 149 |
"gemini-1.5-flash": {'mode': True, 'id': 'Gemini'},
|
|
@@ -185,3 +197,17 @@ TRENDING_AGENT_MODE = {
|
|
| 185 |
'YoutubeAgent': {'mode': True, 'id': "YoutubeAgent"},
|
| 186 |
'builderAgent': {'mode': True, 'id': "builderAgent"},
|
| 187 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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',
|
| 12 |
+
'origin': BASE_URL,
|
| 13 |
+
'pragma': 'no-cache',
|
| 14 |
+
'priority': 'u=1, i',
|
| 15 |
+
'sec-ch-ua': '"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',
|
| 16 |
+
'sec-ch-ua-mobile': '?0',
|
| 17 |
+
'sec-ch-ua-platform': '"Windows"',
|
| 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 |
+
# Header Configurations for Specific API Calls
|
| 27 |
+
def get_headers_api_chat(referer_url):
|
| 28 |
+
return {**common_headers, 'Content-Type': 'application/json', 'Referer': referer_url}
|
| 29 |
+
|
| 30 |
+
def get_headers_chat(chat_url, next_action, next_router_state_tree):
|
| 31 |
+
return {
|
| 32 |
+
**common_headers,
|
| 33 |
+
'Accept': 'text/x-component',
|
| 34 |
+
'Content-Type': 'text/plain;charset=UTF-8',
|
| 35 |
+
'Referer': chat_url,
|
| 36 |
+
'next-action': next_action,
|
| 37 |
+
'next-router-state-tree': next_router_state_tree,
|
| 38 |
+
'next-url': '/',
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
APP_SECRET = os.getenv("APP_SECRET")
|
| 42 |
|
|
|
|
| 43 |
ALLOWED_MODELS = [
|
| 44 |
{"id": "blackboxai", "name": "blackboxai"},
|
| 45 |
{"id": "blackboxai-pro", "name": "blackboxai-pro"},
|
|
|
|
| 92 |
{"id": "builderAgent", "name": "builderAgent"},
|
| 93 |
]
|
| 94 |
|
|
|
|
| 95 |
MODEL_MAPPING = {
|
| 96 |
"blackboxai": "blackboxai",
|
| 97 |
"blackboxai-pro": "blackboxai-pro",
|
| 98 |
"flux": "flux",
|
| 99 |
+
"ImageGeneration": "flux",
|
| 100 |
"llama-3.1-8b": "llama-3.1-8b",
|
| 101 |
"llama-3.1-70b": "llama-3.1-70b",
|
| 102 |
"llama-3.1-405b": "llama-3.1-405",
|
|
|
|
| 123 |
"GitlabAgent": "GitlabAgent",
|
| 124 |
"GitAgent": "GitAgent",
|
| 125 |
"RepoMap": "RepoMap",
|
| 126 |
+
# Additional mappings
|
| 127 |
"gemini-flash": "gemini-1.5-flash",
|
| 128 |
"claude-3.5-sonnet": "claude-sonnet-3.5",
|
| 129 |
"flux": "flux",
|
|
|
|
| 149 |
"builderAgent": "builderAgent",
|
| 150 |
}
|
| 151 |
|
| 152 |
+
# Agent modes
|
| 153 |
AGENT_MODE = {
|
| 154 |
'flux': {'mode': True, 'id': "ImageGenerationLV45LJp", 'name': "flux"},
|
| 155 |
'Niansuh': {'mode': True, 'id': "NiansuhAIk1HgESy", 'name': "Niansuh"},
|
| 156 |
'o1-preview': {'mode': True, 'id': "o1Dst8La8", 'name': "o1-preview"},
|
| 157 |
}
|
| 158 |
|
|
|
|
| 159 |
TRENDING_AGENT_MODE = {
|
| 160 |
"blackboxai": {},
|
| 161 |
"gemini-1.5-flash": {'mode': True, 'id': 'Gemini'},
|
|
|
|
| 197 |
'YoutubeAgent': {'mode': True, 'id': "YoutubeAgent"},
|
| 198 |
'builderAgent': {'mode': True, 'id': "builderAgent"},
|
| 199 |
}
|
| 200 |
+
|
| 201 |
+
# Model prefixes
|
| 202 |
+
MODEL_PREFIXES = {
|
| 203 |
+
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
# Model referers
|
| 207 |
+
MODEL_REFERERS = {
|
| 208 |
+
"blackboxai": "/?model=blackboxai",
|
| 209 |
+
"gpt-4o": "/?model=gpt-4o",
|
| 210 |
+
"gemini-pro": "/?model=gemini-pro",
|
| 211 |
+
"claude-sonnet-3.5": "/?model=claude-sonnet-3.5",
|
| 212 |
+
# Add any additional referers if necessary
|
| 213 |
+
}
|