XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

Add support for detecting incorrect responses in ChatBase API requests.

fd2b5282
razrab <razrab@PimoLin>
提交于

代码差异

1 个文件 +7 -0
Modified g4f/Provider/ChatBase.py +7 -0
@@ -10,6 +10,8 @@ class ChatBase(AsyncGeneratorProvider):
10 10 url = "https://www.chatbase.co"
11 11 supports_gpt_35_turbo = True
12 12 working = True
13 list_incorrect_responses = ["Hmm, I am not sure. Email support@chatbase.co for more info.",
14 "I can only provide support and information about Chatbase"]
13 15
14 16 @classmethod
15 17 async def create_async_generator(
@@ -41,7 +43,12 @@ class ChatBase(AsyncGeneratorProvider):
41 43
42 44 async with session.post("https://www.chatbase.co/api/fe/chat", json=data, proxy=proxy) as response:
43 45 response.raise_for_status()
46 response_data = ""
44 47 async for stream in response.content.iter_any():
48 response_data += stream.decode()
49 for incorrect_response in cls.list_incorrect_responses:
50 if incorrect_response in response_data:
51 raise RuntimeError("Incorrect response")
45 52 yield stream.decode()
46 53
47 54 @classmethod