diff options
author | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-05-21 22:58:56 +0200 |
---|---|---|
committer | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-05-21 22:58:56 +0200 |
commit | 62b2b279ab7f06b14aefb0b3ba09111e004a6003 (patch) | |
tree | 30609eb68c513387bd616a14f9cec3b82db6eaff /g4f/Provider | |
parent | Add streaming and conversation support to gemini (diff) | |
download | gpt4free-62b2b279ab7f06b14aefb0b3ba09111e004a6003.tar gpt4free-62b2b279ab7f06b14aefb0b3ba09111e004a6003.tar.gz gpt4free-62b2b279ab7f06b14aefb0b3ba09111e004a6003.tar.bz2 gpt4free-62b2b279ab7f06b14aefb0b3ba09111e004a6003.tar.lz gpt4free-62b2b279ab7f06b14aefb0b3ba09111e004a6003.tar.xz gpt4free-62b2b279ab7f06b14aefb0b3ba09111e004a6003.tar.zst gpt4free-62b2b279ab7f06b14aefb0b3ba09111e004a6003.zip |
Diffstat (limited to 'g4f/Provider')
-rw-r--r-- | g4f/Provider/You.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/g4f/Provider/You.py b/g4f/Provider/You.py index d549423e..162d6adb 100644 --- a/g4f/Provider/You.py +++ b/g4f/Provider/You.py @@ -8,7 +8,7 @@ import uuid from ..typing import AsyncResult, Messages, ImageType, Cookies from .base_provider import AsyncGeneratorProvider, ProviderModelMixin from .helper import format_prompt -from ..image import ImageResponse, ImagePreview, to_bytes, is_accepted_format +from ..image import ImageResponse, ImagePreview, EXTENSIONS_MAP, to_bytes, is_accepted_format from ..requests import StreamSession, FormData, raise_for_status from .you.har_file import get_telemetry_ids from .. import debug @@ -94,6 +94,8 @@ class You(AsyncGeneratorProvider, ProviderModelMixin): "q": format_prompt(messages), "domain": "youchat", "selectedChatMode": chat_mode, + "conversationTurnId": str(uuid.uuid4()), + "chatId": str(uuid.uuid4()), } params = { "userFiles": upload, @@ -106,8 +108,8 @@ class You(AsyncGeneratorProvider, ProviderModelMixin): async with (session.post if chat_mode == "default" else session.get)( f"{cls.url}/api/streamingSearch", - data=data, - params=params, + data=data if chat_mode == "default" else None, + params=params if chat_mode == "default" else data, headers=headers, cookies=cookies ) as response: @@ -142,7 +144,9 @@ class You(AsyncGeneratorProvider, ProviderModelMixin): await raise_for_status(response) upload_nonce = await response.text() data = FormData() - data.add_field('file', file, content_type=is_accepted_format(file), filename=filename) + content_type = is_accepted_format(file) + filename = f"image.{EXTENSIONS_MAP[content_type]}" if filename is None else filename + data.add_field('file', file, content_type=content_type, filename=filename) async with client.post( f"{cls.url}/api/upload", data=data, |