Langchain中的LLM和LLMChain的输入和输出形式根据调用形式完全不同,此处进行整理一下。
1 LLM
input:
- PromptTemplate.from_template()
output:
- 1 invoke() – 输入为字典,输出为BaseMessage
- 2 stream() – 输入为字典,输出为Iter(BaseMessage)
2 LLMChain
input :
- ChatPromptTemplate.from_messages()
output:
- 1 __call__() — input为字典,output为字典
- 2 .run() — input为字典,output为str
- 3 .predict() — input为关键字参数形式,output为str
- 4 .invoke() — 未来的主流形式,和\__call\__()基本一致,input为字典,output为字典
- 5 .apply() || .generate() — 针对input_list
- 5.1 .apply() — 返回字符串
- 5.2 .generate() — 返回LLMResult对象