summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/You.py
diff options
context:
space:
mode:
authorTekky <98614666+xtekky@users.noreply.github.com>2023-09-12 11:37:20 +0200
committerGitHub <noreply@github.com>2023-09-12 11:37:20 +0200
commitcf7ba76e7eb27a3e62bea900f5f7fbd3381783ba (patch)
tree0a1f1eb3639c34472884d8d3d7bd102b12c891ff /g4f/Provider/You.py
parent~ | 0.0.2.8 (diff)
parentDisable not working providers: (diff)
downloadgpt4free-cf7ba76e7eb27a3e62bea900f5f7fbd3381783ba.tar
gpt4free-cf7ba76e7eb27a3e62bea900f5f7fbd3381783ba.tar.gz
gpt4free-cf7ba76e7eb27a3e62bea900f5f7fbd3381783ba.tar.bz2
gpt4free-cf7ba76e7eb27a3e62bea900f5f7fbd3381783ba.tar.lz
gpt4free-cf7ba76e7eb27a3e62bea900f5f7fbd3381783ba.tar.xz
gpt4free-cf7ba76e7eb27a3e62bea900f5f7fbd3381783ba.tar.zst
gpt4free-cf7ba76e7eb27a3e62bea900f5f7fbd3381783ba.zip
Diffstat (limited to 'g4f/Provider/You.py')
-rw-r--r--g4f/Provider/You.py40
1 files changed, 20 insertions, 20 deletions
diff --git a/g4f/Provider/You.py b/g4f/Provider/You.py
index 121d1dbd..4f49f15e 100644
--- a/g4f/Provider/You.py
+++ b/g4f/Provider/You.py
@@ -2,39 +2,39 @@ from __future__ import annotations
import json
-from aiohttp import ClientSession
+from curl_cffi.requests import AsyncSession
from ..typing import AsyncGenerator
-from .base_provider import AsyncGeneratorProvider, format_prompt, get_cookies
+from .base_provider import AsyncGeneratorProvider, format_prompt
class You(AsyncGeneratorProvider):
url = "https://you.com"
working = True
supports_gpt_35_turbo = True
- supports_stream = True
+ supports_stream = False
- @staticmethod
+
+ @classmethod
async def create_async_generator(
+ cls,
model: str,
messages: list[dict[str, str]],
- cookies: dict = None,
+ proxy: str = None,
**kwargs,
) -> AsyncGenerator:
- if not cookies:
- cookies = get_cookies("you.com")
- headers = {
- "Accept": "text/event-stream",
- "Referer": "https://you.com/search?fromSearchBar=true&tbm=youchat",
- "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/116.0"
- }
- async with ClientSession(headers=headers, cookies=cookies) as session:
- async with session.get(
+ async with AsyncSession(proxies={"https": proxy}, impersonate="chrome107") as session:
+ headers = {
+ "Accept": "text/event-stream",
+ "Referer": "https://you.com/search?fromSearchBar=true&tbm=youchat",
+ }
+ response = await session.get(
"https://you.com/api/streamingSearch",
params={"q": format_prompt(messages), "domain": "youchat", "chat": ""},
- ) as response:
- start = 'data: {"youChatToken": '
- async for line in response.content:
- line = line.decode('utf-8')
- if line.startswith(start):
- yield json.loads(line[len(start): -2]) \ No newline at end of file
+ headers=headers
+ )
+ response.raise_for_status()
+ start = 'data: {"youChatToken": '
+ for line in response.text.splitlines():
+ if line.startswith(start):
+ yield json.loads(line[len(start): -1]) \ No newline at end of file