mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-27 09:25:06 +01:00
Only include inferred-queries in chat history when present
This commit is contained in:
parent
149cbe1019
commit
3ea94ac972
1 changed files with 5 additions and 5 deletions
|
@ -136,9 +136,10 @@ def construct_chat_history(conversation_history: dict, n: int = 4, agent_name="A
|
|||
for chat in conversation_history.get("chat", [])[-n:]:
|
||||
if chat["by"] == "khoj" and chat["intent"].get("type") in ["remember", "reminder", "summarize"]:
|
||||
chat_history += f"User: {chat['intent']['query']}\n"
|
||||
chat_history += (
|
||||
f'Khoj: {{"queries": {chat["intent"].get("inferred-queries") or list([chat["intent"]["query"]])}}}\n'
|
||||
)
|
||||
|
||||
if chat["intent"].get("inferred-queries"):
|
||||
chat_history += f'Khoj: {{"queries": {chat["intent"].get("inferred-queries")}}}\n'
|
||||
|
||||
chat_history += f"{agent_name}: {chat['message']}\n\n"
|
||||
elif chat["by"] == "khoj" and ("text-to-image" in chat["intent"].get("type")):
|
||||
chat_history += f"User: {chat['intent']['query']}\n"
|
||||
|
@ -174,8 +175,7 @@ def construct_tool_chat_history(
|
|||
"by": "khoj",
|
||||
"intent": {
|
||||
"type": "remember",
|
||||
# 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 [],
|
||||
"inferred-queries": inferred_query_extractor(iteration),
|
||||
"query": iteration.query,
|
||||
},
|
||||
"message": iteration.summarizedResult,
|
||||
|
|
Loading…
Reference in a new issue