mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-08 23:32:40 +02:00
fix: q/a agent
This commit is contained in:
parent
284eedde20
commit
f5d279ccdc
3 changed files with 6 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue