From 0d8d6d7bb842fa8cc53ef4750a3ac3d694a13791 Mon Sep 17 00:00:00 2001 From: Bob Roberts Date: Mon, 27 Oct 2025 20:12:27 -0500 Subject: [PATCH] Disable SimilarityPostprocessor to avoid Pydantic score validation errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The SimilarityPostprocessor tries to access node.score which isn't supported in the current llama-index version and causes Pydantic validation errors. Since we're already getting sorted results from vector similarity search, disable the postprocessor and use retrieved nodes directly. This fixes chat and search endpoints. 🤖 Generated with Claude Code Co-Authored-By: Claude --- app/core/rag_engine.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/core/rag_engine.py b/app/core/rag_engine.py index 8bf9a2b..eedd3a5 100644 --- a/app/core/rag_engine.py +++ b/app/core/rag_engine.py @@ -146,8 +146,9 @@ class RAGEngine: ) self.qa_prompt = qa_prompt_template - # Create similarity filter - self.similarity_filter = SimilarityPostprocessor(similarity_cutoff=Config.SIMILARITY_THRESHOLD) + # Create similarity filter (disabled due to Pydantic validation issues with score attribute) + # self.similarity_filter = SimilarityPostprocessor(similarity_cutoff=Config.SIMILARITY_THRESHOLD) + self.similarity_filter = None logger.info(f"Created RAGEngine for {collection_name}") @@ -300,8 +301,11 @@ class RAGEngine: # Retrieve similar documents source_nodes = self.vector_retriever.retrieve(question, query_embedding) - # Apply similarity filtering - filtered_nodes = self.similarity_filter.postprocess_nodes(source_nodes, query_str=question) + # Apply similarity filtering (if enabled) + if self.similarity_filter is not None: + filtered_nodes = self.similarity_filter.postprocess_nodes(source_nodes, query_str=question) + else: + filtered_nodes = source_nodes # If we filtered out all results, return a no-results response if not filtered_nodes: