""" LangChain 1.0 - 自定义工具 (@tool 装饰器) ========================================= 本模块重点讲解: 1. 使用 @tool 装饰器创建工具(LangChain 1.0 推荐方式) 2. 工具...
大模型技术
技术
# 04 - Custom Tools (自定义工具) # 核心概念 # 工具 (Tool) = 给 AI 的函数 # 使用 @tool 装饰器,让 AI 能调用你的 Python 函数。 # @tool 基本用法 import json from turtle import st from ...
04 - Custom Tools (自定义工具)核心概念工具 (Tool) = 给 AI 的函数使用 @tool 装饰器,让 AI 能调用你的 Python 函数。@tool 基本用法from langchain_core.tools import tool @tool def get_weat...
# 03 - Messages: 消息类型与对话管理 # 核心要点(只讲难点) # 初始化模型 from init_model import get_chat_model chat_model = get_chat_model() # 角色 字典格式 对象格式 用途 # Sys...
03 - Messages: 消息类型与对话管理核心要点(只讲难点)1. 三种消息类型角色字典格式对象格式用途System{"role": "system", ...}SystemMessage(...)系统提示User{"role": &...
""" LangChain 1.0 基础教程 - 提示词模板 (Prompt Templates) ======================================================== 本文件演示如何使用 LangChain 的提示词模板系...
# =================================== # 学习目标 # =================================== # 通过本模块,你将学习: # 1. 为什么需要提示词模板 # 字符串拼接的问题 # 模板的优势 # 2.PromptTempla...
02 - Prompt Templates: 提示词模板学习目标通过本模块,你将学习:为什么需要提示词模板字符串拼接的问题模板的优势PromptTemplate基本用法变量替换格式化方法ChatPromptTemplate聊天消息模板多角色支持对话历史管理高级特性部分变量模板组合可复用模板库LCEL...
# 2. invoke 方法 - 调用模型(深入详解) # invoke 是 LangChain 中最核心的方法,用于同步调用 LLM 模型。理解 invoke 是学习 LangChain 的关键。 # 🎯 invoke 方法做什么? # 简单来说,invoke 方法的作用就是: # 接收你的输入...
""" LangChain 1.0 基础教程 - 第一个 LLM 调用 ========================================== 本文件演示如何使用 LangChain 1.0 进行基本的 LLM 调用 涵盖以下核心概念: 1. init_...