Remove conversation command always in query, filter out inferred queries that were not with selected tool when going through tool selection iterations

This commit is contained in:
sabaimran 2024-10-31 20:27:38 -07:00
parent 19241805ee
commit 21858acccc
2 changed files with 6 additions and 5 deletions

View file

@ -174,7 +174,8 @@ def construct_tool_chat_history(
"by": "khoj", "by": "khoj",
"intent": { "intent": {
"type": "remember", "type": "remember",
"inferred-queries": inferred_query_extractor(iteration), # Only include inferred-queries for the specific tool that's being used in this iteration.
"inferred-queries": inferred_query_extractor(iteration) if iteration.tool == tool else [],
"query": iteration.query, "query": iteration.query,
}, },
"message": iteration.summarizedResult, "message": iteration.summarizedResult,

View file

@ -738,6 +738,10 @@ async def chat(
if mode not in conversation_commands: if mode not in conversation_commands:
conversation_commands.append(mode) conversation_commands.append(mode)
for cmd in conversation_commands:
await conversation_command_rate_limiter.update_and_check_if_valid(request, cmd)
q = q.replace(f"/{cmd.value}", "").strip()
if conversation_commands == [ConversationCommand.Research]: if conversation_commands == [ConversationCommand.Research]:
async for research_result in execute_information_collection( async for research_result in execute_information_collection(
request=request, request=request,
@ -774,10 +778,6 @@ async def chat(
pending_research = False pending_research = False
for cmd in conversation_commands:
await conversation_command_rate_limiter.update_and_check_if_valid(request, cmd)
q = q.replace(f"/{cmd.value}", "").strip()
used_slash_summarize = conversation_commands == [ConversationCommand.Summarize] used_slash_summarize = conversation_commands == [ConversationCommand.Summarize]
file_filters = conversation.file_filters if conversation else [] file_filters = conversation.file_filters if conversation else []
# Skip trying to summarize if # Skip trying to summarize if