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
This commit is contained in:
Debanjum Singh Solanky 2023-03-06 23:51:31 -06:00
parent 672f61529e
commit 280061e1fa

View file

@ -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}")