diff --git a/api/app/core/rag/nlp/search.py b/api/app/core/rag/nlp/search.py index 774c7036..572f2e3c 100644 --- a/api/app/core/rag/nlp/search.py +++ b/api/app/core/rag/nlp/search.py @@ -28,7 +28,9 @@ from app.core.rag.common.float_utils import get_float from app.core.rag.common.constants import PAGERANK_FLD, TAG_FLD from app.core.rag.llm.chat_model import Base from app.core.rag.llm.embedding_model import OpenAIEmbed +import logging +logger = logging.getLogger(__name__) def knowledge_retrieval( query: str, @@ -171,10 +173,16 @@ def knowledge_retrieval( return rerank(db=db, reranker_id=reranker_id, query=query, docs=all_results, top_k=reranker_top_k) except Exception as rerank_error: # If reranker fails, log warning and continue with original results - print(f"Failed to rerank documents: {str(rerank_error)}") - print(f"Continuing with original retrieval results (count: {len(all_results)})") - - # use graph + logger.warning( + "Reranker failed, falling back to original results", + extra={ + "reranker_id": reranker_id, + "query": query, + "doc_count": len(all_results), + "error": str(e), + }, + ) + if use_graph: try: from app.core.rag.common.settings import kg_retriever