From 280061e1fae2885c390bddb708dafd2c5892aa49 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Mon, 6 Mar 2023 23:51:31 -0600 Subject: [PATCH] Do not deduplicate search results used for chat context - Chat uses compiled form of search results, not the raw entries to provide context for chat. The compiled snipped search results themselves are unique and using multiple of them for context from the same raw note is fine if they cross the score and rank thresholds This should improve the context provided for chat - Also apply score_threshold, no deduplication to the answers API --- src/khoj/routers/api_beta.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/khoj/routers/api_beta.py b/src/khoj/routers/api_beta.py index 7d08d0da..433d24d3 100644 --- a/src/khoj/routers/api_beta.py +++ b/src/khoj/routers/api_beta.py @@ -55,7 +55,7 @@ def answer_beta(q: str): api_key = state.processor_config.conversation.openai_api_key # Collate context for GPT - result_list = search(q, n=2, r=True) + result_list = search(q, n=2, r=True, score_threshold=0, dedupe=False) collated_result = "\n\n".join([f"# {item.additional['compiled']}" for item in result_list]) logger.debug(f"Reference Context:\n{collated_result}") @@ -87,7 +87,7 @@ def chat(q: Optional[str] = None): return {"status": "ok", "response": []} # Collate context for GPT - result_list = search(q, n=2, r=True, score_threshold=0) + result_list = search(q, n=2, r=True, score_threshold=0, dedupe=False) collated_result = "\n\n".join([f"# {item.additional['compiled']}" for item in result_list]) logger.debug(f"Reference Context:\n{collated_result}")