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
This commit is contained in:
Debanjum Singh Solanky
2024-06-06 11:56:48 +05:30
parent a1e4f4bde7
commit dd2225b1aa
2 changed files with 6 additions and 5 deletions

View File

@@ -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]:

View File

@@ -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.",
}