2023-09-17 13:27:11 +08:00
|
|
|
|
# prompt模板使用Jinja2语法,简单点就是用双大括号代替f-string的单大括号
|
|
|
|
|
|
# 本配置文件支持热加载,修改prompt模板后无需重启服务。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# LLM对话支持的变量:
|
|
|
|
|
|
# - input: 用户输入内容
|
|
|
|
|
|
|
|
|
|
|
|
# 知识库和搜索引擎对话支持的变量:
|
|
|
|
|
|
# - context: 从检索结果拼接的知识文本
|
|
|
|
|
|
# - question: 用户提出的问题
|
|
|
|
|
|
|
2023-10-18 15:19:02 +08:00
|
|
|
|
# Agent对话支持的变量:
|
2023-09-17 13:27:11 +08:00
|
|
|
|
|
2023-10-18 15:19:02 +08:00
|
|
|
|
# - tools: 可用的工具列表
|
|
|
|
|
|
# - tool_names: 可用的工具名称列表
|
|
|
|
|
|
# - history: 用户和Agent的对话历史
|
|
|
|
|
|
# - input: 用户输入内容
|
|
|
|
|
|
# - agent_scratchpad: Agent的思维记录
|
2023-09-29 18:45:50 +08:00
|
|
|
|
|
2023-11-05 11:17:09 +08:00
|
|
|
|
PROMPT_TEMPLATES = {
|
|
|
|
|
|
"completion": {
|
|
|
|
|
|
"default": "{input}"
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
"llm_chat": {
|
|
|
|
|
|
"default": "{{ input }}",
|
|
|
|
|
|
|
|
|
|
|
|
"py":
|
|
|
|
|
|
"""
|
|
|
|
|
|
你是一个聪明的代码助手,请你给我写出简单的py代码。 \n
|
|
|
|
|
|
{{ input }}
|
2023-10-18 15:19:02 +08:00
|
|
|
|
"""
|
2023-11-05 11:17:09 +08:00
|
|
|
|
,
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
"knowledge_base_chat": {
|
|
|
|
|
|
"default":
|
|
|
|
|
|
"""
|
2023-10-18 15:19:02 +08:00
|
|
|
|
<指令>根据已知信息,简洁和专业的来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,不允许在答案中添加编造成分,答案请使用中文。 </指令>
|
|
|
|
|
|
<已知信息>{{ context }}</已知信息>、
|
|
|
|
|
|
<问题>{{ question }}</问题>
|
|
|
|
|
|
""",
|
2023-11-05 11:17:09 +08:00
|
|
|
|
"text":
|
|
|
|
|
|
"""
|
2023-10-18 15:19:02 +08:00
|
|
|
|
<指令>根据已知信息,简洁和专业的来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,答案请使用中文。 </指令>
|
|
|
|
|
|
<已知信息>{{ context }}</已知信息>、
|
|
|
|
|
|
<问题>{{ question }}</问题>
|
|
|
|
|
|
""",
|
2023-11-05 11:17:09 +08:00
|
|
|
|
"Empty": # 搜不到内容的时候调用,此时没有已知信息,这个Empty可以更改,但不能删除,会影响程序使用
|
|
|
|
|
|
"""
|
2023-10-27 11:52:44 +08:00
|
|
|
|
<指令>请根据用户的问题,进行简洁明了的回答</指令>
|
|
|
|
|
|
<问题>{{ question }}</问题>
|
|
|
|
|
|
""",
|
2023-11-05 11:17:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
"search_engine_chat": {
|
|
|
|
|
|
"default":
|
|
|
|
|
|
"""
|
2023-10-18 15:19:02 +08:00
|
|
|
|
<指令>这是我搜索到的互联网信息,请你根据这些信息进行提取并有调理,简洁的回答问题。如果无法从中得到答案,请说 “无法搜索到能回答问题的内容”。 </指令>
|
|
|
|
|
|
<已知信息>{{ context }}</已知信息>、
|
|
|
|
|
|
<问题>{{ question }}</问题>
|
|
|
|
|
|
""",
|
2023-11-05 11:17:09 +08:00
|
|
|
|
"search":
|
|
|
|
|
|
"""
|
2023-10-18 15:19:02 +08:00
|
|
|
|
<指令>根据已知信息,简洁和专业的来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,答案请使用中文。 </指令>
|
|
|
|
|
|
<已知信息>{{ context }}</已知信息>、
|
|
|
|
|
|
<问题>{{ question }}</问题>
|
|
|
|
|
|
""",
|
2023-11-05 11:17:09 +08:00
|
|
|
|
"Empty": # 搜不到内容的时候调用,此时没有已知信息,这个Empty可以更改,但不能删除,会影响程序使用
|
|
|
|
|
|
"""
|
2023-10-27 11:52:44 +08:00
|
|
|
|
<指令>请根据用户的问题,进行简洁明了的回答</指令>
|
|
|
|
|
|
<问题>{{ question }}</问题>
|
|
|
|
|
|
""",
|
2023-11-05 11:17:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
"agent_chat": {
|
|
|
|
|
|
"default":
|
|
|
|
|
|
"""
|
2023-10-18 15:19:02 +08:00
|
|
|
|
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:
|
|
|
|
|
|
|
|
|
|
|
|
{tools}
|
|
|
|
|
|
|
|
|
|
|
|
Please note that the "知识库查询工具" is information about the "西交利物浦大学" ,and if a question is asked about it, you must answer with the knowledge base,
|
|
|
|
|
|
Please note that the "天气查询工具" can only be used once since Question begin.
|
|
|
|
|
|
|
|
|
|
|
|
Use the following format:
|
|
|
|
|
|
Question: the input question you must answer1
|
|
|
|
|
|
Thought: you should always think about what to do and what tools to use.
|
|
|
|
|
|
Action: the action to take, should be one of [{tool_names}]
|
|
|
|
|
|
Action Input: the input to the action
|
|
|
|
|
|
Observation: the result of the action
|
|
|
|
|
|
... (this Thought/Action/Action Input/Observation can be repeated zero or more times)
|
|
|
|
|
|
Thought: I now know the final answer
|
|
|
|
|
|
Final Answer: the final answer to the original input question
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Begin!
|
|
|
|
|
|
history:
|
|
|
|
|
|
{history}
|
|
|
|
|
|
Question: {input}
|
|
|
|
|
|
Thought: {agent_scratchpad}
|
|
|
|
|
|
""",
|
2023-11-13 16:30:09 +08:00
|
|
|
|
|
|
|
|
|
|
"ChatGLM3": # ChatGLM3必须用官方的提示词,没有修改空间,目前参数都不会传入进去
|
2023-11-12 16:45:50 +08:00
|
|
|
|
"""
|
2023-10-21 22:09:53 +08:00
|
|
|
|
history:
|
|
|
|
|
|
{history}
|
|
|
|
|
|
Question: {input}
|
|
|
|
|
|
Thought: {agent_scratchpad}
|
2023-10-18 15:19:02 +08:00
|
|
|
|
""",
|
2023-11-05 11:17:09 +08:00
|
|
|
|
},
|
2023-10-18 15:19:02 +08:00
|
|
|
|
}
|