From f28fb89af8a592ca222d9305936235637f8d8c41 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Mon, 11 Mar 2024 13:03:02 +0530 Subject: [PATCH] Use consistent agent name across static and dynamic examples in prompts Previously the examples constructed from chat history used "Khoj" as the agent's name but all 3 prompts using the func used static examples with "AI:" as the pertinent agent's name --- src/khoj/routers/helpers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/khoj/routers/helpers.py b/src/khoj/routers/helpers.py index 85cf9a55..f83bc3f2 100644 --- a/src/khoj/routers/helpers.py +++ b/src/khoj/routers/helpers.py @@ -112,15 +112,15 @@ def update_telemetry_state( ] -def construct_chat_history(conversation_history: dict, n: int = 4) -> str: +def construct_chat_history(conversation_history: dict, n: int = 4, agent_name="AI") -> str: chat_history = "" for chat in conversation_history.get("chat", [])[-n:]: if chat["by"] == "khoj" and chat["intent"].get("type") == "remember": chat_history += f"User: {chat['intent']['query']}\n" - chat_history += f"Khoj: {chat['message']}\n" + chat_history += f"{agent_name}: {chat['message']}\n" elif chat["by"] == "khoj" and ("text-to-image" in chat["intent"].get("type")): chat_history += f"User: {chat['intent']['query']}\n" - chat_history += f"Khoj: [generated image redacted for space]\n" + chat_history += f"{agent_name}: [generated image redacted for space]\n" return chat_history