mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 15:38:55 +01: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:
parent
d892ab3174
commit
8ef7892c5e
1 changed files with 5 additions and 1 deletions
|
@ -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")):
|
||||
|
|
Loading…
Reference in a new issue