From b6a4a05c084c8758e3bfabd231c1ed7d16b70fec Mon Sep 17 00:00:00 2001 From: RA Date: Sat, 25 Mar 2023 21:55:17 +0800 Subject: [PATCH] =?UTF-8?q?[bug=20fixed]bing=E6=A8=A1=E5=9D=97=E5=AF=B9?= =?UTF-8?q?=E8=AF=9D=E8=B6=85=E6=97=B6=E9=87=8D=E6=96=B0=E5=BC=80=E5=90=AF?= =?UTF-8?q?=E6=96=B0=E4=B8=80=E8=BD=AE=E5=AF=B9=E8=AF=9D,ImageGen=E7=94=9F?= =?UTF-8?q?=E6=88=90=E5=9B=BE=E7=89=87=E5=A4=B1=E8=B4=A5=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/bing/new_bing_model.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/model/bing/new_bing_model.py b/model/bing/new_bing_model.py index c062158..559d2fa 100644 --- a/model/bing/new_bing_model.py +++ b/model/bing/new_bing_model.py @@ -44,7 +44,12 @@ class BingModel(Model): answer = asyncio.run(task) # 最新一条回复 - reply = answer["item"]["messages"][-1] + try: + reply = answer["item"]["messages"][-1] + except Exception as e: + self.reset_chat(context['from_user_id']) + log.exception(answer) + return "本轮对话已超时,已开启新的一轮对话,请重新提问。" reply_text = reply["text"] reference = "" if "sourceAttributions" in reply: @@ -100,7 +105,7 @@ class BingModel(Model): return img_list except Exception as e: log.exception(e) - return None + return "输入的内容可能违反微软的图片生成内容策略。过多的策略冲突可能会导致你被暂停访问。" def reset_chat(self, from_user_id): asyncio.run(user_session.get(from_user_id, None).reset())