summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/ChatBase.py
diff options
context:
space:
mode:
authorTekky <98614666+xtekky@users.noreply.github.com>2023-10-24 20:41:56 +0200
committerGitHub <noreply@github.com>2023-10-24 20:41:56 +0200
commit4c276c7ed640be687c08272b7ab185f2852c2cd3 (patch)
tree46683bfcf166a334b3903ecca88e97aacf8e149e /g4f/Provider/ChatBase.py
parentUpdate MyShell.py (diff)
parentAdd support for detecting incorrect responses in ChatBase API requests. (diff)
downloadgpt4free-4c276c7ed640be687c08272b7ab185f2852c2cd3.tar
gpt4free-4c276c7ed640be687c08272b7ab185f2852c2cd3.tar.gz
gpt4free-4c276c7ed640be687c08272b7ab185f2852c2cd3.tar.bz2
gpt4free-4c276c7ed640be687c08272b7ab185f2852c2cd3.tar.lz
gpt4free-4c276c7ed640be687c08272b7ab185f2852c2cd3.tar.xz
gpt4free-4c276c7ed640be687c08272b7ab185f2852c2cd3.tar.zst
gpt4free-4c276c7ed640be687c08272b7ab185f2852c2cd3.zip
Diffstat (limited to '')
-rw-r--r--g4f/Provider/ChatBase.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/g4f/Provider/ChatBase.py b/g4f/Provider/ChatBase.py
index 8f9e2aad..7190e617 100644
--- a/g4f/Provider/ChatBase.py
+++ b/g4f/Provider/ChatBase.py
@@ -10,6 +10,8 @@ class ChatBase(AsyncGeneratorProvider):
url = "https://www.chatbase.co"
supports_gpt_35_turbo = True
working = True
+ list_incorrect_responses = ["Hmm, I am not sure. Email support@chatbase.co for more info.",
+ "I can only provide support and information about Chatbase"]
@classmethod
async def create_async_generator(
@@ -41,7 +43,12 @@ class ChatBase(AsyncGeneratorProvider):
async with session.post("https://www.chatbase.co/api/fe/chat", json=data, proxy=proxy) as response:
response.raise_for_status()
+ response_data = ""
async for stream in response.content.iter_any():
+ response_data += stream.decode()
+ for incorrect_response in cls.list_incorrect_responses:
+ if incorrect_response in response_data:
+ raise RuntimeError("Incorrect response")
yield stream.decode()
@classmethod