Fix TextNode score validation - pass score during initialization

Instead of setting node.score after creation (which fails Pydantic validation),
pass the score parameter during TextNode initialization. This ensures the score
field is properly validated during object creation.

This fixes the error: 'Object has no attribute score' in chat and search endpoints.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Bob Roberts 2025-10-27 20:11:21 -05:00
parent c1c8dc4da0
commit 2a0f07f951

View file

@ -61,9 +61,9 @@ class SimpleVectorRetriever:
node = TextNode(
text=content,
id_=doc_id,
metadata=metadata
metadata=metadata,
score=similarity # Pass score during initialization for Pydantic validation
)
node.score = similarity
nodes.append(node)
return nodes