mirror of
https://github.com/MODSetter/SurfSense.git
synced 2025-09-02 10:39:13 +00:00
commit
ecf0bccbbf
3 changed files with 6 additions and 3 deletions
|
@ -1174,7 +1174,7 @@ async def handle_qna_workflow(state: State, config: RunnableConfig, writer: Stre
|
||||||
await connector_service.initialize_counter()
|
await connector_service.initialize_counter()
|
||||||
|
|
||||||
# Use the reformulated query as a single research question
|
# Use the reformulated query as a single research question
|
||||||
research_questions = [reformulated_query]
|
research_questions = [reformulated_query, user_query]
|
||||||
|
|
||||||
relevant_documents = await fetch_relevant_documents(
|
relevant_documents = await fetch_relevant_documents(
|
||||||
research_questions=research_questions,
|
research_questions=research_questions,
|
||||||
|
@ -1210,7 +1210,8 @@ async def handle_qna_workflow(state: State, config: RunnableConfig, writer: Stre
|
||||||
# Prepare configuration for the QNA agent
|
# Prepare configuration for the QNA agent
|
||||||
qna_config = {
|
qna_config = {
|
||||||
"configurable": {
|
"configurable": {
|
||||||
"user_query": reformulated_query, # Use the reformulated query
|
"user_query": user_query, # Use the reformulated query
|
||||||
|
"reformulated_query": reformulated_query,
|
||||||
"relevant_documents": all_documents, # Use combined documents
|
"relevant_documents": all_documents, # Use combined documents
|
||||||
"user_id": configuration.user_id,
|
"user_id": configuration.user_id,
|
||||||
"search_space_id": configuration.search_space_id
|
"search_space_id": configuration.search_space_id
|
||||||
|
|
|
@ -14,6 +14,7 @@ class Configuration:
|
||||||
|
|
||||||
# Configuration parameters for the Q&A agent
|
# Configuration parameters for the Q&A agent
|
||||||
user_query: str # The user's question to answer
|
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
|
relevant_documents: List[Any] # Documents provided directly to the agent for answering
|
||||||
user_id: str # User identifier
|
user_id: str # User identifier
|
||||||
search_space_id: int # Search space 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)
|
configuration = Configuration.from_runnable_config(config)
|
||||||
documents = configuration.relevant_documents
|
documents = configuration.relevant_documents
|
||||||
user_query = configuration.user_query
|
user_query = configuration.user_query
|
||||||
|
reformulated_query = configuration.reformulated_query
|
||||||
|
|
||||||
# If no documents were provided, return empty list
|
# If no documents were provided, return empty list
|
||||||
if not documents or len(documents) == 0:
|
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
|
# 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
|
# Sort by score in descending order
|
||||||
reranked_docs.sort(key=lambda x: x.get("score", 0), reverse=True)
|
reranked_docs.sort(key=lambda x: x.get("score", 0), reverse=True)
|
||||||
|
|
Loading…
Add table
Reference in a new issue