1. LLMChain(基础单链)
| 功能 | 通过 PromptTemplate + LLM,完成一次性任务,如问答、改写、总结等 |
| 使用场景 | 单轮问答、Prompt 调试 |
| 特点 | 输入简单参数,输出 LLM 结果 |
示例:
python 复制编辑 from langchain.prompts import PromptTemplate from langchain.chains import LLMChain from langchain.chat_models import ChatOpenAI prompt = PromptTemplate.from_template("Translate this to French: {text}") llm = ChatOpenAI() chain = LLMChain(prompt=prompt, llm=llm) print(chain.run("I love programming."))