mirror of
https://github.com/xtekky/gpt4free.git
synced 2024-12-23 19:11:48 +03:00
feat(g4f/Provider/Blackbox.py): enhance vision image handling
This commit is contained in:
parent
3119b8e37e
commit
9c3190d11c
@ -89,7 +89,7 @@ class Blackbox(AsyncGeneratorProvider, ProviderModelMixin):
|
||||
|
||||
'PythonAgent': '@Python Agent',
|
||||
'JavaAgent': '@Java Agent',
|
||||
'JavaScriptAgent': '@Java Agent',
|
||||
'JavaScriptAgent': '@JavaScript Agent',
|
||||
'HTMLAgent': '@HTML Agent',
|
||||
'GoogleCloudAgent': '@Google Cloud Agent',
|
||||
'AndroidDeveloper': '@Android Developer',
|
||||
@ -163,14 +163,17 @@ class Blackbox(AsyncGeneratorProvider, ProviderModelMixin):
|
||||
if not messages[0]['content'].startswith(prefix):
|
||||
messages[0]['content'] = f"{prefix} {messages[0]['content']}"
|
||||
|
||||
async with ClientSession(headers=headers) as session:
|
||||
if image is not None:
|
||||
messages[-1]["data"] = {
|
||||
"fileText": image_name,
|
||||
"imageBase64": to_data_uri(image)
|
||||
}
|
||||
|
||||
random_id = ''.join(random.choices(string.ascii_letters + string.digits, k=7))
|
||||
messages[-1]['id'] = random_id
|
||||
messages[-1]['role'] = 'user'
|
||||
|
||||
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']
|
||||
|
||||
data = {
|
||||
"messages": messages,
|
||||
@ -203,6 +206,7 @@ class Blackbox(AsyncGeneratorProvider, ProviderModelMixin):
|
||||
elif model in cls.userSelectedModel:
|
||||
data["userSelectedModel"] = cls.userSelectedModel[model]
|
||||
|
||||
async with ClientSession(headers=headers) as session:
|
||||
async with session.post(cls.api_endpoint, json=data, proxy=proxy) as response:
|
||||
response.raise_for_status()
|
||||
if model == 'ImageGeneration':
|
||||
|
Loading…
Reference in New Issue
Block a user