From 4d5ed2f318de89ef042cd6e804309bcf85289aa9 Mon Sep 17 00:00:00 2001 From: neavo Date: Thu, 11 Jul 2024 02:32:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20-=20=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=80=BC=E6=A0=BC=E5=BC=8F=E5=AE=B9=E9=94=99?= =?UTF-8?q?=E5=A4=84=E7=90=86=E4=B8=AD=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helper/TextHelper.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/helper/TextHelper.py b/helper/TextHelper.py index 5ce446a..12bacaf 100644 --- a/helper/TextHelper.py +++ b/helper/TextHelper.py @@ -138,11 +138,11 @@ def fix_broken_json_string(jsonstring): r'(?<=: ").+(?=")', # 匹配Json字符中的值不包括双引号的部分 lambda matches: matches.group(0).replace('\\"', '"').replace('"', '\\"'), jsonstring, - ) + ).strip() # 在 GLM4-9B 回复中发现 - jsonstring = jsonstring.replace("```json", "").replace("```", "") - jsonstring = jsonstring.replace('“', '\\"').replace('”', '\\"') + jsonstring = jsonstring.replace("```json", "").replace("```", "").strip() + jsonstring = jsonstring.replace('“', '\\"').replace('”', '\\"').strip() jsonstring = jsonstring + "}" if not jsonstring.endswith("}") else jsonstring return jsonstring \ No newline at end of file