Skip to content

Commit

Permalink
增加异常请求提示 (#1077)
Browse files Browse the repository at this point in the history
  • Loading branch information
Haibersut authored Jul 21, 2023
1 parent 3b993e6 commit 7a7bc9f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions adapter/chatgpt/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ async def request_with_stream(self, session_id: str = None, messages: list = Non
with async_timeout.timeout(self.bot.timeout):
async with session.post(f'{api_endpoint}/chat/completions', headers=headers, data=json.dumps(data),
proxy=proxy) as resp:
if resp.status != 200:
response_text = await resp.text()
raise Exception(
f"{resp.status} {resp.reason} {response_text}",
)

response_role: str = ''
completion_text: str = ''

Expand Down

0 comments on commit 7a7bc9f

Please sign in to comment.