From 63ae5bb2cdea877e4544518a5fab8bfd7f4a0bb6 Mon Sep 17 00:00:00 2001 From: Luneye <73485421+Luneye@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:35:45 +0200 Subject: [PATCH 01/11] [suggestion] Adding new parameter to check if provider supports message history What are your thoughts on introducing a parameter that allows us to promptly verify whether the provider supports message history? I also considered adding a parameter to indicate whether a provider can perform web searches. --- g4f/Provider/base_provider.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/g4f/Provider/base_provider.py b/g4f/Provider/base_provider.py index c54b98e5..47ea6ff8 100644 --- a/g4f/Provider/base_provider.py +++ b/g4f/Provider/base_provider.py @@ -15,6 +15,7 @@ class BaseProvider(ABC): supports_stream: bool = False supports_gpt_35_turbo: bool = False supports_gpt_4: bool = False + supports_message_history: bool = False @staticmethod @abstractmethod @@ -135,4 +136,4 @@ class AsyncGeneratorProvider(AsyncProvider): messages: Messages, **kwargs ) -> AsyncResult: - raise NotImplementedError() \ No newline at end of file + raise NotImplementedError() From dc798b520db2ab8958f3b01d4d2ee8ac6a52bccd Mon Sep 17 00:00:00 2001 From: Luneye <73485421+Luneye@users.noreply.github.com> Date: Tue, 24 Oct 2023 23:30:07 +0200 Subject: [PATCH 02/11] Indicated support of message history in ChatgptX.py --- g4f/Provider/ChatgptX.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/g4f/Provider/ChatgptX.py b/g4f/Provider/ChatgptX.py index 9a8711b9..75ff0da5 100644 --- a/g4f/Provider/ChatgptX.py +++ b/g4f/Provider/ChatgptX.py @@ -12,6 +12,7 @@ from .helper import format_prompt class ChatgptX(AsyncGeneratorProvider): url = "https://chatgptx.de" supports_gpt_35_turbo = True + supports_message_history = True working = True @classmethod @@ -96,4 +97,4 @@ class ChatgptX(AsyncGeneratorProvider): except: raise RuntimeError(f"Broken line: {line.decode()}") if content: - yield content \ No newline at end of file + yield content From 7f6d85f861c3ba628f50ad4cbf3059eab0104333 Mon Sep 17 00:00:00 2001 From: Luneye <73485421+Luneye@users.noreply.github.com> Date: Tue, 24 Oct 2023 23:36:48 +0200 Subject: [PATCH 03/11] Indicated support of message history in ChatForAi.py --- g4f/Provider/ChatForAi.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/g4f/Provider/ChatForAi.py b/g4f/Provider/ChatForAi.py index 718affeb..7a4e9264 100644 --- a/g4f/Provider/ChatForAi.py +++ b/g4f/Provider/ChatForAi.py @@ -11,6 +11,7 @@ from .base_provider import AsyncGeneratorProvider class ChatForAi(AsyncGeneratorProvider): url = "https://chatforai.store" working = True + supports_message_history = True supports_gpt_35_turbo = True @classmethod @@ -69,4 +70,4 @@ class ChatForAi(AsyncGeneratorProvider): def generate_signature(timestamp: int, message: str, id: str): buffer = f"{timestamp}:{id}:{message}:7YN8z6d6" - return hashlib.sha256(buffer.encode()).hexdigest() \ No newline at end of file + return hashlib.sha256(buffer.encode()).hexdigest() From aee8d5e628094a8c4bfeded5370d1362cf6d82af Mon Sep 17 00:00:00 2001 From: Luneye <73485421+Luneye@users.noreply.github.com> Date: Tue, 24 Oct 2023 23:37:59 +0200 Subject: [PATCH 04/11] Indicated support of message history in FakeGpt.py --- g4f/Provider/FakeGpt.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/g4f/Provider/FakeGpt.py b/g4f/Provider/FakeGpt.py index 5bce1280..a89425d3 100644 --- a/g4f/Provider/FakeGpt.py +++ b/g4f/Provider/FakeGpt.py @@ -10,6 +10,7 @@ from .helper import format_prompt class FakeGpt(AsyncGeneratorProvider): url = "https://chat-shared2.zhile.io" + supports_message_history = True supports_gpt_35_turbo = True working = True _access_token = None @@ -91,4 +92,4 @@ class FakeGpt(AsyncGeneratorProvider): raise RuntimeError("No valid response") def random_string(length: int = 10): - return ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(length)) \ No newline at end of file + return ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(length)) From c839597c6dd0c79d9a603baa8d33fb787b8d5553 Mon Sep 17 00:00:00 2001 From: Luneye <73485421+Luneye@users.noreply.github.com> Date: Tue, 24 Oct 2023 23:39:29 +0200 Subject: [PATCH 05/11] Indicated support of message history in You.py --- g4f/Provider/You.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/g4f/Provider/You.py b/g4f/Provider/You.py index 1afd18be..34972586 100644 --- a/g4f/Provider/You.py +++ b/g4f/Provider/You.py @@ -10,6 +10,7 @@ from .base_provider import AsyncGeneratorProvider, format_prompt class You(AsyncGeneratorProvider): url = "https://you.com" working = True + supports_message_history = True supports_gpt_35_turbo = True @@ -37,4 +38,4 @@ class You(AsyncGeneratorProvider): 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 + yield json.loads(line[len(start):-1]) From c43f82e966299576bc4c58f58bf15d215c2eb695 Mon Sep 17 00:00:00 2001 From: Luneye <73485421+Luneye@users.noreply.github.com> Date: Tue, 24 Oct 2023 23:40:15 +0200 Subject: [PATCH 06/11] Indicated support of message history in Yqcloud.py --- g4f/Provider/Yqcloud.py | 1 + 1 file changed, 1 insertion(+) diff --git a/g4f/Provider/Yqcloud.py b/g4f/Provider/Yqcloud.py index 2829c5bf..12eb7bbb 100644 --- a/g4f/Provider/Yqcloud.py +++ b/g4f/Provider/Yqcloud.py @@ -10,6 +10,7 @@ from .base_provider import AsyncGeneratorProvider, format_prompt class Yqcloud(AsyncGeneratorProvider): url = "https://chat9.yqcloud.top/" working = True + supports_message_history = True supports_gpt_35_turbo = True @staticmethod From 0b43c13268d528cec9fe4b79eb7b7d4efa38e5c4 Mon Sep 17 00:00:00 2001 From: Luneye <73485421+Luneye@users.noreply.github.com> Date: Tue, 24 Oct 2023 23:41:08 +0200 Subject: [PATCH 07/11] Indicated support of message history in GPTalk.py --- g4f/Provider/GPTalk.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/g4f/Provider/GPTalk.py b/g4f/Provider/GPTalk.py index c6b57d91..a5644fc4 100644 --- a/g4f/Provider/GPTalk.py +++ b/g4f/Provider/GPTalk.py @@ -11,6 +11,7 @@ from .helper import format_prompt class GPTalk(AsyncGeneratorProvider): url = "https://gptalk.net" supports_gpt_35_turbo = True + supports_message_history = True working = True _auth = None @@ -81,4 +82,4 @@ class GPTalk(AsyncGeneratorProvider): break message = json.loads(line[6:-1])["content"] yield message[len(last_message):] - last_message = message \ No newline at end of file + last_message = message From 7a2c8e4cd34a5ffc0e6943881a5a4c62f0101040 Mon Sep 17 00:00:00 2001 From: Luneye <73485421+Luneye@users.noreply.github.com> Date: Tue, 24 Oct 2023 23:42:16 +0200 Subject: [PATCH 08/11] Indicated support of message history in FreeGpt.py --- g4f/Provider/FreeGpt.py | 1 + 1 file changed, 1 insertion(+) diff --git a/g4f/Provider/FreeGpt.py b/g4f/Provider/FreeGpt.py index 00d9137d..758e411b 100644 --- a/g4f/Provider/FreeGpt.py +++ b/g4f/Provider/FreeGpt.py @@ -12,6 +12,7 @@ domains = [ class FreeGpt(AsyncGeneratorProvider): url = "https://freegpts1.aifree.site/" + supports_message_history = True supports_gpt_35_turbo = True working = True From e93887aff83862b4ef8634f5be80214ff59bb186 Mon Sep 17 00:00:00 2001 From: Luneye <73485421+Luneye@users.noreply.github.com> Date: Tue, 24 Oct 2023 23:43:08 +0200 Subject: [PATCH 09/11] Indicated support of message history in ChatBase.py --- g4f/Provider/ChatBase.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/g4f/Provider/ChatBase.py b/g4f/Provider/ChatBase.py index 8f9e2aad..0ba511f7 100644 --- a/g4f/Provider/ChatBase.py +++ b/g4f/Provider/ChatBase.py @@ -9,6 +9,7 @@ from .base_provider import AsyncGeneratorProvider class ChatBase(AsyncGeneratorProvider): url = "https://www.chatbase.co" supports_gpt_35_turbo = True + supports_message_history = True working = True @classmethod @@ -53,4 +54,4 @@ class ChatBase(AsyncGeneratorProvider): ("stream", "bool"), ] param = ", ".join([": ".join(p) for p in params]) - return f"g4f.provider.{cls.__name__} supports: ({param})" \ No newline at end of file + return f"g4f.provider.{cls.__name__} supports: ({param})" From 2f539d06013e65d3b7db3e0c5f5f91442c2442f8 Mon Sep 17 00:00:00 2001 From: Luneye <73485421+Luneye@users.noreply.github.com> Date: Tue, 24 Oct 2023 23:44:44 +0200 Subject: [PATCH 10/11] Indicated support of message history in Bing.py --- g4f/Provider/Bing.py | 1 + 1 file changed, 1 insertion(+) diff --git a/g4f/Provider/Bing.py b/g4f/Provider/Bing.py index c54a3ae5..ca14510c 100644 --- a/g4f/Provider/Bing.py +++ b/g4f/Provider/Bing.py @@ -32,6 +32,7 @@ default_cookies = { class Bing(AsyncGeneratorProvider): url = "https://bing.com/chat" working = True + supports_message_history = True supports_gpt_4 = True @staticmethod From 4bb751d989f244422e661e9b9cee125e8338fb62 Mon Sep 17 00:00:00 2001 From: Luneye <73485421+Luneye@users.noreply.github.com> Date: Tue, 24 Oct 2023 23:46:54 +0200 Subject: [PATCH 11/11] Indicated support of message history in GptForLove.py --- g4f/Provider/GptForLove.py | 1 + 1 file changed, 1 insertion(+) diff --git a/g4f/Provider/GptForLove.py b/g4f/Provider/GptForLove.py index 28939592..4b31809c 100644 --- a/g4f/Provider/GptForLove.py +++ b/g4f/Provider/GptForLove.py @@ -9,6 +9,7 @@ from .helper import format_prompt class GptForLove(AsyncGeneratorProvider): url = "https://ai18.gptforlove.com" + supports_message_history = True supports_gpt_35_turbo = True working = True