fix(indexer): handle nested interaction structure in chat logs

This commit is contained in:
2025-12-27 16:00:55 +01:00
parent 3f503bb564
commit 3bb3dd06d0

View File

@@ -84,11 +84,20 @@ class HistoryIndexer:
errors += 1
continue
# We expect entry to have 'question', 'answer', 'role', 'timestamp'
if 'question' not in entry or 'answer' not in entry:
# Check for nested interaction structure (from ChatLogger)
interaction = entry.get('interaction', {})
question = interaction.get('question')
answer = interaction.get('answer')
if not question or not answer:
# Fallback for older flat logs if they exist
question = entry.get('question')
answer = entry.get('answer')
if not question or not answer:
continue
text_content = f"Q: {entry.get('question')}\nA: {entry.get('answer')}"
text_content = f"Q: {question}\nA: {answer}"
# Create a deterministic ID based on content + timestamp
# or just use loop index if file is immutable (risky)