summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/You.py
diff options
context:
space:
mode:
authorTekky <98614666+xtekky@users.noreply.github.com>2023-08-25 18:22:25 +0200
committerGitHub <noreply@github.com>2023-08-25 18:22:25 +0200
commit473ac1450ae09cd59c7dc818a4bb272ed5640610 (patch)
tree60052aad3746053eb4aec5b7e44d75404f4d11fe /g4f/Provider/You.py
parentRemove judge function (diff)
parent~ | Merge pull request #841 (diff)
downloadgpt4free-473ac1450ae09cd59c7dc818a4bb272ed5640610.tar
gpt4free-473ac1450ae09cd59c7dc818a4bb272ed5640610.tar.gz
gpt4free-473ac1450ae09cd59c7dc818a4bb272ed5640610.tar.bz2
gpt4free-473ac1450ae09cd59c7dc818a4bb272ed5640610.tar.lz
gpt4free-473ac1450ae09cd59c7dc818a4bb272ed5640610.tar.xz
gpt4free-473ac1450ae09cd59c7dc818a4bb272ed5640610.tar.zst
gpt4free-473ac1450ae09cd59c7dc818a4bb272ed5640610.zip
Diffstat (limited to 'g4f/Provider/You.py')
-rw-r--r--g4f/Provider/You.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/g4f/Provider/You.py b/g4f/Provider/You.py
index cbd741ba..7ea699a2 100644
--- a/g4f/Provider/You.py
+++ b/g4f/Provider/You.py
@@ -20,7 +20,7 @@ class You(BaseProvider):
stream: bool,
**kwargs: Any,
) -> CreateResult:
- url_param = _create_url_param(messages)
+ url_param = _create_url_param(messages, kwargs.get("history", []))
headers = _create_header()
url = f"https://you.com/api/streamingSearch?{url_param}"
response = requests.get(
@@ -29,16 +29,19 @@ class You(BaseProvider):
impersonate="chrome107",
)
response.raise_for_status()
+
start = 'data: {"youChatToken": '
for line in response.content.splitlines():
line = line.decode('utf-8')
if line.startswith(start):
yield json.loads(line[len(start): -1])
-
-def _create_url_param(messages: list[dict[str, str]]):
- prompt = messages.pop()["content"]
- chat = _convert_chat(messages)
+def _create_url_param(messages: list[dict[str, str]], history: list[dict[str, str]]):
+ prompt = ""
+ for message in messages:
+ prompt += "%s: %s\n" % (message["role"], message["content"])
+ prompt += "assistant:"
+ chat = _convert_chat(history)
param = {"q": prompt, "domain": "youchat", "chat": chat}
return urllib.parse.urlencode(param)