diff --git a/configs/prompt_config.py.example b/configs/prompt_config.py.example index bb53b858..6446ce2e 100644 --- a/configs/prompt_config.py.example +++ b/configs/prompt_config.py.example @@ -47,3 +47,60 @@ PROMPT_TEMPLATES = { Thought: {agent_scratchpad} """ } + + +## GPT或Qwen 的Prompt +# """ +# Answer the following questions as best you can. 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 +# +# Use the following format: +# +# Question: the input question you must answer +# Thought: you should always think about what to do +# 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-Pro的Prompt + +# """ +# 请请严格按照提供的思维方式来思考。你的知识不一定正确,所以你一定要用提供的工具来思考,并给出用户答案。 +# 你有以下工具可以使用: +# {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} +# +# """ diff --git a/img/agent_continue.png b/img/agent_continue.png new file mode 100644 index 00000000..be02fd7d Binary files /dev/null and b/img/agent_continue.png differ diff --git a/img/agent_success.png b/img/agent_success.png new file mode 100644 index 00000000..5c2e3104 Binary files /dev/null and b/img/agent_success.png differ diff --git a/server/agent/custom_template.py b/server/agent/custom_template.py index db2d8ad7..aaa2bfe4 100644 --- a/server/agent/custom_template.py +++ b/server/agent/custom_template.py @@ -52,13 +52,9 @@ class CustomOutputParser(AgentOutputParser): llm_output = llm_output[:min_index] if "Final Answer:" in llm_output: - output = llm_output.split("Final Answer:", 1)[-1].strip() self.begin = True return AgentFinish( - # Return values is generally always a dictionary with a single `output` key - # It is not recommended to try anything else at the moment :) - # return_values={"output": llm_output.replace("Final Answer:", "").strip()}, - return_values={"output": output}, + return_values={"output": llm_output.split("Final Answer:", 1)[-1].strip()}, log=llm_output, ) diff --git a/server/agent/weather.py b/server/agent/weather.py index 54f196cf..ad06d28c 100644 --- a/server/agent/weather.py +++ b/server/agent/weather.py @@ -34,6 +34,7 @@ from langchain.prompts import PromptTemplate ## 使用和风天气API查询天气 KEY = "ac880e5a877042809ac7ffdd19d95b0d" +#key长这样,这里提供了示例的key,这个key没法使用,你需要自己去注册和风天气的账号,然后在这里填入你的key