Add multiple images support (#2478)

* Add multiple images support

* Add multiple images support in gui

* Support multiple images in legacy client and in the api
Fix some model names in provider model list

* Fix unittests

* Add vision and providers docs
This commit is contained in:
H Lohaus 2024-12-13 22:20:58 +01:00 committed by GitHub
parent bb9132bcb4
commit 335c971f6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 1006 additions and 324 deletions

View file

@ -10,7 +10,7 @@ import aiohttp
import json
from pathlib import Path
from ..typing import AsyncResult, Messages, ImageType
from ..typing import AsyncResult, Messages, ImagesType
from .base_provider import AsyncGeneratorProvider, ProviderModelMixin
from ..image import ImageResponse, to_data_uri
from ..cookies import get_cookies_dir
@ -197,8 +197,7 @@ class Blackbox(AsyncGeneratorProvider, ProviderModelMixin):
prompt: str = None,
proxy: str = None,
web_search: bool = False,
image: ImageType = None,
image_name: str = None,
images: ImagesType = None,
top_p: float = 0.9,
temperature: float = 0.5,
max_tokens: int = 1024,
@ -212,13 +211,14 @@ class Blackbox(AsyncGeneratorProvider, ProviderModelMixin):
messages = [{"id": message_id, "content": formatted_message, "role": "user"}]
if image is not None:
if images is not None:
messages[-1]['data'] = {
"imagesData": [
{
"filePath": f"MultipleFiles/{image_name}",
"contents": to_data_uri(image)
}
for image, image_name in images
],
"fileText": "",
"title": ""