fix: q/a agent

This commit is contained in:
DESKTOP-RTLN3BA\$punk 2025-06-05 23:52:34 -07:00
parent 284eedde20
commit f5d279ccdc
3 changed files with 6 additions and 3 deletions

View file

@ -14,6 +14,7 @@ class Configuration:
# Configuration parameters for the Q&A agent
user_query: str # The user's question to answer
reformulated_query: str # The reformulated query
relevant_documents: List[Any] # Documents provided directly to the agent for answering
user_id: str # User identifier
search_space_id: int # Search space identifier

View file

@ -26,6 +26,7 @@ async def rerank_documents(state: State, config: RunnableConfig) -> Dict[str, An
configuration = Configuration.from_runnable_config(config)
documents = configuration.relevant_documents
user_query = configuration.user_query
reformulated_query = configuration.reformulated_query
# If no documents were provided, return empty list
if not documents or len(documents) == 0:
@ -57,7 +58,7 @@ async def rerank_documents(state: State, config: RunnableConfig) -> Dict[str, An
]
# Rerank documents using the user's query
reranked_docs = reranker_service.rerank_documents(user_query, reranker_input_docs)
reranked_docs = reranker_service.rerank_documents(user_query + "\n" + reformulated_query, reranker_input_docs)
# Sort by score in descending order
reranked_docs.sort(key=lambda x: x.get("score", 0), reverse=True)