From 51abcb86cb21b193cfbd619c92d3dafb81f38e16 Mon Sep 17 00:00:00 2001 From: Huoyuuu <86390123+Huoyuuu@users.noreply.github.com> Date: Wed, 5 Jul 2023 16:27:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=20Bard=20=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E4=BB=A5=E6=AD=A3=E7=A1=AE=E8=8E=B7=E5=8F=96=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bard 返回数据的组织方式发生了变化,脚本在读取数据时出现问题。原先代码 `result = data[0][0]` 引发了 `TypeError` 错误。经过实际分析,已将代码修改为 `result = data[4][0][1][0]`。 修改后机器人能够正常运行。 --- adapter/google/bard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapter/google/bard.py b/adapter/google/bard.py index 4d5d4355..841f32be 100644 --- a/adapter/google/bard.py +++ b/adapter/google/bard.py @@ -76,7 +76,7 @@ async def ask(self, prompt: str) -> Generator[str, None, None]: for lines in res: if "wrb.fr" in lines: data = json.loads(json.loads(lines)[0][2]) - result = data[0][0] + result = data[4][0][1][0] self.bard_session_id = data[1][0] self.r = data[1][1] # 用于下一次请求, 这个位置是固定的 # self.rc = data[4][1][0]