summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/Blackbox.py
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-11-20 02:42:15 +0100
committerGitHub <noreply@github.com>2024-11-20 02:42:15 +0100
commit419264f9665ed50ac0dcbf86327da8bf221ac3e8 (patch)
tree027ebe8efcb413b648101ac6fd4fe744803e8a8a /g4f/Provider/Blackbox.py
parentMerge pull request #2387 from hlohaus/info (diff)
parentFix missing provider_handler in client (diff)
downloadgpt4free-419264f9665ed50ac0dcbf86327da8bf221ac3e8.tar
gpt4free-419264f9665ed50ac0dcbf86327da8bf221ac3e8.tar.gz
gpt4free-419264f9665ed50ac0dcbf86327da8bf221ac3e8.tar.bz2
gpt4free-419264f9665ed50ac0dcbf86327da8bf221ac3e8.tar.lz
gpt4free-419264f9665ed50ac0dcbf86327da8bf221ac3e8.tar.xz
gpt4free-419264f9665ed50ac0dcbf86327da8bf221ac3e8.tar.zst
gpt4free-419264f9665ed50ac0dcbf86327da8bf221ac3e8.zip
Diffstat (limited to 'g4f/Provider/Blackbox.py')
-rw-r--r--g4f/Provider/Blackbox.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/g4f/Provider/Blackbox.py b/g4f/Provider/Blackbox.py
index 97466c04..ba58a511 100644
--- a/g4f/Provider/Blackbox.py
+++ b/g4f/Provider/Blackbox.py
@@ -28,6 +28,9 @@ class Blackbox(AsyncGeneratorProvider, ProviderModelMixin):
image_models = [default_image_model, 'repomap']
text_models = [default_model, 'gpt-4o', 'gemini-pro', 'claude-sonnet-3.5', 'blackboxai-pro']
vision_models = [default_model, 'gpt-4o', 'gemini-pro', 'blackboxai-pro']
+ model_aliases = {
+ "claude-3.5-sonnet": "claude-sonnet-3.5",
+ }
agentMode = {
default_image_model: {'mode': True, 'id': "ImageGenerationLV45LJp", 'name': "Image Generation"},
}
@@ -198,6 +201,7 @@ class Blackbox(AsyncGeneratorProvider, ProviderModelMixin):
async with ClientSession(headers=headers) as session:
async with session.post(cls.api_endpoint, json=data, proxy=proxy) as response:
response.raise_for_status()
+ is_first = False
async for chunk in response.content.iter_any():
text_chunk = chunk.decode(errors="ignore")
if model in cls.image_models:
@@ -217,5 +221,9 @@ class Blackbox(AsyncGeneratorProvider, ProviderModelMixin):
for i, result in enumerate(search_results, 1):
formatted_response += f"\n{i}. {result['title']}: {result['link']}"
yield formatted_response
- else:
- yield text_chunk.strip()
+ elif text_chunk:
+ if is_first:
+ is_first = False
+ yield text_chunk.lstrip()
+ else:
+ yield text_chunk \ No newline at end of file