test24 / api /config.py
Niansuh's picture
Update api/config.py
1da90a6 verified
raw
history blame
6.69 kB
# 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)