summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/You.py
diff options
context:
space:
mode:
authorzengrr <47846202+zeng-rr@users.noreply.github.com>2023-08-23 09:26:00 +0200
committerzengrr <47846202+zeng-rr@users.noreply.github.com>2023-08-23 09:26:00 +0200
commit7222d9b7cea4db173258c1189f5069b544606eeb (patch)
treecc7b951a70b084b643067f9fbe2b9c30c8edff88 /g4f/Provider/You.py
parent ~ | Merge pull request #829 (diff)
downloadgpt4free-7222d9b7cea4db173258c1189f5069b544606eeb.tar
gpt4free-7222d9b7cea4db173258c1189f5069b544606eeb.tar.gz
gpt4free-7222d9b7cea4db173258c1189f5069b544606eeb.tar.bz2
gpt4free-7222d9b7cea4db173258c1189f5069b544606eeb.tar.lz
gpt4free-7222d9b7cea4db173258c1189f5069b544606eeb.tar.xz
gpt4free-7222d9b7cea4db173258c1189f5069b544606eeb.tar.zst
gpt4free-7222d9b7cea4db173258c1189f5069b544606eeb.zip
Diffstat (limited to '')
-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 0d8114a8..a8de7dec 100644
--- a/g4f/Provider/You.py
+++ b/g4f/Provider/You.py
@@ -19,7 +19,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(
@@ -28,12 +28,15 @@ class You(BaseProvider):
impersonate="chrome107",
)
response.raise_for_status()
- yield _parse_output(response.text)
+ yield _parse_output(response.text).encode().decode("unicode_escape")
-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)