Skip to content

Commit

Permalink
Merge pull request #18 from neavo/dev
Browse files Browse the repository at this point in the history
修正 - 一个返回值格式容错处理中的问题
  • Loading branch information
neavo authored Jul 10, 2024
2 parents 37bb8ec + 4d5ed2f commit 85e97e2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions helper/TextHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 85e97e2

Please sign in to comment.