From adf5cbfeba62c315bfea7f7f3c0ec56870109b7d Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Fri, 8 Sep 2023 16:41:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E7=BD=91=E9=A1=B5?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E7=9A=84=E7=A8=B3=E5=AE=9A=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- util/gplugin.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/util/gplugin.py b/util/gplugin.py index c4c070fa3..ec3ccb80c 100644 --- a/util/gplugin.py +++ b/util/gplugin.py @@ -129,11 +129,16 @@ def web_search(question, provider): func_definition1 = new_func_call.func_dump() question1 = f"{question} \n(只能调用一个函数。)" - res1, has_func = new_func_call.func_call(question1, func_definition1, is_task=False, is_summary=False) + try: + res1, has_func = new_func_call.func_call(question1, func_definition1, is_task=False, is_summary=False) + except BaseException as e: + res = provider.text_chat(question) + "\n(网页搜索失败, 此为默认回复)" + return res + has_func = True if has_func: provider.forget() - question3 = f"""请你回答`{question}`问题。\n以下是相关材料,你请直接拿此材料针对问题进行总结回答,然后再给出参考链接。不要提到任何函数调用的信息。```\n{res1}\n```\n""" + question3 = f"""请你回答`{question}`问题。\n以下是相关材料,请直接拿此材料针对问题进行总结回答,再给出参考链接。不要提到任何函数调用的信息。```\n{res1}\n```\n""" print(question3) _c = 0 while _c < 5: @@ -148,7 +153,7 @@ def web_search(question, provider): raise e if "The message you submitted was too long" in str(e): res2 = res2[:int(len(res2) / 2)] - question3 = f"""请你回答`{question}`问题。\n以下是相关材料,请直接拿此材料针对问题进行回答,然后再给出参考链接。```\n{res1}\n{res2}\n```\n""" + question3 = f"""请你回答`{question}`问题。\n以下是相关材料,请直接拿此材料针对问题进行回答,再给出参考链接。```\n{res1}\n{res2}\n```\n""" return res3 else: return res1 \ No newline at end of file