diff --git a/assets/ar/QA/MultiNativQA_GPT4_ZeroShot.py b/assets/ar/QA/MultiNativQA_GPT4_ZeroShot.py index e0f382dc..de108dbf 100644 --- a/assets/ar/QA/MultiNativQA_GPT4_ZeroShot.py +++ b/assets/ar/QA/MultiNativQA_GPT4_ZeroShot.py @@ -41,4 +41,11 @@ def prompt(input_sample): def post_process(response): - return response["choices"][0]["message"]["content"] + content = response["choices"][0]["message"]["content"].strip() + content = content.replace("\n", "").strip() + if "```json" in content: + # content = content.replace("```json", "").replace('```', '').replace("\n}", "}") + # content = content.replace("{\n", "{").replace("\",\n", "\",") + + content = re.search(r"```json(.*)```", content).group(1) + return json.loads(content)["answer"]