AI LangChain 学习第 2 课 – 提示词模板(Prompt Template)
本节课会学到: PromptTemplate:纯文本模板(传统"补全式"模型风格,也适合拼长文本); ChatPromptTemplate:聊天消息模板,支持 system / human 多角色(最常用); FewShotChatMessagePromptTemplate:少样本示例,用几个例子"教"模型按格式输出; 模板本身不会调用模型,它只负责"拼提示词",拼好后再交给 LLM。 """ 02 提示词模板(Prompt Template)—— LangChain 学习第 2 课 ========================================================== 本节课你会学到: 1. PromptTemplate:纯文本模板(传统"补全式"模型风格,也适合拼长文本); 2. ChatPromptTemplate:聊天消息模板,支持 system / human 多角色(最常用); 3. FewShotChatMessagePromptTe…
AI LangChain 学习第 1 课 – 模型基本调用
本节课会学到: ChatModel(聊天模型)是 LangChain 最核心的抽象,与具体厂商无关; 模型的三种调用方式:invoke(单次)、stream(流式)、batch(批量); 消息(Message)的四种角色:System / Human / AI / Tool; 返回结果 AIMessage 的结构(内容、token 用量等)。 """ 01 模型基本调用 —— LangChain 学习第 1 课 ========================================== 本节课你会学到: 1. ChatModel(聊天模型)是 LangChain 最核心的抽象,与具体厂商无关; 2. 模型的三种调用方式:invoke(单次)、stream(流式)、batch(批量); 3. 消息(Message)的四种角色:System / Human / AI / Tool; 4. 返回结果 AIMessage 的结构(内容、token 用量等)。 运行方式(在项目根目录下): .venv\\Scripts\\python examples\\…