Skip to content

Commit

Permalink
Use Text output mode to disambiguate from Default data source lookup
Browse files Browse the repository at this point in the history
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
  • Loading branch information
debanjum committed Jun 6, 2024
1 parent a1e4f4b commit dd2225b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/khoj/routers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
3 changes: 2 additions & 1 deletion src/khoj/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ class ConversationCommand(str, Enum):
Online = "online"
Webpage = "webpage"
Image = "image"
Text = "text"
Automation = "automation"
AutomatedTask = "automated_task"

Expand All @@ -330,7 +331,7 @@ class ConversationCommand(str, Enum):
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.",
}


Expand Down

0 comments on commit dd2225b

Please sign in to comment.