2024-01-16 15:37:47 +08:00
|
|
|
|
# prompt模板使用Jinja2语法,简单点就是用双大括号代替f-string的单大括号
|
|
|
|
|
|
# 本配置文件支持热加载,修改prompt模板后无需重启服务。
|
|
|
|
|
|
|
|
|
|
|
|
# LLM对话支持的变量:
|
|
|
|
|
|
# - input: 用户输入内容
|
|
|
|
|
|
|
|
|
|
|
|
# 知识库和搜索引擎对话支持的变量:
|
|
|
|
|
|
# - context: 从检索结果拼接的知识文本
|
|
|
|
|
|
# - question: 用户提出的问题
|
|
|
|
|
|
|
|
|
|
|
|
# Agent对话支持的变量:
|
|
|
|
|
|
|
|
|
|
|
|
# - tools: 可用的工具列表
|
|
|
|
|
|
# - tool_names: 可用的工具名称列表
|
|
|
|
|
|
# - history: 用户和Agent的对话历史
|
|
|
|
|
|
# - input: 用户输入内容
|
|
|
|
|
|
# - agent_scratchpad: Agent的思维记录
|
|
|
|
|
|
|
|
|
|
|
|
PROMPT_TEMPLATES = {
|
|
|
|
|
|
"llm_chat": {
|
|
|
|
|
|
"default":
|
|
|
|
|
|
'{{ input }}',
|
|
|
|
|
|
|
|
|
|
|
|
"with_history":
|
|
|
|
|
|
'The following is a friendly conversation between a human and an AI. '
|
|
|
|
|
|
'The AI is talkative and provides lots of specific details from its context. '
|
|
|
|
|
|
'If the AI does not know the answer to a question, it truthfully says it does not know.\n\n'
|
|
|
|
|
|
'Current conversation:\n'
|
|
|
|
|
|
'{history}\n'
|
|
|
|
|
|
'Human: {input}\n'
|
|
|
|
|
|
'AI:',
|
|
|
|
|
|
|
|
|
|
|
|
"py":
|
|
|
|
|
|
'你是一个聪明的代码助手,请你给我写出简单的py代码。 \n'
|
|
|
|
|
|
'{{ input }}',
|
2024-02-26 09:08:20 +08:00
|
|
|
|
|
|
|
|
|
|
"summary":
|
|
|
|
|
|
'针对提供的文本内容进行阅读理解和摘要,回答应该包含一段对原文的简要概述,注意需使用列表的形式突出文本的关键信息和主要观点。请确保摘要既简洁明了又准确完整,以便让读者能够快速了解原文的核心内容。 请注意你需要给出:'
|
|
|
|
|
|
'【文本简介】简要概述 '
|
|
|
|
|
|
'【文本核心内容】使用列表形式罗列关键信息 \n'
|
|
|
|
|
|
'{{ input }}',
|
2024-01-16 15:37:47 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
"knowledge_base_chat": {
|
|
|
|
|
|
"default":
|
|
|
|
|
|
'<指令>你是一个电力公司相关的专家,请完全依据已知信息的内容,先找出与问题相关的信息,然后再根据这些相关信息回答简洁、专业地来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,'
|
|
|
|
|
|
'不允许在答案中添加编造成分,不回答与问题无关的内容,答案请使用中文。 </指令>\n'
|
|
|
|
|
|
'<已知信息>{{ context }}</已知信息>\n'
|
|
|
|
|
|
'<问题>{{ question }}</问题>\n',
|
|
|
|
|
|
|
|
|
|
|
|
"text":
|
|
|
|
|
|
'<指令>根据已知信息,简洁和专业的来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,答案请使用中文。 </指令>\n'
|
|
|
|
|
|
'<已知信息>{{ context }}</已知信息>\n'
|
|
|
|
|
|
'<问题>{{ question }}</问题>\n',
|
|
|
|
|
|
|
|
|
|
|
|
"empty": # 搜不到知识库的时候使用
|
|
|
|
|
|
'请你回答我的问题:\n'
|
|
|
|
|
|
'{{ question }}\n\n',
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"search_engine_chat": {
|
|
|
|
|
|
"default":
|
|
|
|
|
|
'<指令>这是我搜索到的互联网信息,请你根据这些信息进行提取并有调理,简洁的回答问题。'
|
|
|
|
|
|
'如果无法从中得到答案,请说 “无法搜索到能回答问题的内容”。 </指令>\n'
|
|
|
|
|
|
'<已知信息>{{ context }}</已知信息>\n'
|
|
|
|
|
|
'<问题>{{ question }}</问题>\n',
|
|
|
|
|
|
|
|
|
|
|
|
"search":
|
|
|
|
|
|
'<指令>根据已知信息,简洁和专业的来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,答案请使用中文。 </指令>\n'
|
|
|
|
|
|
'<已知信息>{{ context }}</已知信息>\n'
|
|
|
|
|
|
'<问题>{{ question }}</问题>\n',
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"agent_chat": {
|
|
|
|
|
|
"default":
|
|
|
|
|
|
'Answer the following questions as best you can. If it is in order, you can use some tools appropriately. '
|
|
|
|
|
|
'You have access to the following tools:\n\n'
|
|
|
|
|
|
'{tools}\n\n'
|
|
|
|
|
|
'Use the following format:\n'
|
|
|
|
|
|
'Question: the input question you must answer1\n'
|
|
|
|
|
|
'Thought: you should always think about what to do and what tools to use.\n'
|
|
|
|
|
|
'Action: the action to take, should be one of [{tool_names}]\n'
|
|
|
|
|
|
'Action Input: the input to the action\n'
|
|
|
|
|
|
'Observation: the result of the action\n'
|
|
|
|
|
|
'... (this Thought/Action/Action Input/Observation can be repeated zero or more times)\n'
|
|
|
|
|
|
'Thought: I now know the final answer\n'
|
|
|
|
|
|
'Final Answer: the final answer to the original input question\n'
|
|
|
|
|
|
'Begin!\n\n'
|
|
|
|
|
|
'history: {history}\n\n'
|
|
|
|
|
|
'Question: {input}\n\n'
|
|
|
|
|
|
'Thought: {agent_scratchpad}\n',
|
|
|
|
|
|
|
|
|
|
|
|
"ChatGLM3":
|
|
|
|
|
|
'You can answer using the tools, or answer directly using your knowledge without using the tools. '
|
|
|
|
|
|
'Respond to the human as helpfully and accurately as possible.\n'
|
|
|
|
|
|
'You have access to the following tools:\n'
|
|
|
|
|
|
'{tools}\n'
|
|
|
|
|
|
'Use a json blob to specify a tool by providing an action key (tool name) '
|
|
|
|
|
|
'and an action_input key (tool input).\n'
|
|
|
|
|
|
'Valid "action" values: "Final Answer" or [{tool_names}]'
|
|
|
|
|
|
'Provide only ONE action per $JSON_BLOB, as shown:\n\n'
|
|
|
|
|
|
'```\n'
|
|
|
|
|
|
'{{{{\n'
|
|
|
|
|
|
' "action": $TOOL_NAME,\n'
|
|
|
|
|
|
' "action_input": $INPUT\n'
|
|
|
|
|
|
'}}}}\n'
|
|
|
|
|
|
'```\n\n'
|
|
|
|
|
|
'Follow this format:\n\n'
|
|
|
|
|
|
'Question: input question to answer\n'
|
|
|
|
|
|
'Thought: consider previous and subsequent steps\n'
|
|
|
|
|
|
'Action:\n'
|
|
|
|
|
|
'```\n'
|
|
|
|
|
|
'$JSON_BLOB\n'
|
|
|
|
|
|
'```\n'
|
|
|
|
|
|
'Observation: action result\n'
|
|
|
|
|
|
'... (repeat Thought/Action/Observation N times)\n'
|
|
|
|
|
|
'Thought: I know what to respond\n'
|
|
|
|
|
|
'Action:\n'
|
|
|
|
|
|
'```\n'
|
|
|
|
|
|
'{{{{\n'
|
|
|
|
|
|
' "action": "Final Answer",\n'
|
|
|
|
|
|
' "action_input": "Final response to human"\n'
|
|
|
|
|
|
'}}}}\n'
|
|
|
|
|
|
'Begin! Reminder to ALWAYS respond with a valid json blob of a single action. Use tools if necessary. '
|
|
|
|
|
|
'Respond directly if appropriate. Format is Action:```$JSON_BLOB```then Observation:.\n'
|
|
|
|
|
|
'history: {history}\n\n'
|
|
|
|
|
|
'Question: {input}\n\n'
|
|
|
|
|
|
'Thought: {agent_scratchpad}',
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|