From 5a57526aabccb477750eaf721e943f3fc2e93532 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Sat, 25 Nov 2023 19:56:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6BOM=E7=9A=84=E4=B8=80=E4=BA=9B=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- util/cmd_config.py | 24 ++++++++++++++---------- util/gplugin.py | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/util/cmd_config.py b/util/cmd_config.py index d5fc5cdcc..0312505ee 100644 --- a/util/cmd_config.py +++ b/util/cmd_config.py @@ -40,14 +40,18 @@ class CmdConfig(): @staticmethod def init_attributes(keys: list, init_val = ""): check_exist() + conf_str = '' with open(cpath, "r", encoding="utf-8") as f: - d = json.load(f) - _tag = False - for k in keys: - if k not in d: - d[k] = init_val - _tag = True - if _tag: - with open(cpath, "w", encoding="utf-8") as f: - json.dump(d, f, indent=4, ensure_ascii=False) - f.flush() \ No newline at end of file + conf_str = f.read() + if conf_str.startswith(u'/ufeff'): + conf_str = conf_str.encode('utf8')[3:].decode('utf8') + d = json.loads(conf_str) + _tag = False + for k in keys: + if k not in d: + d[k] = init_val + _tag = True + if _tag: + with open(cpath, "w", encoding="utf-8") as f: + json.dump(d, f, indent=4, ensure_ascii=False) + f.flush() \ No newline at end of file diff --git a/util/gplugin.py b/util/gplugin.py index 0c8a455a4..5795179ff 100644 --- a/util/gplugin.py +++ b/util/gplugin.py @@ -259,7 +259,7 @@ def web_search(question, provider: Provider, session_id, official_fc=False): if has_func: provider.forget(session_id) - question3 = f"""请你用活泼的语气回答`{question}`问题。\n以下是相关材料,请直接拿此材料针对问题进行总结回答。在引文末加上参考链接的标号,如` [1]`;在文章末尾加上各参考链接,如`[1] <标题> <网址>`;不要提到任何函数调用的信息;在总结的末尾加上 1-2 个相关的emoji。```\n{function_invoked_ret}\n```\n""" + question3 = f"""请你用活泼的语气回答`{question}`问题。\n以下是相关材料,请直接拿此材料针对问题进行总结回答。在文章末尾加上各参考链接,如`[1]