From 1f8293250e5fd4a76997d5b6d37711bf184d4905 Mon Sep 17 00:00:00 2001 From: abc <98614666+xtekky@users.noreply.github.com> Date: Sat, 14 Oct 2023 14:36:24 +0100 Subject: ~ fix chatbase (bad) and remove from auto selection --- g4f/Provider/ChatBase.py | 15 ++++----------- g4f/Provider/__init__.py | 9 +++++++-- g4f/models.py | 2 -- 3 files changed, 11 insertions(+), 15 deletions(-) (limited to 'g4f') diff --git a/g4f/Provider/ChatBase.py b/g4f/Provider/ChatBase.py index ce5160d8..3d45b40b 100644 --- a/g4f/Provider/ChatBase.py +++ b/g4f/Provider/ChatBase.py @@ -9,7 +9,6 @@ from .base_provider import AsyncGeneratorProvider class ChatBase(AsyncGeneratorProvider): url = "https://www.chatbase.co" supports_gpt_35_turbo = True - supports_gpt_4 = True working = True @classmethod @@ -20,12 +19,8 @@ class ChatBase(AsyncGeneratorProvider): proxy: str = None, **kwargs ) -> AsyncResult: - if model == "gpt-4": - chat_id = "quran---tafseer-saadi-pdf-wbgknt7zn" - elif model == "gpt-3.5-turbo" or not model: - chat_id = "chatbase--1--pdf-p680fxvnm" - else: - raise ValueError(f"Model are not supported: {model}") + chat_id = 'z2c2HSfKnCTh5J4650V0I' + headers = { "User-Agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36", "Accept" : "*/*", @@ -36,21 +31,19 @@ class ChatBase(AsyncGeneratorProvider): "Sec-Fetch-Mode" : "cors", "Sec-Fetch-Site" : "same-origin", } - async with ClientSession( - headers=headers - ) as session: + async with ClientSession(headers=headers) as session: data = { "messages": messages, "captchaCode": "hadsa", "chatId": chat_id, "conversationId": f"kcXpqEnqUie3dnJlsRi_O-{chat_id}" } + async with session.post("https://www.chatbase.co/api/fe/chat", json=data, proxy=proxy) as response: response.raise_for_status() async for stream in response.content.iter_any(): yield stream.decode() - @classmethod @property def params(cls): diff --git a/g4f/Provider/__init__.py b/g4f/Provider/__init__.py index 86346851..4437f563 100644 --- a/g4f/Provider/__init__.py +++ b/g4f/Provider/__init__.py @@ -1,4 +1,4 @@ -from __future__ import annotations +from __future__ import annotations from .Acytoo import Acytoo from .AiAsk import AiAsk from .Aibn import Aibn @@ -99,7 +99,12 @@ class ProviderUtils: 'Wuguokai': Wuguokai, 'Ylokh': Ylokh, 'You': You, - 'Yqcloud': Yqcloud + 'Yqcloud': Yqcloud, + + 'BaseProvider': BaseProvider, + 'AsyncProvider': AsyncProvider, + 'AsyncGeneratorProvider': AsyncGeneratorProvider, + 'RetryProvider': RetryProvider, } __all__ = [ diff --git a/g4f/models.py b/g4f/models.py index 73e7e481..a0f4c429 100644 --- a/g4f/models.py +++ b/g4f/models.py @@ -10,7 +10,6 @@ from .Provider import ( Vitalentum, ChatgptAi, AItianhu, - ChatBase, Liaobots, Yqcloud, Myshell, @@ -41,7 +40,6 @@ default = Model( best_provider = RetryProvider([ Bing, # Not fully GPT 3 or 4 Yqcloud, # Answers short questions in chinese - ChatBase, # Don't want to answer creatively ChatgptDuo, # Include search results Aibn, Aichat, ChatgptAi, ChatgptLogin, FreeGpt, GptGo, Myshell, Ylokh, ]) -- cgit v1.2.3