From 0e7d611a803d935c1525fc430e56c7f63b1964ce Mon Sep 17 00:00:00 2001 From: Debanjum Date: Tue, 19 Nov 2024 11:25:12 -0800 Subject: [PATCH] Remove ```python codeblock prefix from raw json before deserialize --- src/khoj/processor/conversation/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/khoj/processor/conversation/utils.py b/src/khoj/processor/conversation/utils.py index 91ba3c72..f496583b 100644 --- a/src/khoj/processor/conversation/utils.py +++ b/src/khoj/processor/conversation/utils.py @@ -528,7 +528,7 @@ def reciprocal_conversation_to_chatml(message_pair): def clean_json(response: str): """Remove any markdown json codeblock and newline formatting if present. Useful for non schema enforceable models""" - return response.strip().replace("\n", "").removeprefix("```json").removesuffix("```") + return response.strip().replace("\n", "").removeprefix("```json").removeprefix("```python").removesuffix("```") def clean_code_python(code: str):