# 注意:LangChainDeprecationWarning: The class `LLMChain` was deprecated in LangChain 0.1.17 and will be removed in 1.0. Use :meth:`~RunnableSequence, e.g., `prompt | llm`` instead.from langchain.chains import LLMChain
# 支持的功能示例
chain = LLMChain(
llm=llm,
prompt=prompt,
memory=memory,# 内置记忆管理
output_key="result",# 自定义输出字段名
verbose=True,# 开启详细日志
callbacks=[handler],# 回调系统.....)
复制代码
一轮问答
prompt 构造:prompt & json output parser
from langchain.prompts import PromptTemplate
from langchain_core.output_parsers import JsonOutputParser
from langchain.agents import AgentExecutor, create_react_agent
from langchain_core.prompts import PromptTemplate
复制代码
prompt 构造
template ='''
You are an assistant that strictly adheres to the required format. All outputs must follow the specified format and should not include any additional explanations or descriptions.
Answer the following questions as best you can. You have access to the following tools:
{tools}
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 repeat N times)
Thought: I now know the final answer
Final Answer: the final answer to the original input question