From dd2225b1aa86097624c9ca2eb6436c4ac6790085 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Thu, 6 Jun 2024 11:56:48 +0530 Subject: [PATCH] Use Text output mode to disambiguate from Default data source lookup Previously if default output was selected by Khoj, we'd end up doing an documents search as well, even when Khoj selected internet or general data source to lookup. This update disambiguates the default information mode from the text output mode. To avoid doing documents search when not deemed necessary by Khoj --- src/khoj/routers/helpers.py | 8 ++++---- src/khoj/utils/helpers.py | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/khoj/routers/helpers.py b/src/khoj/routers/helpers.py index 6af8b9d0..f144044e 100644 --- a/src/khoj/routers/helpers.py +++ b/src/khoj/routers/helpers.py @@ -287,16 +287,16 @@ async def aget_relevant_output_modes(query: str, conversation_history: dict, is_ response = response.strip() if is_none_or_empty(response): - return ConversationCommand.Default + return ConversationCommand.Text if response in mode_options.keys(): # Check whether the tool exists as a valid ConversationCommand return ConversationCommand(response) - return ConversationCommand.Default - except Exception as e: + return ConversationCommand.Text + except Exception: logger.error(f"Invalid response for determining relevant mode: {response}") - return ConversationCommand.Default + return ConversationCommand.Text async def infer_webpage_urls(q: str, conversation_history: dict, location_data: LocationData) -> List[str]: diff --git a/src/khoj/utils/helpers.py b/src/khoj/utils/helpers.py index 48be715b..fd44ba85 100644 --- a/src/khoj/utils/helpers.py +++ b/src/khoj/utils/helpers.py @@ -304,6 +304,7 @@ class ConversationCommand(str, Enum): Online = "online" Webpage = "webpage" Image = "image" + Text = "text" Automation = "automation" AutomatedTask = "automated_task" @@ -330,7 +331,7 @@ tool_descriptions_for_llm = { mode_descriptions_for_llm = { ConversationCommand.Image: "Use this if the user is requesting an image or visual response to their query.", ConversationCommand.Automation: "Use this if the user is requesting a response at a scheduled date or time.", - ConversationCommand.Default: "Use this if the other response modes don't seem to fit the query.", + ConversationCommand.Text: "Use this if the other response modes don't seem to fit the query.", }