mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-07 13:23:15 +00:00
Improve Intermediate Steps in Formulating Chat Response (#799)
# Major - Disambiguate Text output mode to disambiguate from Default data source lookup - Fix showing headings in intermediate step in generating chat response - Remove "Path" prefix from org ancestor heading in compiled entry # Minor - Fix OpenAI chat actor, director unit tests
This commit is contained in:
@@ -182,7 +182,7 @@ class OrgToEntries(TextToEntries):
|
||||
# Children nodes do not need ancestors trail as root parent node will have it
|
||||
if not entry_heading:
|
||||
ancestors_trail = " / ".join(parsed_entry.ancestors) or Path(entry_to_file_map[parsed_entry])
|
||||
heading = f"* Path: {ancestors_trail}\n{heading}" if heading else f"* Path: {ancestors_trail}."
|
||||
heading = f"* {ancestors_trail}\n{heading}" if heading else f"* {ancestors_trail}."
|
||||
|
||||
compiled = heading
|
||||
|
||||
|
||||
@@ -641,9 +641,7 @@ async def websocket_endpoint(
|
||||
)
|
||||
|
||||
if compiled_references:
|
||||
headings = "\n- " + "\n- ".join(
|
||||
set([" ".join(c.get("compiled", c).split("Path: ")[1:]).split("\n ")[0] for c in compiled_references])
|
||||
)
|
||||
headings = "\n- " + "\n- ".join(set([c.get("compiled", c).split("\n")[0] for c in compiled_references]))
|
||||
await send_status_update(f"**📜 Found Relevant Notes**: {headings}")
|
||||
|
||||
online_results: Dict = dict()
|
||||
|
||||
@@ -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]:
|
||||
|
||||
@@ -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.",
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user