mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-04-07 19:38:19 +02:00
Search more frequently (#834)
This commit is contained in:
parent
9d296b623b
commit
edfc849652
@ -10,10 +10,9 @@ prompts:
|
||||
You are a question answering system that is constantly learning and improving.
|
||||
|
||||
You can process and comprehend vast amounts of text and utilize this knowledge to provide
|
||||
grounded and accurate answers to diverse queries.
|
||||
grounded, accurate, and concise answers to diverse queries.
|
||||
|
||||
You clearly communicate ANY UNCERTAINTY in your answer.
|
||||
If you don't know the answer, just say that you don't know, don't try to make up an answer.
|
||||
You always clearly communicate ANY UNCERTAINTY in your answer.
|
||||
# Task Prompt (as shown in UI)
|
||||
task: >
|
||||
Answer my query based on the documents provided.
|
||||
|
@ -48,6 +48,27 @@ CHAT_USER_CONTEXT_FREE_PROMPT = f"""
|
||||
# consider doing COT for this and keep it brief, but likely only small gains.
|
||||
SKIP_SEARCH = "Skip Search"
|
||||
YES_SEARCH = "Yes Search"
|
||||
AGGRESSIVE_SEARCH_TEMPLATE = f"""
|
||||
Given the conversation history and a follow up query, determine if the system should call \
|
||||
an external search tool to better answer the latest user input.
|
||||
|
||||
Respond "{SKIP_SEARCH}" if either:
|
||||
- There is sufficient information in chat history to FULLY and ACCURATELY answer the query AND \
|
||||
additional information or details would provide little or no value.
|
||||
- The query is some form of request that does not require additional information to handle.
|
||||
|
||||
Conversation History:
|
||||
{GENERAL_SEP_PAT}
|
||||
{{chat_history}}
|
||||
{GENERAL_SEP_PAT}
|
||||
|
||||
If you are unsure, respond with {YES_SEARCH}.
|
||||
Respond with EXACTLY and ONLY "{YES_SEARCH}" or "{SKIP_SEARCH}"
|
||||
|
||||
Follow Up Input:
|
||||
{{final_query}}
|
||||
""".strip()
|
||||
|
||||
REQUIRE_SEARCH_SINGLE_MSG = f"""
|
||||
Given the conversation history and a follow up query, determine if the system should call \
|
||||
an external search tool to better answer the latest user input.
|
||||
@ -97,27 +118,7 @@ Standalone question (Respond with only the short combined query):
|
||||
""".strip()
|
||||
|
||||
|
||||
# NOTE: THE PROMPTS BELOW ARE RETIRED
|
||||
AGGRESSIVE_SEARCH_TEMPLATE = f"""
|
||||
Given the conversation history and a follow up query, determine if the system should call \
|
||||
an external search tool to better answer the latest user input.
|
||||
|
||||
Respond "{SKIP_SEARCH}" if:
|
||||
- There is sufficient information in chat history to FULLY and ACCURATELY answer the query.
|
||||
- Additional information or details would provide little or no value.
|
||||
- The query is some form of request that does not require additional information to handle.
|
||||
|
||||
{GENERAL_SEP_PAT}
|
||||
Conversation History:
|
||||
{{chat_history}}
|
||||
{GENERAL_SEP_PAT}
|
||||
|
||||
Respond with EXACTLY and ONLY "{YES_SEARCH}" or "{SKIP_SEARCH}"
|
||||
|
||||
Follow Up Input:
|
||||
{{final_query}}
|
||||
"""
|
||||
|
||||
# The below prompts are retired
|
||||
NO_SEARCH = "No Search"
|
||||
REQUIRE_SEARCH_SYSTEM_MSG = f"""
|
||||
You are a large language model whose only job is to determine if the system should call an \
|
||||
|
@ -9,9 +9,9 @@ from danswer.llm.factory import get_default_llm
|
||||
from danswer.llm.interfaces import LLM
|
||||
from danswer.llm.utils import dict_based_prompt_to_langchain_prompt
|
||||
from danswer.llm.utils import translate_danswer_msg_to_langchain
|
||||
from danswer.prompts.chat_prompts import AGGRESSIVE_SEARCH_TEMPLATE
|
||||
from danswer.prompts.chat_prompts import NO_SEARCH
|
||||
from danswer.prompts.chat_prompts import REQUIRE_SEARCH_HINT
|
||||
from danswer.prompts.chat_prompts import REQUIRE_SEARCH_SINGLE_MSG
|
||||
from danswer.prompts.chat_prompts import REQUIRE_SEARCH_SYSTEM_MSG
|
||||
from danswer.prompts.chat_prompts import SKIP_SEARCH
|
||||
from danswer.utils.logger import setup_logger
|
||||
@ -57,9 +57,9 @@ def check_if_need_search(
|
||||
messages = [
|
||||
{
|
||||
"role": "user",
|
||||
"content": REQUIRE_SEARCH_SINGLE_MSG.format(
|
||||
"content": AGGRESSIVE_SEARCH_TEMPLATE.format(
|
||||
final_query=question, chat_history=history_str
|
||||
),
|
||||
).strip(),
|
||||
},
|
||||
]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user