mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-10 05:39:11 +00:00
Do not add "Notes:" suffix to chat messages when no notes retrieved
This was causing spurious "Notes:" suffix being added to Khoj Chat in response
This commit is contained in:
@@ -72,7 +72,11 @@ def generate_chatml_messages_with_context(
|
|||||||
):
|
):
|
||||||
"""Generate messages for ChatGPT with context from previous conversation"""
|
"""Generate messages for ChatGPT with context from previous conversation"""
|
||||||
# Extract Chat History for Context
|
# Extract Chat History for Context
|
||||||
chat_logs = [f'{chat["message"]}\n\nNotes:\n{chat.get("context","")}' for chat in conversation_log.get("chat", [])]
|
chat_logs = []
|
||||||
|
for chat in conversation_log.get("chat", []):
|
||||||
|
chat_notes = f'\n\n Notes:\n{chat.get("context")}' if chat.get("context") else "\n"
|
||||||
|
chat_logs += [chat["message"] + chat_notes]
|
||||||
|
|
||||||
rest_backnforths = []
|
rest_backnforths = []
|
||||||
# Extract in reverse chronological order
|
# Extract in reverse chronological order
|
||||||
for user_msg, assistant_msg in zip(chat_logs[-2::-2], chat_logs[::-2]):
|
for user_msg, assistant_msg in zip(chat_logs[-2::-2], chat_logs[::-2]):
|
||||||
|
|||||||
Reference in New Issue
Block a user