diff options
author | H Lohaus <hlohaus@users.noreply.github.com> | 2024-04-10 08:14:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-10 08:14:50 +0200 |
commit | 00951eb79114adf74ad1a3f1ce596e9e0fa932bf (patch) | |
tree | fea75e7745d69b09d91b0003e5dbf12b77380223 /g4f/Provider/You.py | |
parent | Update Dockerfile (diff) | |
download | gpt4free-00951eb79114adf74ad1a3f1ce596e9e0fa932bf.tar gpt4free-00951eb79114adf74ad1a3f1ce596e9e0fa932bf.tar.gz gpt4free-00951eb79114adf74ad1a3f1ce596e9e0fa932bf.tar.bz2 gpt4free-00951eb79114adf74ad1a3f1ce596e9e0fa932bf.tar.lz gpt4free-00951eb79114adf74ad1a3f1ce596e9e0fa932bf.tar.xz gpt4free-00951eb79114adf74ad1a3f1ce596e9e0fa932bf.tar.zst gpt4free-00951eb79114adf74ad1a3f1ce596e9e0fa932bf.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/Provider/You.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/g4f/Provider/You.py b/g4f/Provider/You.py index 6256cda9..cfa2c7bf 100644 --- a/g4f/Provider/You.py +++ b/g4f/Provider/You.py @@ -8,8 +8,9 @@ import uuid from ..typing import AsyncResult, Messages, ImageType, Cookies from .base_provider import AsyncGeneratorProvider, ProviderModelMixin from .helper import format_prompt -from ..image import to_bytes, ImageResponse +from ..image import ImageResponse, to_bytes, is_accepted_format from ..requests import StreamSession, FormData, raise_for_status +from ..errors import MissingRequirementsError from .you.har_file import get_dfp_telemetry_id @@ -46,6 +47,7 @@ class You(AsyncGeneratorProvider, ProviderModelMixin): image: ImageType = None, image_name: str = None, proxy: str = None, + timeout: int = 240, chat_mode: str = "default", **kwargs, ) -> AsyncResult: @@ -55,12 +57,14 @@ class You(AsyncGeneratorProvider, ProviderModelMixin): ... elif model.startswith("dall-e"): chat_mode = "create" + messages = [messages[-1]] else: chat_mode = "custom" model = cls.get_model(model) async with StreamSession( proxies={"all": proxy}, - impersonate="chrome" + impersonate="chrome", + timeout=(30, timeout) ) as session: cookies = await cls.get_cookies(session) if chat_mode != "default" else None upload = json.dumps([await cls.upload_file(session, cookies, to_bytes(image), image_name)]) if image else "" @@ -73,7 +77,6 @@ class You(AsyncGeneratorProvider, ProviderModelMixin): "q": format_prompt(messages), "domain": "youchat", "selectedChatMode": chat_mode, - #"chat": json.dumps(chat), } params = { "userFiles": upload, @@ -113,7 +116,7 @@ class You(AsyncGeneratorProvider, ProviderModelMixin): await raise_for_status(response) upload_nonce = await response.text() data = FormData() - data.add_field('file', file, filename=filename) + data.add_field('file', file, content_type=is_accepted_format(file), filename=filename) async with client.post( f"{cls.url}/api/upload", data=data, |