From de6e9d80faa73630f45f2f134c117f9c5c0f3326 Mon Sep 17 00:00:00 2001 From: Mayank Aamseek Date: Mon, 17 Jun 2024 13:47:30 +0000 Subject: [PATCH] }} issue in prompt output fixed using post-processing --- textract-pipeline/src/lambda/prompt-orchestrator/index.py | 2 ++ 1 file changed, 2 insertions(+) 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(",") + "}"