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