diff --git a/textract-pipeline/src/lambda/prompt-orchestrator/index.py b/textract-pipeline/src/lambda/prompt-orchestrator/index.py index 88fbf35..bb260e2 100644 --- a/textract-pipeline/src/lambda/prompt-orchestrator/index.py +++ b/textract-pipeline/src/lambda/prompt-orchestrator/index.py @@ -271,6 +271,8 @@ def json_parsing(response_text, context): if len(response_text.split("}", 1)) > 1: if response_text.rsplit("}", 1)[0].strip()[-1] == '"': response_text = response_text.rsplit("}", 1)[0] + "}" + elif response_text.rsplit("}", 1)[0].strip()[-1] == '}': + response_text = response_text.rsplit("}", 1)[0] else: response_text = response_text.rstrip(",") + "}"