File size: 6,692 Bytes
1da90a6
 
6a247c1
1a5a844
 
1da90a6
1a5a844
6a247c1
1da90a6
6a247c1
 
1da90a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6a247c1
 
1da90a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6a247c1
1da90a6
 
 
 
 
 
 
 
1a5a844
1da90a6
 
 
 
 
 
 
1a5a844
2ae7fb3
1da90a6
 
 
 
 
 
 
 
 
1a5a844
 
 
 
 
1da90a6
 
1a5a844
1da90a6
 
 
 
1a5a844
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
532a10c
1da90a6
 
6a247c1
1da90a6
 
 
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
# api/config.py

import os
from dotenv import load_dotenv

# Load environment variables from .env file
load_dotenv()

# Base URL for external API
BASE_URL = "https://www.blackbox.ai"

# Common headers for HTTP requests
headers = {
    'accept': '*/*',
    'accept-language': 'zh-CN,zh;q=0.9',
    'content-type': 'application/json',
    'origin': 'https://www.blackbox.ai',
    '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/129.0.0.0 Safari/537.36',
}

# Application secret key for authentication
APP_SECRET = os.getenv("APP_SECRET")

# Default model used by the application
default_model = 'blackboxai'

# Image-related models
image_models = ['Image Generation', 'repomap']

# User-selected models
userSelectedModel = ['gpt-4o', 'gemini-pro', 'claude-sonnet-3.5', 'blackboxai-pro']

# Agent modes with their configurations
agentMode = {
    'Image Generation': {'mode': True, 'id': "ImageGenerationLV45LJp", 'name': "Image Generation"},
}

# Trending agent modes with their configurations
trendingAgentMode = {
    "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"},
    'Python Agent': {'mode': True, 'id': "Python Agent"},
    'Java Agent': {'mode': True, 'id': "Java Agent"},
    'JavaScript Agent': {'mode': True, 'id': "JavaScript Agent"},
    'HTML Agent': {'mode': True, 'id': "HTML Agent"},
    'Google Cloud Agent': {'mode': True, 'id': "Google Cloud Agent"},
    'Android Developer': {'mode': True, 'id': "Android Developer"},
    'Swift Developer': {'mode': True, 'id': "Swift Developer"},
    'Next.js Agent': {'mode': True, 'id': "Next.js Agent"},
    'MongoDB Agent': {'mode': True, 'id': "MongoDB Agent"},
    'PyTorch Agent': {'mode': True, 'id': "PyTorch Agent"},
    'React Agent': {'mode': True, 'id': "React Agent"},
    'Xcode Agent': {'mode': True, 'id': "Xcode Agent"},
    'AngularJS Agent': {'mode': True, 'id': "AngularJS Agent"},
    'repomap': {'mode': True, 'id': "repomap"},
    'Heroku Agent': {'mode': True, 'id': "Heroku Agent"},
    'Godot Agent': {'mode': True, 'id': "Godot Agent"},
    'Go Agent': {'mode': True, 'id': "Go Agent"},
    'Gitlab Agent': {'mode': True, 'id': "Gitlab Agent"},
    'Git Agent': {'mode': True, 'id': "Git Agent"},
    'Flask Agent': {'mode': True, 'id': "Flask Agent"},
    'Firebase Agent': {'mode': True, 'id': "Firebase Agent"},
    'FastAPI Agent': {'mode': True, 'id': "FastAPI Agent"},
    'Erlang Agent': {'mode': True, 'id': "Erlang Agent"},
    'Electron Agent': {'mode': True, 'id': "Electron Agent"},
    'Docker Agent': {'mode': True, 'id': "Docker Agent"},
    'DigitalOcean Agent': {'mode': True, 'id': "DigitalOcean Agent"},
    'Bitbucket Agent': {'mode': True, 'id': "Bitbucket Agent"},
    'Azure Agent': {'mode': True, 'id': "Azure Agent"},
    'Flutter Agent': {'mode': True, 'id': "Flutter Agent"},
    'Youtube Agent': {'mode': True, 'id': "Youtube Agent"},
    'builder Agent': {'mode': True, 'id': "builder Agent"},
}

