Niansuh commited on
Commit
16f7793
·
verified ·
1 Parent(s): 3721a6d

Update api/config.py

Browse files
Files changed (1) hide show
  1. api/config.py +9 -103
api/config.py CHANGED
@@ -1,15 +1,9 @@
1
- # api/config.py
2
-
3
  import os
4
  from dotenv import load_dotenv
5
 
6
- # Load environment variables from .env file
7
  load_dotenv()
8
 
9
- # Base URL for external API
10
  BASE_URL = "https://www.blackbox.ai"
11
-
12
- # Common headers for HTTP requests
13
  headers = {
14
  'accept': '*/*',
15
  'accept-language': 'zh-CN,zh;q=0.9',
@@ -24,30 +18,21 @@ headers = {
24
  'sec-fetch-site': 'same-origin',
25
  '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',
26
  }
27
-
28
- # Application secret key for authentication
29
  APP_SECRET = os.getenv("APP_SECRET")
30
 
31
- # Default model used by the application
32
  default_model = 'blackboxai'
33
-
34
- # Image-related models
35
  image_models = ['Image Generation', 'repomap']
36
-
37
- # User-selected models
38
  userSelectedModel = ['gpt-4o', 'gemini-pro', 'claude-sonnet-3.5', 'blackboxai-pro']
39
 
40
- # Agent modes with their configurations
41
  agentMode = {
42
  'Image Generation': {'mode': True, 'id': "ImageGenerationLV45LJp", 'name': "Image Generation"},
43
  }
44
-
45
- # Trending agent modes with their configurations
46
  trendingAgentMode = {
47
  "gemini-1.5-flash": {'mode': True, 'id': 'Gemini'},
48
  "llama-3.1-8b": {'mode': True, 'id': "llama-3.1-8b"},
49
- 'llama-3.1-70b': {'mode': True, 'id': "llama-3.1-70b"},
50
- 'llama-3.1-405b': {'mode': True, 'id': "llama-3.1-405"},
51
  'Python Agent': {'mode': True, 'id': "Python Agent"},
52
  'Java Agent': {'mode': True, 'id': "Java Agent"},
53
  'JavaScript Agent': {'mode': True, 'id': "JavaScript Agent"},
@@ -61,6 +46,7 @@ trendingAgentMode = {
61
  'React Agent': {'mode': True, 'id': "React Agent"},
62
  'Xcode Agent': {'mode': True, 'id': "Xcode Agent"},
63
  'AngularJS Agent': {'mode': True, 'id': "AngularJS Agent"},
 
64
  'repomap': {'mode': True, 'id': "repomap"},
65
  'Heroku Agent': {'mode': True, 'id': "Heroku Agent"},
66
  'Godot Agent': {'mode': True, 'id': "Godot Agent"},
@@ -81,95 +67,15 @@ trendingAgentMode = {
81
  'builder Agent': {'mode': True, 'id': "builder Agent"},
82
  }
83
 
84
- # Prefixes for trending agent modes (excluding specific models)
85
- model_prefixes = {
86
- mode: f"@{value['id']}"
87
- for mode, value in trendingAgentMode.items()
88
- if mode not in ["gemini-1.5-flash", "llama-3.1-8b", "llama-3.1-70b", "llama-3.1-405b", "repomap"]
89
- }
90
 
91
- # Comprehensive list of all models
92
- models = [
93
- default_model,
94
- *userSelectedModel,
95
- *list(agentMode.keys()),
96
- *list(trendingAgentMode.keys())
97
- ]
98
 
99
- # Aliases for certain models to handle alternative naming
100
  model_aliases = {
101
  "gemini-flash": "gemini-1.5-flash",
102
  "claude-3.5-sonnet": "claude-sonnet-3.5",
103
  "flux": "Image Generation",
104
  }
105
-
106
- # Allowed models for API requests
107
- ALLOWED_MODELS = [
108
- {"id": default_model, "name": "BlackboxAI"},
109
- {"id": "gpt-4o", "name": "GPT-4o"},
110
- {"id": "gemini-pro", "name": "Gemini Pro"},
111
- {"id": "claude-sonnet-3.5", "name": "Claude Sonnet 3.5"},
112
- {"id": "blackboxai-pro", "name": "BlackboxAI-Pro"},
113
- {"id": "Image Generation", "name": "Image Generation"},
114
- {"id": "repomap", "name": "Repomap"},
115
- ]
116
-
117
- # Add agentMode models to ALLOWED_MODELS
118
- for model_key, model_info in agentMode.items():
119
- ALLOWED_MODELS.append({"id": model_info['id'], "name": model_info['name']})
120
-
121
- # Add trendingAgentMode models to ALLOWED_MODELS
122
- for model_key, model_info in trendingAgentMode.items():
123
- ALLOWED_MODELS.append({"id": model_info['id'], "name": model_key})
124
-
125
- # Mapping from user-provided model identifiers to internal model identifiers
126
- MODEL_MAPPING = {
127
- "blackboxai": "blackboxai",
128
- "gpt-4o": "gpt-4o",
129
- "gemini-pro": "gemini-pro",
130
- "claude-sonnet-3.5": "claude-sonnet-3.5",
131
- "blackboxai-pro": "BLACKBOXAI-PRO",
132
- "Image Generation": "ImageGenerationLV45LJp",
133
- "repomap": "repomap",
134
- "gemini-1.5-flash": "Gemini",
135
- "llama-3.1-8b": "llama-3.1-8b",
136
- "llama-3.1-70b": "llama-3.1-70b",
137
- "llama-3.1-405b": "llama-3.1-405",
138
- "Python Agent": "Python Agent",
139
- "Java Agent": "Java Agent",
140
- "JavaScript Agent": "JavaScript Agent",
141
- "HTML Agent": "HTML Agent",
142
- "Google Cloud Agent": "Google Cloud Agent",
143
- "Android Developer": "Android Developer",
144
- "Swift Developer": "Swift Developer",
145
- "Next.js Agent": "Next.js Agent",
146
- "MongoDB Agent": "MongoDB Agent",
147
- "PyTorch Agent": "PyTorch Agent",
148
- "React Agent": "React Agent",
149
- "Xcode Agent": "Xcode Agent",
150
- "AngularJS Agent": "AngularJS Agent",
151
- "Heroku Agent": "Heroku Agent",
152
- "Godot Agent": "Godot Agent",
153
- "Go Agent": "Go Agent",
154
- "Gitlab Agent": "Gitlab Agent",
155
- "Git Agent": "Git Agent",
156
- "Flask Agent": "Flask Agent",
157
- "Firebase Agent": "Firebase Agent",
158
- "FastAPI Agent": "FastAPI Agent",
159
- "Erlang Agent": "Erlang Agent",
160
- "Electron Agent": "Electron Agent",
161
- "Docker Agent": "Docker Agent",
162
- "DigitalOcean Agent": "DigitalOcean Agent",
163
- "Bitbucket Agent": "Bitbucket Agent",
164
- "Azure Agent": "Azure Agent",
165
- "Flutter Agent": "Flutter Agent",
166
- "Youtube Agent": "Youtube Agent",
167
- "builder Agent": "builder Agent",
168
- }
169
-
170
- # Reverse mapping for model aliases
171
- REVERSE_MODEL_MAPPING = {alias: original for alias, original in model_aliases.items()}
172
-
173
- # Function to resolve model aliases
174
- def resolve_model(model_name: str) -> str:
175
- return REVERSE_MODEL_MAPPING.get(model_name, model_name)
 
 
 
1
  import os
2
  from dotenv import load_dotenv
3
 
 
4
  load_dotenv()
5
 
 
6
  BASE_URL = "https://www.blackbox.ai"
 
 
7
  headers = {
8
  'accept': '*/*',
9
  'accept-language': 'zh-CN,zh;q=0.9',
 
18
  'sec-fetch-site': 'same-origin',
19
  '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',
20
  }
 
 
21
  APP_SECRET = os.getenv("APP_SECRET")
22
 
 
23
  default_model = 'blackboxai'
 
 
24
  image_models = ['Image Generation', 'repomap']
 
 
25
  userSelectedModel = ['gpt-4o', 'gemini-pro', 'claude-sonnet-3.5', 'blackboxai-pro']
26
 
27
+ # Agent and trending agent modes
28
  agentMode = {
29
  'Image Generation': {'mode': True, 'id': "ImageGenerationLV45LJp", 'name': "Image Generation"},
30
  }
 
 
31
  trendingAgentMode = {
32
  "gemini-1.5-flash": {'mode': True, 'id': 'Gemini'},
33
  "llama-3.1-8b": {'mode': True, 'id': "llama-3.1-8b"},
34
+ "llama-3.1-70b": {'mode': True, 'id': "llama-3.1-70b"},
35
+ "llama-3.1-405b": {'mode': True, 'id': "llama-3.1-405b"},
36
  'Python Agent': {'mode': True, 'id': "Python Agent"},
37
  'Java Agent': {'mode': True, 'id': "Java Agent"},
38
  'JavaScript Agent': {'mode': True, 'id': "JavaScript Agent"},
 
46
  'React Agent': {'mode': True, 'id': "React Agent"},
47
  'Xcode Agent': {'mode': True, 'id': "Xcode Agent"},
48
  'AngularJS Agent': {'mode': True, 'id': "AngularJS Agent"},
49
+ 'blackboxai-pro': {'mode': True, 'id': "BLACKBOXAI-PRO"},
50
  'repomap': {'mode': True, 'id': "repomap"},
51
  'Heroku Agent': {'mode': True, 'id': "Heroku Agent"},
52
  'Godot Agent': {'mode': True, 'id': "Godot Agent"},
 
67
  'builder Agent': {'mode': True, 'id': "builder Agent"},
68
  }
69
 
70
+ # Model prefixes for trending agent modes
71
+ 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"]}
 
 
 
 
72
 
73
+ # Consolidated models list
74
+ models = [default_model, *userSelectedModel, *list(agentMode.keys()), *list(trendingAgentMode.keys())]
 
 
 
 
 
75
 
76
+ # Aliases for model names
77
  model_aliases = {
78
  "gemini-flash": "gemini-1.5-flash",
79
  "claude-3.5-sonnet": "claude-sonnet-3.5",
80
  "flux": "Image Generation",
81
  }