From 7222d9b7cea4db173258c1189f5069b544606eeb Mon Sep 17 00:00:00 2001 From: zengrr <47846202+zeng-rr@users.noreply.github.com> Date: Wed, 23 Aug 2023 15:26:00 +0800 Subject: "You" unicode decode and fix prompt just is last message --- g4f/Provider/You.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'g4f/Provider') 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) -- cgit v1.2.3 From 6a4463889eab6cfa4d73efd2aff7c2904640444c Mon Sep 17 00:00:00 2001 From: zengrr <47846202+zeng-rr@users.noreply.github.com> Date: Wed, 23 Aug 2023 15:34:38 +0800 Subject: fix Yqcloud's prompter using only the last message --- g4f/Provider/Yqcloud.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'g4f/Provider') diff --git a/g4f/Provider/Yqcloud.py b/g4f/Provider/Yqcloud.py index a3147c2d..82ece2d5 100644 --- a/g4f/Provider/Yqcloud.py +++ b/g4f/Provider/Yqcloud.py @@ -35,7 +35,10 @@ def _create_header(): def _create_payload(messages: list[dict[str, str]]): - prompt = messages[-1]["content"] + prompt = "" + for message in messages: + prompt += "%s: %s\n" % (message["role"], message["content"]) + prompt += "assistant:" return { "prompt": prompt, "network": True, -- cgit v1.2.3 From 1ed448e584092e151212b1d511fd2cbec133064b Mon Sep 17 00:00:00 2001 From: zengrr <47846202+zeng-rr@users.noreply.github.com> Date: Wed, 23 Aug 2023 19:36:30 +0800 Subject: Ails throw the contents of an error response --- g4f/Provider/Ails.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'g4f/Provider') diff --git a/g4f/Provider/Ails.py b/g4f/Provider/Ails.py index 52b3745d..806544b4 100644 --- a/g4f/Provider/Ails.py +++ b/g4f/Provider/Ails.py @@ -72,6 +72,8 @@ class Ails(BaseProvider): if b"content" in token: completion_chunk = json.loads(token.decode().replace("data: ", "")) token = completion_chunk["choices"][0]["delta"].get("content") + if "ai.ls".lower() in token.lower(): + raise Exception("Response Error: " + token) if token != None: yield token -- cgit v1.2.3 From 38abb0a0b0a7f2e92dd5d19cee5374cc5a166f20 Mon Sep 17 00:00:00 2001 From: zengrr <47846202+zeng-rr@users.noreply.github.com> Date: Fri, 25 Aug 2023 10:07:48 +0800 Subject: Ails Supplementary Identification of Unusual Response Content --- g4f/Provider/Ails.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'g4f/Provider') diff --git a/g4f/Provider/Ails.py b/g4f/Provider/Ails.py index 806544b4..6665b677 100644 --- a/g4f/Provider/Ails.py +++ b/g4f/Provider/Ails.py @@ -72,7 +72,7 @@ class Ails(BaseProvider): if b"content" in token: completion_chunk = json.loads(token.decode().replace("data: ", "")) token = completion_chunk["choices"][0]["delta"].get("content") - if "ai.ls".lower() in token.lower(): + if "ai.ls" in token.lower() or "ai.ci" in token.lower(): raise Exception("Response Error: " + token) if token != None: yield token -- cgit v1.2.3