# Prefixes for trending agent modes (excluding specific models)
model_prefixes = {
    mode: f"@{value['id']}"
    for mode, value in trendingAgentMode.items()
    if mode not in ["gemini-1.5-flash", "llama-3.1-8b", "llama-3.1-70b", "llama-3.1-405b", "repomap"]
}

# Comprehensive list of all models
models = [
    default_model,
    *userSelectedModel,
    *list(agentMode.keys()),
    *list(trendingAgentMode.keys())
]

# Aliases for certain models to handle alternative naming
model_aliases = {
    "gemini-flash": "gemini-1.5-flash",
    "claude-3.5-sonnet": "claude-sonnet-3.5",
    "flux": "Image Generation",
}

# Allowed models for API requests
ALLOWED_MODELS = [
    {"id": default_model, "name": "BlackboxAI"},
    {"id": "gpt-4o", "name": "GPT-4o"},
    {"id": "gemini-pro", "name": "Gemini Pro"},
    {"id": "claude-sonnet-3.5", "name": "Claude Sonnet 3.5"},
    {"id": "blackboxai-pro", "name": "BlackboxAI-Pro"},
    {"id": "Image Generation", "name": "Image Generation"},
    {"id": "repomap", "name": "Repomap"},
]

# Add agentMode models to ALLOWED_MODELS
for model_key, model_info in agentMode.items():
    ALLOWED_MODELS.append({"id": model_info['id'], "name": model_info['name']})

# Add trendingAgentMode models to ALLOWED_MODELS
for model_key, model_info in trendingAgentMode.items():
    ALLOWED_MODELS.append({"id": model_info['id'], "name": model_key})

# Mapping from user-provided model identifiers to internal model identifiers
MODEL_MAPPING = {
    "blackboxai": "blackboxai",
    "gpt-4o": "gpt-4o",
    "gemini-pro": "gemini-pro",
    "claude-sonnet-3.5": "claude-sonnet-3.5",
    "blackboxai-pro": "BLACKBOXAI-PRO",
    "Image Generation": "ImageGenerationLV45LJp",
    "repomap": "repomap",
    "gemini-1.5-flash": "Gemini",
    "llama-3.1-8b": "llama-3.1-8b",
    "llama-3.1-70b": "llama-3.1-70b",
    "llama-3.1-405b": "llama-3.1-405",
    "Python Agent": "Python Agent",
    "Java Agent": "Java Agent",
    "JavaScript Agent": "JavaScript Agent",
    "HTML Agent": "HTML Agent",
    "Google Cloud Agent": "Google Cloud Agent",
    "Android Developer": "Android Developer",
    "Swift Developer": "Swift Developer",
    "Next.js Agent": "Next.js Agent",
    "MongoDB Agent": "MongoDB Agent",
    "PyTorch Agent": "PyTorch Agent",
    "React Agent": "React Agent",
    "Xcode Agent": "Xcode Agent",
    "AngularJS Agent": "AngularJS Agent",
    "Heroku Agent": "Heroku Agent",
    "Godot Agent": "Godot Agent",
    "Go Agent": "Go Agent",
    "Gitlab Agent": "Gitlab Agent",
    "Git Agent": "Git Agent",
    "Flask Agent": "Flask Agent",
    "Firebase Agent": "Firebase Agent",
    "FastAPI Agent": "FastAPI Agent",
    "Erlang Agent": "Erlang Agent",
    "Electron Agent": "Electron Agent",
    "Docker Agent": "Docker Agent",
    "DigitalOcean Agent": "DigitalOcean Agent",
    "Bitbucket Agent": "Bitbucket Agent",
    "Azure Agent": "Azure Agent",
    "Flutter Agent": "Flutter Agent",
    "Youtube Agent": "Youtube Agent",
    "builder Agent": "builder Agent",
}

# Reverse mapping for model aliases
REVERSE_MODEL_MAPPING = {alias: original for alias, original in model_aliases.items()}

# Function to resolve model aliases
def resolve_model(model_name: str) -> str:
    return REVERSE_MODEL_MAPPING.get(model_name, model_name)