From 7bdc9590dda040e991341d0a89777a2140293a15 Mon Sep 17 00:00:00 2001 From: Debanjum Date: Tue, 19 Nov 2024 13:49:27 -0800 Subject: [PATCH] Fix handling sources, output in chat actor when is automated task Remove unnecessary ```python prefix removal. It isn't being triggered in json deserialize path. --- src/khoj/processor/conversation/utils.py | 2 +- src/khoj/routers/helpers.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/khoj/processor/conversation/utils.py b/src/khoj/processor/conversation/utils.py index f496583b..91ba3c72 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").removeprefix("```python").removesuffix("```") + return response.strip().replace("\n", "").removeprefix("```json").removesuffix("```") def clean_code_python(code: str): diff --git a/src/khoj/routers/helpers.py b/src/khoj/routers/helpers.py index 52d67c6e..b011106e 100644 --- a/src/khoj/routers/helpers.py +++ b/src/khoj/routers/helpers.py @@ -411,7 +411,7 @@ async def aget_data_sources_and_output_format( f"Invalid response for determining relevant tools: {selected_sources}. Raw Response: {response}" ) - result: Dict = {"sources": [], "output": None} if not is_task else {"output": ConversationCommand.AutomatedTask} + result: Dict = {"sources": [], "output": None if not is_task else ConversationCommand.AutomatedTask} for selected_source in selected_sources: # Add a double check to verify it's in the agent list, because the LLM sometimes gets confused by the tool options. if (