diff options
author | kqlio67 <kqlio67@users.noreply.github.com> | 2024-10-19 12:17:55 +0200 |
---|---|---|
committer | kqlio67 <kqlio67@users.noreply.github.com> | 2024-10-19 12:17:55 +0200 |
commit | 0a1cfe19879b4babce513d8c47fc009d6dd87d4f (patch) | |
tree | e167758156d0296628741faa8bf7c1507d3daec7 /g4f/Provider/Blackbox.py | |
parent | refactor(g4f/providers/types.py): remove redundant attributes (diff) | |
download | gpt4free-0a1cfe19879b4babce513d8c47fc009d6dd87d4f.tar gpt4free-0a1cfe19879b4babce513d8c47fc009d6dd87d4f.tar.gz gpt4free-0a1cfe19879b4babce513d8c47fc009d6dd87d4f.tar.bz2 gpt4free-0a1cfe19879b4babce513d8c47fc009d6dd87d4f.tar.lz gpt4free-0a1cfe19879b4babce513d8c47fc009d6dd87d4f.tar.xz gpt4free-0a1cfe19879b4babce513d8c47fc009d6dd87d4f.tar.zst gpt4free-0a1cfe19879b4babce513d8c47fc009d6dd87d4f.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/Provider/Blackbox.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/g4f/Provider/Blackbox.py b/g4f/Provider/Blackbox.py index 317df1d4..6d8a467d 100644 --- a/g4f/Provider/Blackbox.py +++ b/g4f/Provider/Blackbox.py @@ -11,9 +11,9 @@ from typing import Optional, AsyncGenerator, Union from aiohttp import ClientSession, ClientResponseError -from ..typing import AsyncResult, Messages +from ..typing import AsyncResult, Messages, ImageType from .base_provider import AsyncGeneratorProvider, ProviderModelMixin -from ..image import ImageResponse +from ..image import ImageResponse, to_data_uri class Blackbox(AsyncGeneratorProvider, ProviderModelMixin): @@ -21,7 +21,6 @@ class Blackbox(AsyncGeneratorProvider, ProviderModelMixin): url = "https://www.blackbox.ai" api_endpoint = "https://www.blackbox.ai/api/chat" working = True - supports_gpt_4 = True supports_stream = True supports_system_message = True supports_message_history = True @@ -171,6 +170,8 @@ class Blackbox(AsyncGeneratorProvider, ProviderModelMixin): model: str, messages: Messages, proxy: Optional[str] = None, + image: ImageType = None, + image_name: str = None, websearch: bool = False, **kwargs ) -> AsyncGenerator[Union[str, ImageResponse], None]: @@ -181,12 +182,23 @@ class Blackbox(AsyncGeneratorProvider, ProviderModelMixin): model (str): Model to use for generating responses. messages (Messages): Message history. proxy (Optional[str]): Proxy URL, if needed. + image (ImageType): Image data to be processed, if any. + image_name (str): Name of the image file, if an image is provided. websearch (bool): Enables or disables web search mode. **kwargs: Additional keyword arguments. Yields: Union[str, ImageResponse]: Segments of the generated response or ImageResponse objects. """ + + if image is not None: + messages[-1]['data'] = { + 'fileText': '', + 'imageBase64': to_data_uri(image), + 'title': image_name + } + messages[-1]['content'] = 'FILE:BB\n$#$\n\n$#$\n' + messages[-1]['content'] + model = cls.get_model(model) chat_id = cls.generate_random_string() @@ -240,7 +252,8 @@ class Blackbox(AsyncGeneratorProvider, ProviderModelMixin): { "id": chat_id, "content": formatted_prompt, - "role": "user" + "role": "user", + "data": messages[-1].get('data') } ], "id": chat_id, |