fix(indexer): handle nested interaction structure in chat logs
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user