summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/You.py
diff options
context:
space:
mode:
authorTekky <98614666+xtekky@users.noreply.github.com>2023-10-05 20:06:21 +0200
committerGitHub <noreply@github.com>2023-10-05 20:06:21 +0200
commita59dc2fb36b42be735d52db24016f29f09cefff6 (patch)
tree76240685a9dcc320535cf0ffb3a5b931b2a14b72 /g4f/Provider/You.py
parent~ | Merge pull request #984 from HexyeDEV/patch-2 (diff)
parentMerge branch 'main' into bom (diff)
downloadgpt4free-a59dc2fb36b42be735d52db24016f29f09cefff6.tar
gpt4free-a59dc2fb36b42be735d52db24016f29f09cefff6.tar.gz
gpt4free-a59dc2fb36b42be735d52db24016f29f09cefff6.tar.bz2
gpt4free-a59dc2fb36b42be735d52db24016f29f09cefff6.tar.lz
gpt4free-a59dc2fb36b42be735d52db24016f29f09cefff6.tar.xz
gpt4free-a59dc2fb36b42be735d52db24016f29f09cefff6.tar.zst
gpt4free-a59dc2fb36b42be735d52db24016f29f09cefff6.zip
Diffstat (limited to 'g4f/Provider/You.py')
-rw-r--r--g4f/Provider/You.py21
1 files changed, 10 insertions, 11 deletions
diff --git a/g4f/Provider/You.py b/g4f/Provider/You.py
index 4f49f15e..4afe1ef6 100644
--- a/g4f/Provider/You.py
+++ b/g4f/Provider/You.py
@@ -2,8 +2,7 @@ from __future__ import annotations
import json
-from curl_cffi.requests import AsyncSession
-
+from ..requests import StreamSession
from ..typing import AsyncGenerator
from .base_provider import AsyncGeneratorProvider, format_prompt
@@ -12,7 +11,6 @@ class You(AsyncGeneratorProvider):
url = "https://you.com"
working = True
supports_gpt_35_turbo = True
- supports_stream = False
@classmethod
@@ -21,20 +19,21 @@ class You(AsyncGeneratorProvider):
model: str,
messages: list[dict[str, str]],
proxy: str = None,
+ timeout: int = 30,
**kwargs,
) -> AsyncGenerator:
- async with AsyncSession(proxies={"https": proxy}, impersonate="chrome107") as session:
+ async with StreamSession(proxies={"https": proxy}, impersonate="chrome107", timeout=timeout) as session:
headers = {
"Accept": "text/event-stream",
"Referer": "https://you.com/search?fromSearchBar=true&tbm=youchat",
}
- response = await session.get(
+ async with session.get(
"https://you.com/api/streamingSearch",
params={"q": format_prompt(messages), "domain": "youchat", "chat": ""},
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
+ ) as response:
+ response.raise_for_status()
+ start = b'data: {"youChatToken": '
+ async for line in response.iter_lines():
+ if line.startswith(start):
+ yield json.loads(line[len(start):-1]) \ No newline at end of file