webscout 8.2.7__py3-none-any.whl → 8.2.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of webscout might be problematic. Click here for more details.
- webscout/AIauto.py +1 -1
- webscout/AIutel.py +298 -249
- webscout/Extra/Act.md +309 -0
- webscout/Extra/GitToolkit/__init__.py +10 -0
- webscout/Extra/GitToolkit/gitapi/README.md +110 -0
- webscout/Extra/GitToolkit/gitapi/__init__.py +12 -0
- webscout/Extra/GitToolkit/gitapi/repository.py +195 -0
- webscout/Extra/GitToolkit/gitapi/user.py +96 -0
- webscout/Extra/GitToolkit/gitapi/utils.py +62 -0
- webscout/Extra/YTToolkit/README.md +375 -0
- webscout/Extra/YTToolkit/YTdownloader.py +957 -0
- webscout/Extra/YTToolkit/__init__.py +3 -0
- webscout/Extra/YTToolkit/transcriber.py +476 -0
- webscout/Extra/YTToolkit/ytapi/README.md +44 -0
- webscout/Extra/YTToolkit/ytapi/__init__.py +6 -0
- webscout/Extra/YTToolkit/ytapi/channel.py +307 -0
- webscout/Extra/YTToolkit/ytapi/errors.py +13 -0
- webscout/Extra/YTToolkit/ytapi/extras.py +118 -0
- webscout/Extra/YTToolkit/ytapi/https.py +88 -0
- webscout/Extra/YTToolkit/ytapi/patterns.py +61 -0
- webscout/Extra/YTToolkit/ytapi/playlist.py +59 -0
- webscout/Extra/YTToolkit/ytapi/pool.py +8 -0
- webscout/Extra/YTToolkit/ytapi/query.py +40 -0
- webscout/Extra/YTToolkit/ytapi/stream.py +63 -0
- webscout/Extra/YTToolkit/ytapi/utils.py +62 -0
- webscout/Extra/YTToolkit/ytapi/video.py +232 -0
- webscout/Extra/__init__.py +7 -0
- webscout/Extra/autocoder/__init__.py +9 -0
- webscout/Extra/autocoder/autocoder.py +1105 -0
- webscout/Extra/autocoder/autocoder_utiles.py +332 -0
- webscout/Extra/gguf.md +430 -0
- webscout/Extra/gguf.py +684 -0
- webscout/Extra/tempmail/README.md +488 -0
- webscout/Extra/tempmail/__init__.py +28 -0
- webscout/Extra/tempmail/async_utils.py +141 -0
- webscout/Extra/tempmail/base.py +161 -0
- webscout/Extra/tempmail/cli.py +187 -0
- webscout/Extra/tempmail/emailnator.py +84 -0
- webscout/Extra/tempmail/mail_tm.py +361 -0
- webscout/Extra/tempmail/temp_mail_io.py +292 -0
- webscout/Extra/weather.md +281 -0
- webscout/Extra/weather.py +194 -0
- webscout/Extra/weather_ascii.py +76 -0
- webscout/Litlogger/Readme.md +175 -0
- webscout/Litlogger/__init__.py +67 -0
- webscout/Litlogger/core/__init__.py +6 -0
- webscout/Litlogger/core/level.py +23 -0
- webscout/Litlogger/core/logger.py +165 -0
- webscout/Litlogger/handlers/__init__.py +12 -0
- webscout/Litlogger/handlers/console.py +33 -0
- webscout/Litlogger/handlers/file.py +143 -0
- webscout/Litlogger/handlers/network.py +173 -0
- webscout/Litlogger/styles/__init__.py +7 -0
- webscout/Litlogger/styles/colors.py +249 -0
- webscout/Litlogger/styles/formats.py +458 -0
- webscout/Litlogger/styles/text.py +87 -0
- webscout/Litlogger/utils/__init__.py +6 -0
- webscout/Litlogger/utils/detectors.py +153 -0
- webscout/Litlogger/utils/formatters.py +200 -0
- webscout/Provider/AI21.py +177 -0
- webscout/Provider/AISEARCH/DeepFind.py +254 -0
- webscout/Provider/AISEARCH/Perplexity.py +359 -0
- webscout/Provider/AISEARCH/README.md +279 -0
- webscout/Provider/AISEARCH/__init__.py +9 -0
- webscout/Provider/AISEARCH/felo_search.py +228 -0
- webscout/Provider/AISEARCH/genspark_search.py +350 -0
- webscout/Provider/AISEARCH/hika_search.py +198 -0
- webscout/Provider/AISEARCH/iask_search.py +436 -0
- webscout/Provider/AISEARCH/monica_search.py +246 -0
- webscout/Provider/AISEARCH/scira_search.py +324 -0
- webscout/Provider/AISEARCH/webpilotai_search.py +281 -0
- webscout/Provider/Aitopia.py +316 -0
- webscout/Provider/AllenAI.py +440 -0
- webscout/Provider/Andi.py +228 -0
- webscout/Provider/Blackboxai.py +673 -0
- webscout/Provider/ChatGPTClone.py +237 -0
- webscout/Provider/ChatGPTGratis.py +194 -0
- webscout/Provider/ChatSandbox.py +342 -0
- webscout/Provider/Cloudflare.py +324 -0
- webscout/Provider/Cohere.py +208 -0
- webscout/Provider/Deepinfra.py +340 -0
- webscout/Provider/ExaAI.py +261 -0
- webscout/Provider/ExaChat.py +358 -0
- webscout/Provider/Flowith.py +217 -0
- webscout/Provider/FreeGemini.py +250 -0
- webscout/Provider/Gemini.py +169 -0
- webscout/Provider/GithubChat.py +370 -0
- webscout/Provider/GizAI.py +295 -0
- webscout/Provider/Glider.py +225 -0
- webscout/Provider/Groq.py +801 -0
- webscout/Provider/HF_space/__init__.py +0 -0
- webscout/Provider/HF_space/qwen_qwen2.py +206 -0
- webscout/Provider/HeckAI.py +285 -0
- webscout/Provider/HuggingFaceChat.py +469 -0
- webscout/Provider/Hunyuan.py +283 -0
- webscout/Provider/Jadve.py +291 -0
- webscout/Provider/Koboldai.py +384 -0
- webscout/Provider/LambdaChat.py +411 -0
- webscout/Provider/Llama3.py +259 -0
- webscout/Provider/MCPCore.py +315 -0
- webscout/Provider/Marcus.py +198 -0
- webscout/Provider/Nemotron.py +218 -0
- webscout/Provider/Netwrck.py +270 -0
- webscout/Provider/OLLAMA.py +396 -0
- webscout/Provider/OPENAI/BLACKBOXAI.py +735 -0
- webscout/Provider/OPENAI/Cloudflare.py +378 -0
- webscout/Provider/OPENAI/FreeGemini.py +282 -0
- webscout/Provider/OPENAI/NEMOTRON.py +244 -0
- webscout/Provider/OPENAI/README.md +1253 -0
- webscout/Provider/OPENAI/__init__.py +36 -0
- webscout/Provider/OPENAI/ai4chat.py +293 -0
- webscout/Provider/OPENAI/api.py +810 -0
- webscout/Provider/OPENAI/base.py +249 -0
- webscout/Provider/OPENAI/c4ai.py +373 -0
- webscout/Provider/OPENAI/chatgpt.py +556 -0
- webscout/Provider/OPENAI/chatgptclone.py +488 -0
- webscout/Provider/OPENAI/chatsandbox.py +172 -0
- webscout/Provider/OPENAI/deepinfra.py +319 -0
- webscout/Provider/OPENAI/e2b.py +1356 -0
- webscout/Provider/OPENAI/exaai.py +411 -0
- webscout/Provider/OPENAI/exachat.py +443 -0
- webscout/Provider/OPENAI/flowith.py +162 -0
- webscout/Provider/OPENAI/freeaichat.py +359 -0
- webscout/Provider/OPENAI/glider.py +323 -0
- webscout/Provider/OPENAI/groq.py +361 -0
- webscout/Provider/OPENAI/heckai.py +307 -0
- webscout/Provider/OPENAI/llmchatco.py +335 -0
- webscout/Provider/OPENAI/mcpcore.py +383 -0
- webscout/Provider/OPENAI/multichat.py +376 -0
- webscout/Provider/OPENAI/netwrck.py +356 -0
- webscout/Provider/OPENAI/opkfc.py +496 -0
- webscout/Provider/OPENAI/scirachat.py +471 -0
- webscout/Provider/OPENAI/sonus.py +303 -0
- webscout/Provider/OPENAI/standardinput.py +433 -0
- webscout/Provider/OPENAI/textpollinations.py +339 -0
- webscout/Provider/OPENAI/toolbaz.py +413 -0
- webscout/Provider/OPENAI/typefully.py +355 -0
- webscout/Provider/OPENAI/typegpt.py +358 -0
- webscout/Provider/OPENAI/uncovrAI.py +462 -0
- webscout/Provider/OPENAI/utils.py +307 -0
- webscout/Provider/OPENAI/venice.py +425 -0
- webscout/Provider/OPENAI/wisecat.py +381 -0
- webscout/Provider/OPENAI/writecream.py +163 -0
- webscout/Provider/OPENAI/x0gpt.py +378 -0
- webscout/Provider/OPENAI/yep.py +356 -0
- webscout/Provider/OpenGPT.py +209 -0
- webscout/Provider/Openai.py +496 -0
- webscout/Provider/PI.py +429 -0
- webscout/Provider/Perplexitylabs.py +415 -0
- webscout/Provider/QwenLM.py +254 -0
- webscout/Provider/Reka.py +214 -0
- webscout/Provider/StandardInput.py +290 -0
- webscout/Provider/TTI/AiForce/README.md +159 -0
- webscout/Provider/TTI/AiForce/__init__.py +22 -0
- webscout/Provider/TTI/AiForce/async_aiforce.py +224 -0
- webscout/Provider/TTI/AiForce/sync_aiforce.py +245 -0
- webscout/Provider/TTI/FreeAIPlayground/README.md +99 -0
- webscout/Provider/TTI/FreeAIPlayground/__init__.py +9 -0
- webscout/Provider/TTI/FreeAIPlayground/async_freeaiplayground.py +181 -0
- webscout/Provider/TTI/FreeAIPlayground/sync_freeaiplayground.py +180 -0
- webscout/Provider/TTI/ImgSys/README.md +174 -0
- webscout/Provider/TTI/ImgSys/__init__.py +23 -0
- webscout/Provider/TTI/ImgSys/async_imgsys.py +202 -0
- webscout/Provider/TTI/ImgSys/sync_imgsys.py +195 -0
- webscout/Provider/TTI/MagicStudio/README.md +101 -0
- webscout/Provider/TTI/MagicStudio/__init__.py +2 -0
- webscout/Provider/TTI/MagicStudio/async_magicstudio.py +111 -0
- webscout/Provider/TTI/MagicStudio/sync_magicstudio.py +109 -0
- webscout/Provider/TTI/Nexra/README.md +155 -0
- webscout/Provider/TTI/Nexra/__init__.py +22 -0
- webscout/Provider/TTI/Nexra/async_nexra.py +286 -0
- webscout/Provider/TTI/Nexra/sync_nexra.py +258 -0
- webscout/Provider/TTI/PollinationsAI/README.md +146 -0
- webscout/Provider/TTI/PollinationsAI/__init__.py +23 -0
- webscout/Provider/TTI/PollinationsAI/async_pollinations.py +311 -0
- webscout/Provider/TTI/PollinationsAI/sync_pollinations.py +265 -0
- webscout/Provider/TTI/README.md +128 -0
- webscout/Provider/TTI/__init__.py +12 -0
- webscout/Provider/TTI/aiarta/README.md +134 -0
- webscout/Provider/TTI/aiarta/__init__.py +2 -0
- webscout/Provider/TTI/aiarta/async_aiarta.py +482 -0
- webscout/Provider/TTI/aiarta/sync_aiarta.py +440 -0
- webscout/Provider/TTI/artbit/README.md +100 -0
- webscout/Provider/TTI/artbit/__init__.py +22 -0
- webscout/Provider/TTI/artbit/async_artbit.py +155 -0
- webscout/Provider/TTI/artbit/sync_artbit.py +148 -0
- webscout/Provider/TTI/fastflux/README.md +129 -0
- webscout/Provider/TTI/fastflux/__init__.py +22 -0
- webscout/Provider/TTI/fastflux/async_fastflux.py +261 -0
- webscout/Provider/TTI/fastflux/sync_fastflux.py +252 -0
- webscout/Provider/TTI/huggingface/README.md +114 -0
- webscout/Provider/TTI/huggingface/__init__.py +22 -0
- webscout/Provider/TTI/huggingface/async_huggingface.py +199 -0
- webscout/Provider/TTI/huggingface/sync_huggingface.py +195 -0
- webscout/Provider/TTI/piclumen/README.md +161 -0
- webscout/Provider/TTI/piclumen/__init__.py +23 -0
- webscout/Provider/TTI/piclumen/async_piclumen.py +268 -0
- webscout/Provider/TTI/piclumen/sync_piclumen.py +233 -0
- webscout/Provider/TTI/pixelmuse/README.md +79 -0
- webscout/Provider/TTI/pixelmuse/__init__.py +4 -0
- webscout/Provider/TTI/pixelmuse/async_pixelmuse.py +249 -0
- webscout/Provider/TTI/pixelmuse/sync_pixelmuse.py +182 -0
- webscout/Provider/TTI/talkai/README.md +139 -0
- webscout/Provider/TTI/talkai/__init__.py +4 -0
- webscout/Provider/TTI/talkai/async_talkai.py +229 -0
- webscout/Provider/TTI/talkai/sync_talkai.py +207 -0
- webscout/Provider/TTS/README.md +192 -0
- webscout/Provider/TTS/__init__.py +9 -0
- webscout/Provider/TTS/base.py +159 -0
- webscout/Provider/TTS/deepgram.py +156 -0
- webscout/Provider/TTS/elevenlabs.py +111 -0
- webscout/Provider/TTS/gesserit.py +128 -0
- webscout/Provider/TTS/murfai.py +113 -0
- webscout/Provider/TTS/parler.py +111 -0
- webscout/Provider/TTS/speechma.py +580 -0
- webscout/Provider/TTS/sthir.py +94 -0
- webscout/Provider/TTS/streamElements.py +333 -0
- webscout/Provider/TTS/utils.py +280 -0
- webscout/Provider/TeachAnything.py +229 -0
- webscout/Provider/TextPollinationsAI.py +308 -0
- webscout/Provider/TwoAI.py +280 -0
- webscout/Provider/TypliAI.py +305 -0
- webscout/Provider/UNFINISHED/ChatHub.py +209 -0
- webscout/Provider/UNFINISHED/Youchat.py +330 -0
- webscout/Provider/UNFINISHED/liner_api_request.py +263 -0
- webscout/Provider/UNFINISHED/oivscode.py +351 -0
- webscout/Provider/UNFINISHED/test_lmarena.py +119 -0
- webscout/Provider/Venice.py +258 -0
- webscout/Provider/VercelAI.py +253 -0
- webscout/Provider/WiseCat.py +233 -0
- webscout/Provider/WrDoChat.py +370 -0
- webscout/Provider/Writecream.py +246 -0
- webscout/Provider/WritingMate.py +269 -0
- webscout/Provider/__init__.py +172 -0
- webscout/Provider/ai4chat.py +149 -0
- webscout/Provider/akashgpt.py +335 -0
- webscout/Provider/asksteve.py +220 -0
- webscout/Provider/cerebras.py +290 -0
- webscout/Provider/chatglm.py +215 -0
- webscout/Provider/cleeai.py +213 -0
- webscout/Provider/copilot.py +425 -0
- webscout/Provider/elmo.py +283 -0
- webscout/Provider/freeaichat.py +285 -0
- webscout/Provider/geminiapi.py +208 -0
- webscout/Provider/granite.py +235 -0
- webscout/Provider/hermes.py +266 -0
- webscout/Provider/julius.py +223 -0
- webscout/Provider/koala.py +170 -0
- webscout/Provider/learnfastai.py +325 -0
- webscout/Provider/llama3mitril.py +215 -0
- webscout/Provider/llmchat.py +258 -0
- webscout/Provider/llmchatco.py +306 -0
- webscout/Provider/lmarena.py +198 -0
- webscout/Provider/meta.py +801 -0
- webscout/Provider/multichat.py +364 -0
- webscout/Provider/samurai.py +223 -0
- webscout/Provider/scira_chat.py +299 -0
- webscout/Provider/scnet.py +243 -0
- webscout/Provider/searchchat.py +292 -0
- webscout/Provider/sonus.py +258 -0
- webscout/Provider/talkai.py +194 -0
- webscout/Provider/toolbaz.py +353 -0
- webscout/Provider/turboseek.py +266 -0
- webscout/Provider/typefully.py +202 -0
- webscout/Provider/typegpt.py +289 -0
- webscout/Provider/uncovr.py +368 -0
- webscout/Provider/x0gpt.py +299 -0
- webscout/Provider/yep.py +389 -0
- webscout/__init__.py +4 -2
- webscout/cli.py +3 -28
- webscout/conversation.py +35 -35
- webscout/litagent/Readme.md +276 -0
- webscout/litagent/__init__.py +29 -0
- webscout/litagent/agent.py +455 -0
- webscout/litagent/constants.py +60 -0
- webscout/litprinter/__init__.py +59 -0
- webscout/scout/README.md +402 -0
- webscout/scout/__init__.py +8 -0
- webscout/scout/core/__init__.py +7 -0
- webscout/scout/core/crawler.py +140 -0
- webscout/scout/core/scout.py +568 -0
- webscout/scout/core/search_result.py +96 -0
- webscout/scout/core/text_analyzer.py +63 -0
- webscout/scout/core/text_utils.py +277 -0
- webscout/scout/core/web_analyzer.py +52 -0
- webscout/scout/element.py +460 -0
- webscout/scout/parsers/__init__.py +69 -0
- webscout/scout/parsers/html5lib_parser.py +172 -0
- webscout/scout/parsers/html_parser.py +236 -0
- webscout/scout/parsers/lxml_parser.py +178 -0
- webscout/scout/utils.py +37 -0
- webscout/swiftcli/Readme.md +323 -0
- webscout/swiftcli/__init__.py +95 -0
- webscout/swiftcli/core/__init__.py +7 -0
- webscout/swiftcli/core/cli.py +297 -0
- webscout/swiftcli/core/context.py +104 -0
- webscout/swiftcli/core/group.py +241 -0
- webscout/swiftcli/decorators/__init__.py +28 -0
- webscout/swiftcli/decorators/command.py +221 -0
- webscout/swiftcli/decorators/options.py +220 -0
- webscout/swiftcli/decorators/output.py +252 -0
- webscout/swiftcli/exceptions.py +21 -0
- webscout/swiftcli/plugins/__init__.py +9 -0
- webscout/swiftcli/plugins/base.py +135 -0
- webscout/swiftcli/plugins/manager.py +262 -0
- webscout/swiftcli/utils/__init__.py +59 -0
- webscout/swiftcli/utils/formatting.py +252 -0
- webscout/swiftcli/utils/parsing.py +267 -0
- webscout/version.py +1 -1
- webscout/webscout_search.py +2 -182
- webscout/webscout_search_async.py +1 -179
- webscout/zeroart/README.md +89 -0
- webscout/zeroart/__init__.py +135 -0
- webscout/zeroart/base.py +66 -0
- webscout/zeroart/effects.py +101 -0
- webscout/zeroart/fonts.py +1239 -0
- {webscout-8.2.7.dist-info → webscout-8.2.8.dist-info}/METADATA +115 -60
- webscout-8.2.8.dist-info/RECORD +334 -0
- {webscout-8.2.7.dist-info → webscout-8.2.8.dist-info}/WHEEL +1 -1
- webscout-8.2.7.dist-info/RECORD +0 -26
- {webscout-8.2.7.dist-info → webscout-8.2.8.dist-info}/entry_points.txt +0 -0
- {webscout-8.2.7.dist-info → webscout-8.2.8.dist-info}/licenses/LICENSE.md +0 -0
- {webscout-8.2.7.dist-info → webscout-8.2.8.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,735 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import random
|
|
3
|
+
import string
|
|
4
|
+
import base64
|
|
5
|
+
from datetime import datetime, timedelta
|
|
6
|
+
from typing import List, Dict, Optional, Any
|
|
7
|
+
import json
|
|
8
|
+
import uuid
|
|
9
|
+
import time
|
|
10
|
+
|
|
11
|
+
# Import base classes and utility structures
|
|
12
|
+
from .base import OpenAICompatibleProvider, BaseChat, BaseCompletions
|
|
13
|
+
from .utils import (
|
|
14
|
+
ChatCompletion, Choice,
|
|
15
|
+
ChatCompletionMessage, CompletionUsage
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def to_data_uri(image_data):
|
|
20
|
+
"""Convert image data to a data URI format"""
|
|
21
|
+
if isinstance(image_data, str):
|
|
22
|
+
# Assume it's already a data URI
|
|
23
|
+
return image_data
|
|
24
|
+
|
|
25
|
+
# Encode binary data to base64
|
|
26
|
+
encoded = base64.b64encode(image_data).decode('utf-8')
|
|
27
|
+
|
|
28
|
+
# Determine MIME type (simplified)
|
|
29
|
+
mime_type = "image/jpeg" # Default
|
|
30
|
+
if image_data.startswith(b'\x89PNG'):
|
|
31
|
+
mime_type = "image/png"
|
|
32
|
+
elif image_data.startswith(b'\xff\xd8'):
|
|
33
|
+
mime_type = "image/jpeg"
|
|
34
|
+
elif image_data.startswith(b'GIF'):
|
|
35
|
+
mime_type = "image/gif"
|
|
36
|
+
|
|
37
|
+
return f"data:{mime_type};base64,{encoded}"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class Completions(BaseCompletions):
|
|
41
|
+
def __init__(self, client: 'BLACKBOXAI'):
|
|
42
|
+
self._client = client
|
|
43
|
+
|
|
44
|
+
def create(
|
|
45
|
+
self,
|
|
46
|
+
*,
|
|
47
|
+
model: str,
|
|
48
|
+
messages: List[Dict[str, Any]],
|
|
49
|
+
max_tokens: Optional[int] = None,
|
|
50
|
+
stream: bool = False,
|
|
51
|
+
temperature: Optional[float] = None,
|
|
52
|
+
top_p: Optional[float] = None,
|
|
53
|
+
**kwargs: Any
|
|
54
|
+
) -> ChatCompletion:
|
|
55
|
+
"""
|
|
56
|
+
Create a chat completion with BlackboxAI API.
|
|
57
|
+
|
|
58
|
+
Args:
|
|
59
|
+
model: The model to use (from AVAILABLE_MODELS)
|
|
60
|
+
messages: List of message dictionaries with 'role' and 'content'
|
|
61
|
+
max_tokens: Maximum number of tokens to generate
|
|
62
|
+
stream: If True, raises an error as streaming is not supported
|
|
63
|
+
temperature: Sampling temperature (0-1)
|
|
64
|
+
top_p: Nucleus sampling parameter (0-1)
|
|
65
|
+
**kwargs: Additional parameters to pass to the API
|
|
66
|
+
|
|
67
|
+
Returns:
|
|
68
|
+
Returns a ChatCompletion object
|
|
69
|
+
"""
|
|
70
|
+
# Check if streaming is requested and raise an error
|
|
71
|
+
if stream:
|
|
72
|
+
raise ValueError("Streaming is not supported by the BLACKBOXAI provider. Please use stream=False.")
|
|
73
|
+
|
|
74
|
+
# Generate request ID and timestamp
|
|
75
|
+
request_id = str(uuid.uuid4())
|
|
76
|
+
created_time = int(time.time())
|
|
77
|
+
|
|
78
|
+
# Extract system message if present
|
|
79
|
+
system_message = "You are a helpful AI assistant."
|
|
80
|
+
for msg in messages:
|
|
81
|
+
if msg.get("role") == "system":
|
|
82
|
+
system_message = msg.get("content")
|
|
83
|
+
break
|
|
84
|
+
|
|
85
|
+
# Look for any image content
|
|
86
|
+
media = []
|
|
87
|
+
for msg in messages:
|
|
88
|
+
if msg.get("role") == "user":
|
|
89
|
+
# Check for image attachments in content
|
|
90
|
+
content = msg.get("content", [])
|
|
91
|
+
if isinstance(content, list):
|
|
92
|
+
for item in content:
|
|
93
|
+
if isinstance(item, dict) and item.get("type") == "image_url":
|
|
94
|
+
image_url = item.get("image_url", {})
|
|
95
|
+
if isinstance(image_url, dict) and "url" in image_url:
|
|
96
|
+
url = image_url["url"]
|
|
97
|
+
if url.startswith("data:"):
|
|
98
|
+
# It's already a data URI
|
|
99
|
+
image_name = f"image_{len(media)}.png"
|
|
100
|
+
media.append((url, image_name))
|
|
101
|
+
else:
|
|
102
|
+
# Need to fetch and convert to data URI
|
|
103
|
+
try:
|
|
104
|
+
image_response = requests.get(url)
|
|
105
|
+
if image_response.ok:
|
|
106
|
+
image_name = f"image_{len(media)}.png"
|
|
107
|
+
media.append((image_response.content, image_name))
|
|
108
|
+
except Exception as e:
|
|
109
|
+
pass
|
|
110
|
+
|
|
111
|
+
# Use non-streaming implementation
|
|
112
|
+
return self._create_non_streaming(
|
|
113
|
+
request_id=request_id,
|
|
114
|
+
created_time=created_time,
|
|
115
|
+
model=model,
|
|
116
|
+
messages=messages,
|
|
117
|
+
system_message=system_message,
|
|
118
|
+
max_tokens=max_tokens,
|
|
119
|
+
temperature=temperature,
|
|
120
|
+
top_p=top_p,
|
|
121
|
+
media=media
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def _create_non_streaming(
|
|
127
|
+
self,
|
|
128
|
+
*,
|
|
129
|
+
request_id: str,
|
|
130
|
+
created_time: int,
|
|
131
|
+
model: str,
|
|
132
|
+
messages: List[Dict[str, Any]],
|
|
133
|
+
system_message: str,
|
|
134
|
+
max_tokens: Optional[int] = None,
|
|
135
|
+
temperature: Optional[float] = None,
|
|
136
|
+
top_p: Optional[float] = None,
|
|
137
|
+
media: List = None
|
|
138
|
+
) -> ChatCompletion:
|
|
139
|
+
"""Implementation for non-streaming chat completions."""
|
|
140
|
+
try:
|
|
141
|
+
# Prepare user messages for BlackboxAI API format
|
|
142
|
+
blackbox_messages = []
|
|
143
|
+
for i, msg in enumerate(messages):
|
|
144
|
+
if msg["role"] == "system":
|
|
145
|
+
continue # System message handled separately
|
|
146
|
+
|
|
147
|
+
msg_id = self._client.generate_id() if i > 0 else request_id
|
|
148
|
+
blackbox_messages.append({
|
|
149
|
+
"id": msg_id,
|
|
150
|
+
"content": msg["content"],
|
|
151
|
+
"role": msg["role"]
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
# Add image data if provided
|
|
155
|
+
if media and blackbox_messages:
|
|
156
|
+
blackbox_messages[-1]['data'] = {
|
|
157
|
+
"imagesData": [
|
|
158
|
+
{
|
|
159
|
+
"filePath": f"/",
|
|
160
|
+
"contents": to_data_uri(image)
|
|
161
|
+
} for image in media
|
|
162
|
+
],
|
|
163
|
+
"fileText": "",
|
|
164
|
+
"title": ""
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
# Generate request payload with session
|
|
168
|
+
request_email = f"{self._client.generate_random_string(8)}@blackbox.ai"
|
|
169
|
+
session_data = self._client.generate_session(request_email)
|
|
170
|
+
|
|
171
|
+
# Create the API request payload
|
|
172
|
+
payload = self._client.create_request_payload(
|
|
173
|
+
messages=blackbox_messages,
|
|
174
|
+
chat_id=request_id,
|
|
175
|
+
system_message=system_message,
|
|
176
|
+
max_tokens=max_tokens,
|
|
177
|
+
temperature=temperature,
|
|
178
|
+
top_p=top_p,
|
|
179
|
+
session_data=session_data,
|
|
180
|
+
model=model
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
# Make the API request with cookies
|
|
184
|
+
response = self._client.session.post(
|
|
185
|
+
self._client.api_endpoint,
|
|
186
|
+
json=payload,
|
|
187
|
+
headers=self._client.headers,
|
|
188
|
+
cookies=self._client.cookies,
|
|
189
|
+
timeout=self._client.timeout
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
# Process the response
|
|
193
|
+
full_content = ""
|
|
194
|
+
if response.status_code == 200:
|
|
195
|
+
# Extract content from response text
|
|
196
|
+
response_text = response.text
|
|
197
|
+
|
|
198
|
+
# Handle possible SSE format in response
|
|
199
|
+
if "data: " in response_text:
|
|
200
|
+
# Extract content from SSE format
|
|
201
|
+
content_lines = []
|
|
202
|
+
for line in response_text.split('\n'):
|
|
203
|
+
if line.startswith("data: "):
|
|
204
|
+
line = line[6:].strip()
|
|
205
|
+
if line and not any(error_msg in line.lower() for error_msg in [
|
|
206
|
+
"service has been suspended",
|
|
207
|
+
"api request failed",
|
|
208
|
+
"you have reached your request limit"
|
|
209
|
+
]):
|
|
210
|
+
content_lines.append(line)
|
|
211
|
+
full_content = "".join(content_lines)
|
|
212
|
+
else:
|
|
213
|
+
# Regular response
|
|
214
|
+
full_content = response_text
|
|
215
|
+
else:
|
|
216
|
+
# Handle error response
|
|
217
|
+
raise IOError(f"BlackboxAI request failed with status code {response.status_code}")
|
|
218
|
+
|
|
219
|
+
# Create the completion message
|
|
220
|
+
message = ChatCompletionMessage(
|
|
221
|
+
role="assistant",
|
|
222
|
+
content=full_content
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
# Create the choice with the message
|
|
226
|
+
choice = Choice(
|
|
227
|
+
index=0,
|
|
228
|
+
message=message,
|
|
229
|
+
finish_reason="stop"
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
# Estimate token usage
|
|
233
|
+
prompt_tokens = sum(len(str(msg.get("content", ""))) // 4 for msg in messages)
|
|
234
|
+
completion_tokens = len(full_content) // 4
|
|
235
|
+
|
|
236
|
+
# Create the final completion object
|
|
237
|
+
completion = ChatCompletion(
|
|
238
|
+
id=request_id,
|
|
239
|
+
choices=[choice],
|
|
240
|
+
created=created_time,
|
|
241
|
+
model=model,
|
|
242
|
+
usage=CompletionUsage(
|
|
243
|
+
prompt_tokens=prompt_tokens,
|
|
244
|
+
completion_tokens=completion_tokens,
|
|
245
|
+
total_tokens=prompt_tokens + completion_tokens
|
|
246
|
+
)
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
return completion
|
|
250
|
+
|
|
251
|
+
except Exception as e:
|
|
252
|
+
raise IOError(f"BlackboxAI request failed: {str(e)}") from e
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
class Chat(BaseChat):
|
|
256
|
+
def __init__(self, client: 'BLACKBOXAI'):
|
|
257
|
+
self.completions = Completions(client)
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
class BLACKBOXAI(OpenAICompatibleProvider):
|
|
261
|
+
"""
|
|
262
|
+
OpenAI-compatible client for BlackboxAI API.
|
|
263
|
+
|
|
264
|
+
Usage:
|
|
265
|
+
client = BLACKBOXAI()
|
|
266
|
+
response = client.chat.completions.create(
|
|
267
|
+
model="GPT-4.1",
|
|
268
|
+
messages=[{"role": "user", "content": "Hello!"}]
|
|
269
|
+
)
|
|
270
|
+
print(response.choices[0].message.content)
|
|
271
|
+
"""
|
|
272
|
+
# Default model
|
|
273
|
+
default_model = "GPT-4.1"
|
|
274
|
+
default_vision_model = default_model
|
|
275
|
+
api_endpoint = "https://www.blackbox.ai/api/chat"
|
|
276
|
+
timeout = 30
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
# Default model (remains the same as per original class)
|
|
280
|
+
default_model = "GPT-4.1"
|
|
281
|
+
default_vision_model = default_model
|
|
282
|
+
|
|
283
|
+
# New OpenRouter models list
|
|
284
|
+
openrouter_models = [
|
|
285
|
+
"Deepcoder 14B Preview",
|
|
286
|
+
"DeepHermes 3 Llama 3 8B Preview",
|
|
287
|
+
"DeepSeek R1 Zero",
|
|
288
|
+
"Dolphin3.0 Mistral 24B",
|
|
289
|
+
"Dolphin3.0 R1 Mistral 24B",
|
|
290
|
+
"Flash 3",
|
|
291
|
+
"Gemini 2.0 Flash Experimental",
|
|
292
|
+
"Gemma 2 9B",
|
|
293
|
+
"Gemma 3 12B",
|
|
294
|
+
"Gemma 3 1B",
|
|
295
|
+
"Gemma 3 27B",
|
|
296
|
+
"Gemma 3 4B",
|
|
297
|
+
"Kimi VL A3B Thinking",
|
|
298
|
+
"Llama 3.1 8B Instruct",
|
|
299
|
+
"Llama 3.1 Nemotron Ultra 253B v1",
|
|
300
|
+
"Llama 3.2 11B Vision Instruct",
|
|
301
|
+
"Llama 3.2 1B Instruct",
|
|
302
|
+
"Llama 3.2 3B Instruct",
|
|
303
|
+
"Llama 3.3 70B Instruct",
|
|
304
|
+
"Llama 3.3 Nemotron Super 49B v1",
|
|
305
|
+
"Llama 4 Maverick",
|
|
306
|
+
"Llama 4 Scout",
|
|
307
|
+
"Mistral 7B Instruct",
|
|
308
|
+
"Mistral Nemo",
|
|
309
|
+
"Mistral Small 3",
|
|
310
|
+
"Mistral Small 3.1 24B",
|
|
311
|
+
"Molmo 7B D",
|
|
312
|
+
"Moonlight 16B A3B Instruct",
|
|
313
|
+
"Qwen2.5 72B Instruct",
|
|
314
|
+
"Qwen2.5 7B Instruct",
|
|
315
|
+
"Qwen2.5 Coder 32B Instruct",
|
|
316
|
+
"Qwen2.5 VL 32B Instruct",
|
|
317
|
+
"Qwen2.5 VL 3B Instruct",
|
|
318
|
+
"Qwen2.5 VL 72B Instruct",
|
|
319
|
+
"Qwen2.5-VL 7B Instruct",
|
|
320
|
+
"Qwerky 72B",
|
|
321
|
+
"QwQ 32B",
|
|
322
|
+
"QwQ 32B Preview",
|
|
323
|
+
"QwQ 32B RpR v1",
|
|
324
|
+
"R1",
|
|
325
|
+
"R1 Distill Llama 70B",
|
|
326
|
+
"R1 Distill Qwen 14B",
|
|
327
|
+
"R1 Distill Qwen 32B",
|
|
328
|
+
]
|
|
329
|
+
|
|
330
|
+
# New base models list
|
|
331
|
+
models = [
|
|
332
|
+
default_model,
|
|
333
|
+
"o3-mini",
|
|
334
|
+
"gpt-4.1-nano",
|
|
335
|
+
"Claude-sonnet-3.7",
|
|
336
|
+
"Claude-sonnet-3.5",
|
|
337
|
+
"DeepSeek-R1",
|
|
338
|
+
"Mistral-Small-24B-Instruct-2501",
|
|
339
|
+
*openrouter_models,
|
|
340
|
+
# Trending agent modes (names)
|
|
341
|
+
'Python Agent', 'HTML Agent', 'Builder Agent', 'Java Agent', 'JavaScript Agent',
|
|
342
|
+
'React Agent', 'Android Agent', 'Flutter Agent', 'Next.js Agent', 'AngularJS Agent',
|
|
343
|
+
'Swift Agent', 'MongoDB Agent', 'PyTorch Agent', 'Xcode Agent', 'Azure Agent',
|
|
344
|
+
'Bitbucket Agent', 'DigitalOcean Agent', 'Docker Agent', 'Electron Agent',
|
|
345
|
+
'Erlang Agent', 'FastAPI Agent', 'Firebase Agent', 'Flask Agent', 'Git Agent',
|
|
346
|
+
'Gitlab Agent', 'Go Agent', 'Godot Agent', 'Google Cloud Agent', 'Heroku Agent'
|
|
347
|
+
]
|
|
348
|
+
|
|
349
|
+
# Models that support vision capabilities
|
|
350
|
+
vision_models = [default_vision_model, 'o3-mini', "Llama 3.2 11B Vision Instruct"] # Added Llama vision
|
|
351
|
+
|
|
352
|
+
# Models that can be directly selected by users
|
|
353
|
+
userSelectedModel = ['o3-mini','Claude-sonnet-3.7', 'Claude-sonnet-3.5', 'DeepSeek-R1', 'Mistral-Small-24B-Instruct-2501'] + openrouter_models
|
|
354
|
+
|
|
355
|
+
# Agent mode configurations
|
|
356
|
+
agentMode = {
|
|
357
|
+
# OpenRouter Free
|
|
358
|
+
'Deepcoder 14B Preview': {'mode': True, 'id': "agentica-org/deepcoder-14b-preview:free", 'name': "Deepcoder 14B Preview"},
|
|
359
|
+
'DeepHermes 3 Llama 3 8B Preview': {'mode': True, 'id': "nousresearch/deephermes-3-llama-3-8b-preview:free", 'name': "DeepHermes 3 Llama 3 8B Preview"},
|
|
360
|
+
'DeepSeek R1 Zero': {'mode': True, 'id': "deepseek/deepseek-r1-zero:free", 'name': "DeepSeek R1 Zero"},
|
|
361
|
+
'Dolphin3.0 Mistral 24B': {'mode': True, 'id': "cognitivecomputations/dolphin3.0-mistral-24b:free", 'name': "Dolphin3.0 Mistral 24B"},
|
|
362
|
+
'Dolphin3.0 R1 Mistral 24B': {'mode': True, 'id': "cognitivecomputations/dolphin3.0-r1-mistral-24b:free", 'name': "Dolphin3.0 R1 Mistral 24B"},
|
|
363
|
+
'Flash 3': {'mode': True, 'id': "rekaai/reka-flash-3:free", 'name': "Flash 3"},
|
|
364
|
+
'Gemini 2.0 Flash Experimental': {'mode': True, 'id': "google/gemini-2.0-flash-exp:free", 'name': "Gemini 2.0 Flash Experimental"},
|
|
365
|
+
'Gemma 2 9B': {'mode': True, 'id': "google/gemma-2-9b-it:free", 'name': "Gemma 2 9B"},
|
|
366
|
+
'Gemma 3 12B': {'mode': True, 'id': "google/gemma-3-12b-it:free", 'name': "Gemma 3 12B"},
|
|
367
|
+
'Gemma 3 1B': {'mode': True, 'id': "google/gemma-3-1b-it:free", 'name': "Gemma 3 1B"},
|
|
368
|
+
'Gemma 3 27B': {'mode': True, 'id': "google/gemma-3-27b-it:free", 'name': "Gemma 3 27B"},
|
|
369
|
+
'Gemma 3 4B': {'mode': True, 'id': "google/gemma-3-4b-it:free", 'name': "Gemma 3 4B"},
|
|
370
|
+
'Kimi VL A3B Thinking': {'mode': True, 'id': "moonshotai/kimi-vl-a3b-thinking:free", 'name': "Kimi VL A3B Thinking"},
|
|
371
|
+
'Llama 3.1 8B Instruct': {'mode': True, 'id': "meta-llama/llama-3.1-8b-instruct:free", 'name': "Llama 3.1 8B Instruct"},
|
|
372
|
+
'Llama 3.1 Nemotron Ultra 253B v1': {'mode': True, 'id': "nvidia/llama-3.1-nemotron-ultra-253b-v1:free", 'name': "Llama 3.1 Nemotron Ultra 253B v1"},
|
|
373
|
+
'Llama 3.2 11B Vision Instruct': {'mode': True, 'id': "meta-llama/llama-3.2-11b-vision-instruct:free", 'name': "Llama 3.2 11B Vision Instruct"},
|
|
374
|
+
'Llama 3.2 1B Instruct': {'mode': True, 'id': "meta-llama/llama-3.2-1b-instruct:free", 'name': "Llama 3.2 1B Instruct"},
|
|
375
|
+
'Llama 3.2 3B Instruct': {'mode': True, 'id': "meta-llama/llama-3.2-3b-instruct:free", 'name': "Llama 3.2 3B Instruct"},
|
|
376
|
+
'Llama 3.3 70B Instruct': {'mode': True, 'id': "meta-llama/llama-3.3-70b-instruct:free", 'name': "Llama 3.3 70B Instruct"},
|
|
377
|
+
'Llama 3.3 Nemotron Super 49B v1': {'mode': True, 'id': "nvidia/llama-3.3-nemotron-super-49b-v1:free", 'name': "Llama 3.3 Nemotron Super 49B v1"},
|
|
378
|
+
'Llama 4 Maverick': {'mode': True, 'id': "meta-llama/llama-4-maverick:free", 'name': "Llama 4 Maverick"},
|
|
379
|
+
'Llama 4 Scout': {'mode': True, 'id': "meta-llama/llama-4-scout:free", 'name': "Llama 4 Scout"},
|
|
380
|
+
'Mistral 7B Instruct': {'mode': True, 'id': "mistralai/mistral-7b-instruct:free", 'name': "Mistral 7B Instruct"},
|
|
381
|
+
'Mistral Nemo': {'mode': True, 'id': "mistralai/mistral-nemo:free", 'name': "Mistral Nemo"},
|
|
382
|
+
'Mistral Small 3': {'mode': True, 'id': "mistralai/mistral-small-24b-instruct-2501:free", 'name': "Mistral Small 3"}, # Matches Mistral-Small-24B-Instruct-2501
|
|
383
|
+
'Mistral Small 3.1 24B': {'mode': True, 'id': "mistralai/mistral-small-3.1-24b-instruct:free", 'name': "Mistral Small 3.1 24B"},
|
|
384
|
+
'Molmo 7B D': {'mode': True, 'id': "allenai/molmo-7b-d:free", 'name': "Molmo 7B D"},
|
|
385
|
+
'Moonlight 16B A3B Instruct': {'mode': True, 'id': "moonshotai/moonlight-16b-a3b-instruct:free", 'name': "Moonlight 16B A3B Instruct"},
|
|
386
|
+
'Qwen2.5 72B Instruct': {'mode': True, 'id': "qwen/qwen-2.5-72b-instruct:free", 'name': "Qwen2.5 72B Instruct"},
|
|
387
|
+
'Qwen2.5 7B Instruct': {'mode': True, 'id': "qwen/qwen-2.5-7b-instruct:free", 'name': "Qwen2.5 7B Instruct"},
|
|
388
|
+
'Qwen2.5 Coder 32B Instruct': {'mode': True, 'id': "qwen/qwen-2.5-coder-32b-instruct:free", 'name': "Qwen2.5 Coder 32B Instruct"},
|
|
389
|
+
'Qwen2.5 VL 32B Instruct': {'mode': True, 'id': "qwen/qwen2.5-vl-32b-instruct:free", 'name': "Qwen2.5 VL 32B Instruct"},
|
|
390
|
+
'Qwen2.5 VL 3B Instruct': {'mode': True, 'id': "qwen/qwen2.5-vl-3b-instruct:free", 'name': "Qwen2.5 VL 3B Instruct"},
|
|
391
|
+
'Qwen2.5 VL 72B Instruct': {'mode': True, 'id': "qwen/qwen2.5-vl-72b-instruct:free", 'name': "Qwen2.5 VL 72B Instruct"},
|
|
392
|
+
'Qwen2.5-VL 7B Instruct': {'mode': True, 'id': "qwen/qwen-2.5-vl-7b-instruct:free", 'name': "Qwen2.5-VL 7B Instruct"},
|
|
393
|
+
'Qwerky 72B': {'mode': True, 'id': "featherless/qwerky-72b:free", 'name': "Qwerky 72B"},
|
|
394
|
+
'QwQ 32B': {'mode': True, 'id': "qwen/qwq-32b:free", 'name': "QwQ 32B"},
|
|
395
|
+
'QwQ 32B Preview': {'mode': True, 'id': "qwen/qwq-32b-preview:free", 'name': "QwQ 32B Preview"},
|
|
396
|
+
'QwQ 32B RpR v1': {'mode': True, 'id': "arliai/qwq-32b-arliai-rpr-v1:free", 'name': "QwQ 32B RpR v1"},
|
|
397
|
+
'R1': {'mode': True, 'id': "deepseek/deepseek-r1:free", 'name': "R1"}, # Matches DeepSeek-R1
|
|
398
|
+
'R1 Distill Llama 70B': {'mode': True, 'id': "deepseek/deepseek-r1-distill-llama-70b:free", 'name': "R1 Distill Llama 70B"},
|
|
399
|
+
'R1 Distill Qwen 14B': {'mode': True, 'id': "deepseek/deepseek-r1-distill-qwen-14b:free", 'name': "R1 Distill Qwen 14B"},
|
|
400
|
+
'R1 Distill Qwen 32B': {'mode': True, 'id': "deepseek/deepseek-r1-distill-qwen-32b:free", 'name': "R1 Distill Qwen 32B"},
|
|
401
|
+
# Default models from the new list
|
|
402
|
+
'Claude-sonnet-3.7': {'mode': True, 'id': "Claude-sonnet-3.7", 'name': "Claude-sonnet-3.7"},
|
|
403
|
+
'Claude-sonnet-3.5': {'mode': True, 'id': "Claude-sonnet-3.5", 'name': "Claude-sonnet-3.5"},
|
|
404
|
+
'DeepSeek-R1': {'mode': True, 'id': "deepseek-reasoner", 'name': "DeepSeek-R1"}, # This is 'R1' in openrouter, but 'DeepSeek-R1' in base models
|
|
405
|
+
'Mistral-Small-24B-Instruct-2501': {'mode': True, 'id': "mistralai/Mistral-Small-24B-Instruct-2501", 'name': "Mistral-Small-24B-Instruct-2501"},
|
|
406
|
+
# Add default_model if it's not covered and has an agent mode
|
|
407
|
+
default_model: {'mode': True, 'id': "openai/gpt-4.1", 'name': default_model}, # Assuming GPT-4.1 is agent-compatible
|
|
408
|
+
'o3-mini': {'mode': True, 'id': "o3-mini", 'name': "o3-mini"}, # Assuming o3-mini is agent-compatible
|
|
409
|
+
'gpt-4.1-nano': {'mode': True, 'id': "gpt-4.1-nano", 'name': "gpt-4.1-nano"}, # Assuming gpt-4.1-nano is agent-compatible
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
# Trending agent modes
|
|
413
|
+
trendingAgentMode = {
|
|
414
|
+
'Python Agent': {'mode': True, 'id': "python"},
|
|
415
|
+
'HTML Agent': {'mode': True, 'id': "html"},
|
|
416
|
+
'Builder Agent': {'mode': True, 'id': "builder"},
|
|
417
|
+
'Java Agent': {'mode': True, 'id': "java"},
|
|
418
|
+
'JavaScript Agent': {'mode': True, 'id': "javascript"},
|
|
419
|
+
'React Agent': {'mode': True, 'id': "react"},
|
|
420
|
+
'Android Agent': {'mode': True, 'id': "android"},
|
|
421
|
+
'Flutter Agent': {'mode': True, 'id': "flutter"},
|
|
422
|
+
'Next.js Agent': {'mode': True, 'id': "next.js"},
|
|
423
|
+
'AngularJS Agent': {'mode': True, 'id': "angularjs"},
|
|
424
|
+
'Swift Agent': {'mode': True, 'id': "swift"},
|
|
425
|
+
'MongoDB Agent': {'mode': True, 'id': "mongodb"},
|
|
426
|
+
'PyTorch Agent': {'mode': True, 'id': "pytorch"},
|
|
427
|
+
'Xcode Agent': {'mode': True, 'id': "xcode"},
|
|
428
|
+
'Azure Agent': {'mode': True, 'id': "azure"},
|
|
429
|
+
'Bitbucket Agent': {'mode': True, 'id': "bitbucket"},
|
|
430
|
+
'DigitalOcean Agent': {'mode': True, 'id': "digitalocean"},
|
|
431
|
+
'Docker Agent': {'mode': True, 'id': "docker"},
|
|
432
|
+
'Electron Agent': {'mode': True, 'id': "electron"},
|
|
433
|
+
'Erlang Agent': {'mode': True, 'id': "erlang"},
|
|
434
|
+
'FastAPI Agent': {'mode': True, 'id': "fastapi"},
|
|
435
|
+
'Firebase Agent': {'mode': True, 'id': "firebase"},
|
|
436
|
+
'Flask Agent': {'mode': True, 'id': "flask"},
|
|
437
|
+
'Git Agent': {'mode': True, 'id': "git"},
|
|
438
|
+
'Gitlab Agent': {'mode': True, 'id': "gitlab"},
|
|
439
|
+
'Go Agent': {'mode': True, 'id': "go"},
|
|
440
|
+
'Godot Agent': {'mode': True, 'id': "godot"},
|
|
441
|
+
'Google Cloud Agent': {'mode': True, 'id': "googlecloud"},
|
|
442
|
+
'Heroku Agent': {'mode': True, 'id': "heroku"},
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
# Create a list of all model aliases
|
|
446
|
+
_all_model_aliases = list(dict.fromkeys([
|
|
447
|
+
# Add all model aliases
|
|
448
|
+
"gpt-4", "gpt-4.1", "gpt-4o", "gpt-4o-mini",
|
|
449
|
+
"claude-3.7-sonnet", "claude-3.5-sonnet",
|
|
450
|
+
"deepcoder-14b", "deephermes-3-8b", "deepseek-r1-zero", "deepseek-r1",
|
|
451
|
+
"dolphin-3.0-24b", "dolphin-3.0-r1-24b", "reka-flash", "gemini-2.0-flash",
|
|
452
|
+
"gemma-2-9b", "gemma-3-12b", "gemma-3-1b", "gemma-3-27b", "gemma-3-4b",
|
|
453
|
+
"kimi-vl-a3b-thinking", "llama-3.1-8b", "nemotron-253b", "llama-3.2-11b",
|
|
454
|
+
"llama-3.2-1b", "llama-3.2-3b", "llama-3.3-70b", "nemotron-49b",
|
|
455
|
+
"llama-4-maverick", "llama-4-scout", "mistral-7b", "mistral-nemo",
|
|
456
|
+
"mistral-small-24b", "mistral-small-24b-instruct-2501", "mistral-small-3.1-24b",
|
|
457
|
+
"molmo-7b", "moonlight-16b", "qwen-2.5-72b", "qwen-2.5-7b", "qwen-2.5-coder-32b",
|
|
458
|
+
"qwen-2.5-vl-32b", "qwen-2.5-vl-3b", "qwen-2.5-vl-72b", "qwen-2.5-vl-7b",
|
|
459
|
+
"qwerky-72b", "qwq-32b", "qwq-32b-preview", "qwq-32b-arliai",
|
|
460
|
+
"deepseek-r1-distill-llama-70b", "deepseek-r1-distill-qwen-14b", "deepseek-r1-distill-qwen-32b",
|
|
461
|
+
# Add base models
|
|
462
|
+
"o3-mini", "gpt-4.1-nano"
|
|
463
|
+
]))
|
|
464
|
+
|
|
465
|
+
# Create AVAILABLE_MODELS as a list with the format "BLACKBOXAI/model"
|
|
466
|
+
AVAILABLE_MODELS = [f"BLACKBOXAI/{name}" for name in _all_model_aliases]
|
|
467
|
+
|
|
468
|
+
# Create a mapping dictionary for internal use
|
|
469
|
+
_model_mapping = {name: f"BLACKBOXAI/{name}" for name in _all_model_aliases}
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
# Model aliases for easier reference
|
|
473
|
+
model_aliases = {
|
|
474
|
+
"gpt-4": default_model, # default_model is "GPT-4.1"
|
|
475
|
+
"gpt-4.1": default_model,
|
|
476
|
+
"gpt-4o": default_model, # Defaulting to GPT-4.1 as per previous logic if specific GPT-4o handling isn't defined elsewhere
|
|
477
|
+
"gpt-4o-mini": default_model, # Defaulting
|
|
478
|
+
"claude-3.7-sonnet": "Claude-sonnet-3.7",
|
|
479
|
+
"claude-3.5-sonnet": "Claude-sonnet-3.5",
|
|
480
|
+
# "deepseek-r1": "DeepSeek-R1", # This is in base models, maps to R1 or DeepSeek R1 Zero in agentMode
|
|
481
|
+
#
|
|
482
|
+
"deepcoder-14b": "Deepcoder 14B Preview",
|
|
483
|
+
"deephermes-3-8b": "DeepHermes 3 Llama 3 8B Preview",
|
|
484
|
+
"deepseek-r1-zero": "DeepSeek R1 Zero",
|
|
485
|
+
"deepseek-r1": "R1", # Alias for R1 (which is deepseek/deepseek-r1:free)
|
|
486
|
+
"dolphin-3.0-24b": "Dolphin3.0 Mistral 24B",
|
|
487
|
+
"dolphin-3.0-r1-24b": "Dolphin3.0 R1 Mistral 24B",
|
|
488
|
+
"reka-flash": "Flash 3",
|
|
489
|
+
"gemini-2.0-flash": "Gemini 2.0 Flash Experimental",
|
|
490
|
+
"gemma-2-9b": "Gemma 2 9B",
|
|
491
|
+
"gemma-3-12b": "Gemma 3 12B",
|
|
492
|
+
"gemma-3-1b": "Gemma 3 1B",
|
|
493
|
+
"gemma-3-27b": "Gemma 3 27B",
|
|
494
|
+
"gemma-3-4b": "Gemma 3 4B",
|
|
495
|
+
"kimi-vl-a3b-thinking": "Kimi VL A3B Thinking",
|
|
496
|
+
"llama-3.1-8b": "Llama 3.1 8B Instruct",
|
|
497
|
+
"nemotron-253b": "Llama 3.1 Nemotron Ultra 253B v1",
|
|
498
|
+
"llama-3.2-11b": "Llama 3.2 11B Vision Instruct",
|
|
499
|
+
"llama-3.2-1b": "Llama 3.2 1B Instruct",
|
|
500
|
+
"llama-3.2-3b": "Llama 3.2 3B Instruct",
|
|
501
|
+
"llama-3.3-70b": "Llama 3.3 70B Instruct",
|
|
502
|
+
"nemotron-49b": "Llama 3.3 Nemotron Super 49B v1",
|
|
503
|
+
"llama-4-maverick": "Llama 4 Maverick",
|
|
504
|
+
"llama-4-scout": "Llama 4 Scout",
|
|
505
|
+
"mistral-7b": "Mistral 7B Instruct",
|
|
506
|
+
"mistral-nemo": "Mistral Nemo",
|
|
507
|
+
"mistral-small-24b": "Mistral Small 3", # Alias for "Mistral Small 3"
|
|
508
|
+
"mistral-small-24b-instruct-2501": "Mistral-Small-24B-Instruct-2501", # Specific name
|
|
509
|
+
"mistral-small-3.1-24b": "Mistral Small 3.1 24B",
|
|
510
|
+
"molmo-7b": "Molmo 7B D",
|
|
511
|
+
"moonlight-16b": "Moonlight 16B A3B Instruct",
|
|
512
|
+
"qwen-2.5-72b": "Qwen2.5 72B Instruct",
|
|
513
|
+
"qwen-2.5-7b": "Qwen2.5 7B Instruct",
|
|
514
|
+
"qwen-2.5-coder-32b": "Qwen2.5 Coder 32B Instruct",
|
|
515
|
+
"qwen-2.5-vl-32b": "Qwen2.5 VL 32B Instruct",
|
|
516
|
+
"qwen-2.5-vl-3b": "Qwen2.5 VL 3B Instruct",
|
|
517
|
+
"qwen-2.5-vl-72b": "Qwen2.5 VL 72B Instruct",
|
|
518
|
+
"qwen-2.5-vl-7b": "Qwen2.5-VL 7B Instruct",
|
|
519
|
+
"qwerky-72b": "Qwerky 72B",
|
|
520
|
+
"qwq-32b": "QwQ 32B",
|
|
521
|
+
"qwq-32b-preview": "QwQ 32B Preview",
|
|
522
|
+
"qwq-32b-arliai": "QwQ 32B RpR v1",
|
|
523
|
+
"deepseek-r1-distill-llama-70b": "R1 Distill Llama 70B",
|
|
524
|
+
"deepseek-r1-distill-qwen-14b": "R1 Distill Qwen 14B",
|
|
525
|
+
"deepseek-r1-distill-qwen-32b": "R1 Distill Qwen 32B",
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
def __init__(
|
|
529
|
+
self,
|
|
530
|
+
proxies: dict = {}
|
|
531
|
+
):
|
|
532
|
+
"""
|
|
533
|
+
Initialize the BlackboxAI provider with OpenAI compatibility.
|
|
534
|
+
|
|
535
|
+
Args:
|
|
536
|
+
proxies: Optional proxy configuration
|
|
537
|
+
"""
|
|
538
|
+
# Initialize session
|
|
539
|
+
self.session = requests.Session()
|
|
540
|
+
|
|
541
|
+
# Set headers based on GitHub reference
|
|
542
|
+
self.headers = {
|
|
543
|
+
'Accept': 'text/event-stream',
|
|
544
|
+
'Accept-Encoding': 'gzip, deflate, br, zstd',
|
|
545
|
+
'Accept-Language': 'en-US,en;q=0.9,en-IN;q=0.8',
|
|
546
|
+
'Content-Type': 'application/json',
|
|
547
|
+
'DNT': '1',
|
|
548
|
+
'Origin': 'https://www.blackbox.ai',
|
|
549
|
+
'Referer': 'https://www.blackbox.ai/',
|
|
550
|
+
'Sec-CH-UA': '"Not)A;Brand";v="99", "Microsoft Edge";v="127", "Chromium";v="127"',
|
|
551
|
+
'Sec-CH-UA-Mobile': '?0',
|
|
552
|
+
'Sec-CH-UA-Platform': '"Windows"',
|
|
553
|
+
'Sec-Fetch-Dest': 'empty',
|
|
554
|
+
'Sec-Fetch-Mode': 'cors',
|
|
555
|
+
'Sec-Fetch-Site': 'same-origin',
|
|
556
|
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36'
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
# Set cookies for the session
|
|
560
|
+
self.cookies = {
|
|
561
|
+
'cfzs_amplitude': self.generate_id(32),
|
|
562
|
+
'cfz_amplitude': self.generate_id(32),
|
|
563
|
+
'__cf_bm': self.generate_id(32),
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
# Set proxies if provided
|
|
567
|
+
self.session.proxies = proxies
|
|
568
|
+
|
|
569
|
+
# Initialize chat interface with completions
|
|
570
|
+
self.chat = Chat(self)
|
|
571
|
+
|
|
572
|
+
@property
|
|
573
|
+
def models(self):
|
|
574
|
+
class _ModelList:
|
|
575
|
+
def list(inner_self):
|
|
576
|
+
return type(self).AVAILABLE_MODELS
|
|
577
|
+
return _ModelList()
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
@classmethod
|
|
581
|
+
def get_model(cls, model: str) -> str:
|
|
582
|
+
"""Resolve model name from alias."""
|
|
583
|
+
# Remove BLACKBOXAI/ prefix if present
|
|
584
|
+
if model.startswith("BLACKBOXAI/"):
|
|
585
|
+
model = model[len("BLACKBOXAI/"):]
|
|
586
|
+
|
|
587
|
+
# Convert to lowercase for case-insensitive matching
|
|
588
|
+
model_lower = model.lower()
|
|
589
|
+
|
|
590
|
+
# Check aliases (case-insensitive)
|
|
591
|
+
for alias, target in cls.model_aliases.items():
|
|
592
|
+
if model_lower == alias.lower():
|
|
593
|
+
return target
|
|
594
|
+
|
|
595
|
+
# If the model is directly in available models (without the prefix), return it
|
|
596
|
+
for available_model in cls._all_model_aliases:
|
|
597
|
+
if model_lower == available_model.lower():
|
|
598
|
+
# Find the corresponding model in model_aliases or use the model directly
|
|
599
|
+
for alias, target in cls.model_aliases.items():
|
|
600
|
+
if available_model.lower() == alias.lower():
|
|
601
|
+
return target
|
|
602
|
+
return available_model
|
|
603
|
+
|
|
604
|
+
# If we get here, use the default model
|
|
605
|
+
return cls.default_model
|
|
606
|
+
|
|
607
|
+
@classmethod
|
|
608
|
+
def generate_random_string(cls, length: int = 8) -> str:
|
|
609
|
+
"""Generate a random string of specified length."""
|
|
610
|
+
chars = string.ascii_lowercase + string.digits
|
|
611
|
+
return ''.join(random.choice(chars) for _ in range(length))
|
|
612
|
+
|
|
613
|
+
@classmethod
|
|
614
|
+
def generate_id(cls, length: int = 7) -> str:
|
|
615
|
+
"""Generate a random ID of specified length."""
|
|
616
|
+
chars = string.ascii_letters + string.digits
|
|
617
|
+
return ''.join(random.choice(chars) for _ in range(length))
|
|
618
|
+
|
|
619
|
+
@classmethod
|
|
620
|
+
def generate_session(cls, email: str, id_length: int = 21, days_ahead: int = 30) -> dict:
|
|
621
|
+
"""
|
|
622
|
+
Generate a dynamic session with proper ID and expiry format using a specific email.
|
|
623
|
+
|
|
624
|
+
Args:
|
|
625
|
+
email: The email to use for this session
|
|
626
|
+
id_length: Length of the numeric ID (default: 21)
|
|
627
|
+
days_ahead: Number of days ahead for expiry (default: 30)
|
|
628
|
+
|
|
629
|
+
Returns:
|
|
630
|
+
dict: A session dictionary with user information and expiry
|
|
631
|
+
"""
|
|
632
|
+
# Generate a random name
|
|
633
|
+
first_names = ["Alex", "Jordan", "Taylor", "Morgan", "Casey", "Riley", "Avery", "Quinn", "Skyler", "Dakota"]
|
|
634
|
+
last_names = ["Smith", "Johnson", "Williams", "Brown", "Jones", "Miller", "Davis", "Garcia", "Rodriguez", "Wilson"]
|
|
635
|
+
name = f"{random.choice(first_names)} {random.choice(last_names)}"
|
|
636
|
+
|
|
637
|
+
# Generate numeric ID - using Google-like ID format
|
|
638
|
+
numeric_id = ''.join(random.choice('0123456789') for _ in range(id_length))
|
|
639
|
+
|
|
640
|
+
# Generate future expiry date
|
|
641
|
+
future_date = datetime.now() + timedelta(days=days_ahead)
|
|
642
|
+
expiry = future_date.strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z'
|
|
643
|
+
|
|
644
|
+
# Generate random image ID for the new URL format
|
|
645
|
+
chars = string.ascii_letters + string.digits + "-"
|
|
646
|
+
random_img_id = ''.join(random.choice(chars) for _ in range(48))
|
|
647
|
+
image_url = f"https://lh3.googleusercontent.com/a/ACg8oc{random_img_id}=s96-c"
|
|
648
|
+
|
|
649
|
+
return {
|
|
650
|
+
"user": {
|
|
651
|
+
"name": name,
|
|
652
|
+
"email": email,
|
|
653
|
+
"image": image_url,
|
|
654
|
+
"id": numeric_id
|
|
655
|
+
},
|
|
656
|
+
"expires": expiry,
|
|
657
|
+
"isNewUser": False
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
def create_request_payload(
|
|
661
|
+
self,
|
|
662
|
+
messages: List[Dict[str, Any]],
|
|
663
|
+
chat_id: str,
|
|
664
|
+
system_message: str,
|
|
665
|
+
max_tokens: int,
|
|
666
|
+
temperature: Optional[float] = None,
|
|
667
|
+
top_p: Optional[float] = None,
|
|
668
|
+
session_data: Dict[str, Any] = None,
|
|
669
|
+
model: str = None
|
|
670
|
+
) -> Dict[str, Any]:
|
|
671
|
+
"""Create the full request payload for the BlackboxAI API."""
|
|
672
|
+
# Get the correct model ID and agent mode
|
|
673
|
+
model_name = self.get_model(model or self.default_model)
|
|
674
|
+
agent_mode = self.agentMode.get(model_name, {})
|
|
675
|
+
|
|
676
|
+
# Generate a random customer ID for the subscription
|
|
677
|
+
customer_id = "cus_" + ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(14))
|
|
678
|
+
|
|
679
|
+
# Create the full request payload
|
|
680
|
+
return {
|
|
681
|
+
"messages": messages,
|
|
682
|
+
"agentMode": agent_mode,
|
|
683
|
+
"id": chat_id,
|
|
684
|
+
"previewToken": None,
|
|
685
|
+
"userId": None,
|
|
686
|
+
"codeModelMode": True,
|
|
687
|
+
"trendingAgentMode": {},
|
|
688
|
+
"isMicMode": False,
|
|
689
|
+
"userSystemPrompt": system_message,
|
|
690
|
+
"maxTokens": max_tokens,
|
|
691
|
+
"playgroundTopP": top_p,
|
|
692
|
+
"playgroundTemperature": temperature,
|
|
693
|
+
"isChromeExt": False,
|
|
694
|
+
"githubToken": "",
|
|
695
|
+
"clickedAnswer2": False,
|
|
696
|
+
"clickedAnswer3": False,
|
|
697
|
+
"clickedForceWebSearch": False,
|
|
698
|
+
"visitFromDelta": False,
|
|
699
|
+
"isMemoryEnabled": False,
|
|
700
|
+
"mobileClient": False,
|
|
701
|
+
"userSelectedModel": model_name if model_name in self.userSelectedModel else None,
|
|
702
|
+
"validated": "00f37b34-a166-4efb-bce5-1312d87f2f94",
|
|
703
|
+
"imageGenerationMode": False,
|
|
704
|
+
"webSearchModePrompt": False,
|
|
705
|
+
"deepSearchMode": False,
|
|
706
|
+
"designerMode": False,
|
|
707
|
+
"domains": None,
|
|
708
|
+
"vscodeClient": False,
|
|
709
|
+
"codeInterpreterMode": False,
|
|
710
|
+
"customProfile": {
|
|
711
|
+
"name": "",
|
|
712
|
+
"occupation": "",
|
|
713
|
+
"traits": [],
|
|
714
|
+
"additionalInfo": "",
|
|
715
|
+
"enableNewChats": False
|
|
716
|
+
},
|
|
717
|
+
"webSearchModeOption": {
|
|
718
|
+
"autoMode": True,
|
|
719
|
+
"webMode": False,
|
|
720
|
+
"offlineMode": False
|
|
721
|
+
},
|
|
722
|
+
"session": session_data,
|
|
723
|
+
"isPremium": True,
|
|
724
|
+
"subscriptionCache": {
|
|
725
|
+
"status": "PREMIUM",
|
|
726
|
+
"customerId": customer_id,
|
|
727
|
+
"expiryTimestamp": int((datetime.now() + timedelta(days=30)).timestamp()),
|
|
728
|
+
"lastChecked": int(datetime.now().timestamp() * 1000),
|
|
729
|
+
"isTrialSubscription": True
|
|
730
|
+
},
|
|
731
|
+
"beastMode": False,
|
|
732
|
+
"reasoningMode": False,
|
|
733
|
+
"designerMode": False,
|
|
734
|
+
"workspaceId": ""
|
|
735
|
+
}
|