mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 21:19:12 +00:00
Exclude non-dictionary doc context from chat history sent to chat models
This fixes chat with old chat sessions. Fixes issue with old Whatsapp users can't chat with Khoj because chat history doc context was stored as a list earlier
This commit is contained in:
@@ -338,7 +338,11 @@ def generate_chatml_messages_with_context(
|
||||
message_context += chat.get("intent").get("inferred-queries")[0]
|
||||
if not is_none_or_empty(chat.get("context")):
|
||||
references = "\n\n".join(
|
||||
{f"# File: {item['file']}\n## {item['compiled']}\n" for item in chat.get("context") or []}
|
||||
{
|
||||
f"# File: {item['file']}\n## {item['compiled']}\n"
|
||||
for item in chat.get("context") or []
|
||||
if isinstance(item, dict)
|
||||
}
|
||||
)
|
||||
message_context += f"{prompts.notes_conversation.format(references=references)}\n\n"
|
||||
if not is_none_or_empty(chat.get("onlineContext")):
|
||||
|
||||
Reference in New Issue
Block a user