mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-09 05:39:12 +00:00
Skip summarize when not triggered via slash cmd and can't summarize
Maybe better to fallback to non-summarize behavior if summarize intent is just inferred but we can't actually summarize because the single file added to conversation isn't satisfied
This commit is contained in:
@@ -154,7 +154,7 @@ def converse(
|
|||||||
completion_func(chat_response=prompts.no_online_results_found.format())
|
completion_func(chat_response=prompts.no_online_results_found.format())
|
||||||
return iter([prompts.no_online_results_found.format()])
|
return iter([prompts.no_online_results_found.format()])
|
||||||
|
|
||||||
if ConversationCommand.Online in conversation_commands or ConversationCommand.Webpage in conversation_commands:
|
if not is_none_or_empty(online_results):
|
||||||
conversation_primer = (
|
conversation_primer = (
|
||||||
f"{prompts.online_search_conversation.format(online_results=str(online_results))}\n{conversation_primer}"
|
f"{prompts.online_search_conversation.format(online_results=str(online_results))}\n{conversation_primer}"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -632,6 +632,7 @@ async def websocket_endpoint(
|
|||||||
|
|
||||||
meta_log = conversation.conversation_log
|
meta_log = conversation.conversation_log
|
||||||
is_automated_task = conversation_commands == [ConversationCommand.AutomatedTask]
|
is_automated_task = conversation_commands == [ConversationCommand.AutomatedTask]
|
||||||
|
used_slash_summarize = conversation_commands == [ConversationCommand.Summarize]
|
||||||
|
|
||||||
if conversation_commands == [ConversationCommand.Default] or is_automated_task:
|
if conversation_commands == [ConversationCommand.Default] or is_automated_task:
|
||||||
conversation_commands = await aget_relevant_information_sources(q, meta_log, is_automated_task)
|
conversation_commands = await aget_relevant_information_sources(q, meta_log, is_automated_task)
|
||||||
@@ -647,8 +648,18 @@ async def websocket_endpoint(
|
|||||||
await conversation_command_rate_limiter.update_and_check_if_valid(websocket, cmd)
|
await conversation_command_rate_limiter.update_and_check_if_valid(websocket, cmd)
|
||||||
q = q.replace(f"/{cmd.value}", "").strip()
|
q = q.replace(f"/{cmd.value}", "").strip()
|
||||||
|
|
||||||
if ConversationCommand.Summarize in conversation_commands:
|
file_filters = conversation.file_filters if conversation else []
|
||||||
file_filters = conversation.file_filters
|
# Skip trying to summarize if
|
||||||
|
if (
|
||||||
|
# summarization intent was inferred
|
||||||
|
ConversationCommand.Summarize in conversation_commands
|
||||||
|
# and not triggered via slash command
|
||||||
|
and not used_slash_summarize
|
||||||
|
# but we can't actually summarize
|
||||||
|
and len(file_filters) != 1
|
||||||
|
):
|
||||||
|
conversation_commands.remove(ConversationCommand.Summarize)
|
||||||
|
elif ConversationCommand.Summarize in conversation_commands:
|
||||||
response_log = ""
|
response_log = ""
|
||||||
if len(file_filters) == 0:
|
if len(file_filters) == 0:
|
||||||
response_log = "No files selected for summarization. Please add files using the section on the left."
|
response_log = "No files selected for summarization. Please add files using the section on the left."
|
||||||
|
|||||||
Reference in New Issue
Block a user