fix: self healing response parser

This commit is contained in:
Florian Hönicke
2023-05-27 00:00:14 +02:00
parent 8f263c4488
commit e3e2767b0a
5 changed files with 10 additions and 20 deletions

View File

@@ -18,8 +18,8 @@ def boolean_parser(x):
def json_parser(x):
if '```' in x:
pattern = r'```(json)?(.+)```'
x = re.findall(pattern, x, re.DOTALL)[-1][-1]
pattern = r'([\[\{].+[\]\}])'
x = re.findall(pattern, x, re.DOTALL)[-1]
return json.loads(x)
def self_healing_json_parser(original_json_string):