mirror of
https://github.com/RYDE-WORK/Langchain-Chatchat.git
synced 2026-01-27 09:13:25 +08:00
## 🛠 新增功能 - 支持百川在线模型 (@hzg0601 @liunux4odoo in #1623) - 支持 Azure OpenAI 与 claude 等 Langchain 自带模型 (@zRzRzRzRzRzRzR in #1808) - Agent 功能大量更新,支持更多的工具、更换提示词、检索知识库 (@zRzRzRzRzRzRzR in #1626 #1666 #1785) - 加长 32k 模型的历史记录 (@zRzRzRzRzRzRzR in #1629 #1630) - *_chat 接口支持 max_tokens 参数 (@liunux4odoo in #1744) - 实现 API 和 WebUI 的前后端分离 (@liunux4odoo in #1772) - 支持 zlilliz 向量库 (@zRzRzRzRzRzRzR in #1785) - 支持 metaphor 搜索引擎 (@liunux4odoo in #1792) - 支持 p-tuning 模型 (@hzg0601 in #1810) - 更新完善文档和 Wiki (@imClumsyPanda @zRzRzRzRzRzRzR @glide-the in #1680 #1811) ## 🐞 问题修复 - 修复 bge-* 模型匹配超过 1 的问题 (@zRzRzRzRzRzRzR in #1652) - 修复系统代理为空的问题 (@glide-the in #1654) - 修复重建知识库时 `d == self.d assert error` (@liunux4odoo in #1766) - 修复对话历史消息错误 (@liunux4odoo in #1801) - 修复 OpenAI 无法调用的 bug (@zRzRzRzRzRzRzR in #1808) - 修复 windows下 BIND_HOST=0.0.0.0 时对话出错的问题 (@hzg0601 in #1810)
115 lines
4.5 KiB
Plaintext
115 lines
4.5 KiB
Plaintext
# prompt模板使用Jinja2语法,简单点就是用双大括号代替f-string的单大括号
|
||
# 本配置文件支持热加载,修改prompt模板后无需重启服务。
|
||
|
||
|
||
# LLM对话支持的变量:
|
||
# - input: 用户输入内容
|
||
|
||
# 知识库和搜索引擎对话支持的变量:
|
||
# - context: 从检索结果拼接的知识文本
|
||
# - question: 用户提出的问题
|
||
|
||
# Agent对话支持的变量:
|
||
|
||
# - tools: 可用的工具列表
|
||
# - tool_names: 可用的工具名称列表
|
||
# - history: 用户和Agent的对话历史
|
||
# - input: 用户输入内容
|
||
# - agent_scratchpad: Agent的思维记录
|
||
|
||
PROMPT_TEMPLATES = {}
|
||
|
||
PROMPT_TEMPLATES["llm_chat"] = {
|
||
"default": "{{ input }}",
|
||
|
||
"py":
|
||
"""
|
||
你是一个聪明的代码助手,请你给我写出简单的py代码。 \n
|
||
{{ input }}
|
||
"""
|
||
,
|
||
}
|
||
|
||
PROMPT_TEMPLATES["knowledge_base_chat"] = {
|
||
"default":
|
||
"""
|
||
<指令>根据已知信息,简洁和专业的来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,不允许在答案中添加编造成分,答案请使用中文。 </指令>
|
||
<已知信息>{{ context }}</已知信息>、
|
||
<问题>{{ question }}</问题>
|
||
""",
|
||
"text":
|
||
"""
|
||
<指令>根据已知信息,简洁和专业的来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,答案请使用中文。 </指令>
|
||
<已知信息>{{ context }}</已知信息>、
|
||
<问题>{{ question }}</问题>
|
||
""",
|
||
}
|
||
PROMPT_TEMPLATES["search_engine_chat"] = {
|
||
"default":
|
||
"""
|
||
<指令>这是我搜索到的互联网信息,请你根据这些信息进行提取并有调理,简洁的回答问题。如果无法从中得到答案,请说 “无法搜索到能回答问题的内容”。 </指令>
|
||
<已知信息>{{ context }}</已知信息>、
|
||
<问题>{{ question }}</问题>
|
||
""",
|
||
|
||
"search":
|
||
"""
|
||
<指令>根据已知信息,简洁和专业的来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,答案请使用中文。 </指令>
|
||
<已知信息>{{ context }}</已知信息>、
|
||
<问题>{{ question }}</问题>
|
||
""",
|
||
}
|
||
PROMPT_TEMPLATES["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:
|
||
|
||
{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}
|
||
""",
|
||
"ChatGLM":
|
||
"""
|
||
请请严格按照提供的思维方式来思考。你的知识不一定正确,所以你一定要用提供的工具来思考,并给出用户答案。
|
||
你有以下工具可以使用:
|
||
{tools}
|
||
```
|
||
Question: 用户的提问或者观察到的信息,
|
||
Thought: 你应该思考该做什么,是根据工具的结果来回答问题,还是决定使用什么工具。
|
||
Action: 需要使用的工具,应该是在[{tool_names}]中的一个。
|
||
Action Input: 传入工具的内容
|
||
Observation: 工具给出的答案(不是你生成的)
|
||
... (this Thought/Action/Action Input/Observation can be repeated zero or more times)
|
||
Thought: 通过工具给出的答案,你是否能回答Question。
|
||
Final Answer是你的答案
|
||
|
||
现在,我们开始!
|
||
你和用户的历史记录:
|
||
History:
|
||
{history}
|
||
|
||
用户开始以提问:
|
||
Question: {input}
|
||
Thought: {agent_scratchpad}
|
||
|
||
""",
|
||
}
|