mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-05-19 16:20:05 +02:00
58 lines
1.7 KiB
Python
58 lines
1.7 KiB
Python
from onyx.prompts.constants import GENERAL_SEP_PAT
|
|
|
|
DONT_USE_TOOL = "Don't use tool"
|
|
USE_TOOL = "Use tool"
|
|
|
|
|
|
"""Prompts to determine if we should use a custom tool or not."""
|
|
|
|
|
|
SHOULD_USE_CUSTOM_TOOL_SYSTEM_PROMPT = (
|
|
"You are a large language model whose only job is to determine if the system should call an "
|
|
"external tool to be able to answer the user's last message."
|
|
).strip()
|
|
|
|
SHOULD_USE_CUSTOM_TOOL_USER_PROMPT = f"""
|
|
Given the conversation history and a follow up query, determine if the system should use the \
|
|
'{{tool_name}}' tool to answer the user's query. The '{{tool_name}}' tool is a tool defined as: '{{tool_description}}'.
|
|
|
|
Respond with "{USE_TOOL}" if you think the tool would be helpful in respnding to the users query.
|
|
Respond with "{DONT_USE_TOOL}" otherwise.
|
|
|
|
Conversation History:
|
|
{GENERAL_SEP_PAT}
|
|
{{history}}
|
|
{GENERAL_SEP_PAT}
|
|
|
|
If you are at all unsure, respond with {DONT_USE_TOOL}.
|
|
Respond with EXACTLY and ONLY "{DONT_USE_TOOL}" or "{USE_TOOL}"
|
|
|
|
Follow up input:
|
|
{{query}}
|
|
""".strip()
|
|
|
|
|
|
"""Prompts to figure out the arguments to pass to a custom tool."""
|
|
|
|
|
|
TOOL_ARG_SYSTEM_PROMPT = (
|
|
"You are a large language model whose only job is to determine the arguments to pass to an "
|
|
"external tool."
|
|
).strip()
|
|
|
|
|
|
TOOL_ARG_USER_PROMPT = f"""
|
|
Given the following conversation and a follow up input, generate a \
|
|
dictionary of arguments to pass to the '{{tool_name}}' tool. \
|
|
The '{{tool_name}}' tool is a tool defined as: '{{tool_description}}'. \
|
|
The expected arguments are: {{tool_args}}.
|
|
|
|
Conversation:
|
|
{{history}}
|
|
|
|
Follow up input:
|
|
{{query}}
|
|
|
|
Respond with ONLY and EXACTLY a JSON object specifying the values of the arguments to pass to the tool.
|
|
""".strip() # noqa: F541
|