当前位置: 首页 > news >正文

(LangGraph教程)0. Welcome to the course!

https://academy.langchain.com/courses/intro-to-langgraph

https://github.com/shangxiang0907/langchain-academy

https://github.com/shangxiang0907/langchain-academy/blob/main/module-0/basics.ipynb

文章目录

  • Getting Set Up
    • Introduction
    • Setup
      • Python version
      • Clone repo
      • Create an environment and install dependencies
      • Running notebooks
      • Sign up for LangSmith
      • Set up OpenAI API key
      • Tavily for web search
      • Set up LangSmith Studio
      • Note: LangSmith Studio was formerly LangGraph Studio
    • Slack Community
  • Module 0 Resources
      • Getting Set Up (Video Guide)

Getting Set Up

中文:环境设置

Introduction

中文:简介

Welcome to LangChain Academy’s Introduction to LangGraph course!

欢迎来到 LangChain Academy 的 LangGraph 入门课程!

This course is divided into six modules, starting with the basics and gradually progressing to more advanced topics.

本课程分为六个模块,从基础知识开始,逐步深入到更高级的主题。

Each module includes video lessons to walk you through key concepts, along with corresponding notebooks.

每个模块都包含讲解关键概念的视频课程,以及与之对应的笔记本。

You’ll also find astudiosubdirectory in each module, featuring a set of relevant graphs that we’ll explore using the LangGraph API and Studio.

每个模块中还包含一个studio子目录,其中提供了一组相关的图;我们将使用 LangGraph API 和 Studio 对它们进行探索。


Setup

中文:设置

Here’s our recommended setup to get started with the course.

下面是我们建议的课程入门设置。

We’ll be using the set of notebooks located here.

我们将使用位于此处的一组笔记本。

If you prefer to download the notebooks manually, you can access a ZIP file here.

如果你希望手动下载这些笔记本,可以在此处获取 ZIP 文件。

Each module will also include links to the corresponding notebooks, with additional options to access them in Google Colab for a quick start.

每个模块还会提供相应笔记本的链接,并额外提供在 Google Colab 中打开的选项,方便你快速开始。

Python version

中文:Python 版本

Please make sure you’re using a Python version higher than 3.11 but lower than 3.14, specifically 3.11, 3.12, or 3.13.

请确保你使用的 Python 版本高于 3.11 且低于 3.14,具体可使用 3.11、3.12 或 3.13。

python3 --version

Clone repo

中文:克隆代码仓库

git clone https://github.com/langchain-ai/langchain-academy.git $ cd langchain-academy

Create an environment and install dependencies

中文:创建环境并安装依赖项

$ python3 -m venv lc-academy-env $ source lc-academy-env/bin/activate $ pip install -r requirements.txt

我ubuntu里装的是python3.14,用uv先装python3.13,不会影响默认的

uv pythoninstall3.13


然后把上面命令改成用:

python3.13-mvenv lc-academy-env


第一次报错了,不知道为啥

为了方便,可以:

  1. 按 Ctrl+Shift+P
  2. 选择 Python: Select Interpreter
  3. 选择或手动输入:/home/user/projects/langchain-academy/lc-academy-env/bin/python

Running notebooks

中文:运行笔记本

If you don’t have Jupyter set up, follow installation instructions here.

如果你尚未设置 Jupyter,请按照此处的安装说明操作。

$ jupyter notebook


Sign up for LangSmith

中文:注册 LangSmith

Create a LangSmith account and API key.

创建一个 LangSmith 账户和 API 密钥。

You can reference LangSmith docs here.

你可以在此处查看 LangSmith 文档。

Then, set

然后设置:

LANGSMITH_API_KEY="your-key" LANGSMITH_TRACING_V2=true LANGSMITH_PROJECT="langchain-academy" # If you are on the EU instance: LANGSMITH_ENDPOINT=https://eu.api.smith.langchain.com

代码注释翻译:# If you are on the EU instance:表示“如果你使用的是欧盟实例”。

in your environment.

在你的环境中完成上述设置。

https://docs.langchain.com/langsmith/observability-quickstart#prerequisites

参考文章:VSCode Python扩展自动加载.env环境变量机制(Python插件)python.terminal.useEnvFile

Set up OpenAI API key

中文:设置 OpenAI API 密钥

If you don’t have an OpenAI API key, you can sign up here.

如果你没有 OpenAI API 密钥,可以在此处注册。

Note that OpenAI no longer has a free tier.

请注意,OpenAI 已不再提供免费层级。

You will need to add funds to your OpenAI account.

你需要为 OpenAI 账户充值。

You can use other models.

你也可以使用其他模型。

Your results may differ from those in the course video, but that is not unusual in LLM development.

你的结果可能与课程视频中的结果不同,但这在 LLM 开发中并不罕见。

Be sure to set up keys and alter invocations for any alternate models.

如果使用其他模型,请务必设置相应密钥并修改调用方式。

Then, set

然后设置:

OPENAI_API_KEY

in your environment.

在你的环境中完成上述设置。

Tavily for web search

中文:使用 Tavily 进行网络搜索

Tavily Search API is a search engine optimized for LLMs and RAG, aimed at efficient, quick, and persistent search results.

Tavily Search API 是一款针对 LLM 和 RAG 优化的搜索引擎,旨在高效、快速且持续地提供搜索结果。

You can sign up for an API key here.

你可以在此处注册 API 密钥。

It’s easy to sign up and offers a generous free tier.

注册过程很简单,并且提供额度充足的免费层级。

Some lessons in Module 4 will use Tavily.

模块4中的部分课程会使用 Tavily。

Then, set

然后设置:

TAVILY_API_KEY

in your environment.

在你的环境中完成上述设置。

Set up LangSmith Studio

中文:设置 LangSmith Studio

Note: LangSmith Studio was formerly LangGraph Studio

中文:注意:LangSmith Studio 原名为 LangGraph Studio。

  • LangSmith Studio is a custom IDE for viewing and testing agents.
    • 中文:LangSmith Studio 是一个用于查看和测试智能体的定制 IDE。
  • Studio can be run locally and opened in your browser on Mac, Windows, and Linux.
    • 中文:在 Mac、Windows 和 Linux 上,Studio 都可以在本地运行并通过浏览器打开。
  • See documentation here.
    • 中文:请在此处查看文档。
  • Graphs for LangSmith Studio are in the module-x/studio/ folders.
    • 中文:LangSmith Studio 使用的图位于module-x/studio/文件夹中。
  • To start the local development server, run the following command in your terminal in the /studio directory each module:
    • 中文:若要启动本地开发服务器,请在每个模块的/studio目录中,通过终端运行以下命令:
langgraph dev

You should see the following output:

你应该会看到以下输出:

- 🚀 API: http://127.0.0.1:2024 - 🎨 Studio UI: https://smith.langchain.com/studio/?baseUrl=http://127.0.0.1:2024 - 📚 API Docs: http://127.0.0.1:2024/docs


https://aws.smith.langchain.com/studio/?baseUrl=http://127.0.0.1:2024

Open your browser and navigate to the Studio UI:https://smith.langchain.com/studio/?baseUrl=http://127.0.0.1:2024

打开浏览器并前往 Studio UI:https://smith.langchain.com/studio/?baseUrl=http://127.0.0.1:2024

  • To use Studio, you will need to create a .env file with the relevant API keys
    • 中文:若要使用 Studio,需要创建一个包含相关 API 密钥的.env文件。
  • Run this from the command line to create these files for module 1 to 6, as an example:
    • 中文:以下命令演示了如何通过命令行为模块1至模块6创建这些文件:
for i in {1..5}; do cp module-$i/studio/.env.example module-$i/studio/.env echo "OPENAI_API_KEY=\"$OPENAI_API_KEY\"" > module-$i/studio/.env done echo "TAVILY_API_KEY=\"$TAVILY_API_KEY\"" >> module-4/studio/.env

现在不需要执行截图中的循环命令。Studio 已经打开,而且页面显示绿色 Connected,说明本地开发服务运行正常。截图中的命令只负责给每个module-*/studio创建 .env,并不负责启动 Studio。但当前仓库已经改成让所有 Studio 统一读取根目录的 .env:"env": "../../.env"


Slack Community

中文:Slack 社区

If you’re interested in connecting with other learners, you can join our Slack Community here.

如果你希望与其他学习者交流,可以在此处加入我们的 Slack 社区。

If you have any questions, we encourage you to ask and explore in our community-run Forum.

如果你有任何问题,我们鼓励你在社区运营的论坛中提问和探索。

We encourage you to pay it forward within the community and help other learners.

我们鼓励你在社区中将善意传递下去,帮助其他学习者。

Please note that our Slack Community is not an official support channel.

请注意,我们的 Slack 社区并非官方支持渠道。

If you are a customer and need product support, reach out to support@langchain.dev.

如果你是客户并需要产品支持,请联系 support@langchain.dev。

Module 0 Resources

中文:模块0资源

Getting Set Up (Video Guide)

中文:环境设置(视频指南)

  • Notebook Reference: basics.ipynb
    • 中文:笔记本参考文件:basics.ipynb
  • Download Notebook onGitHub
    • 中文:在GitHub上下载笔记本。
  • View Notebook onGoogle Colab
    • 中文:在Google Colab上查看笔记本。
http://www.cnnetsun.cn/news/4261475.html

相关文章:

  • 快速幂算法精讲:从原理到实战,掌握高效指数运算与取模技巧
  • 从AI剧到互动影游:用Flask与状态机构建动态剧情应用
  • 线性规划实战:从生产优化到MATLAB/LINGO求解与灵敏度分析
  • 潜态推理与视频世界模型:从像素预测到状态演化的建模实践
  • ComfyUI与Wan2.2实现可控视频生成:背景保留与动作迁移实战
  • 蓝桥杯平面切分问题解析:从数学归纳到增量算法实现
  • 理解网络--Linux 系统是如何收发网络包的?
  • SEMI E30标准解析(二)_GEM三大控制状态——谁在控制设备?
  • 具身智能的“开发范式革命”:重塑智能算法与软件开发体系
  • 【数据安全培训】2、数据安全技术01【附全文阅读】
  • 微分方程建模实战:从SIR传染病模型到数值求解与参数优化
  • Agent的“乐高工厂”:DeepSeek Harness的微内核架构与插件化工程全景剖析
  • 9000AI的项目联营和代运营、外包团队的本质区别是什么?李家旺:核心在利益绑定
  • 012-方法学比较
  • 基于Parser解析的车辆重识别:从语义分割到精准检索的实战指南
  • 200+ 插件!这个仓库收集了几乎所有的 DeepSeek Harness 插件!
  • 从黑盒到白盒:构建模块化RAG系统的核心组件与工程实践
  • Seedance 2.5专业工具:AI视频生成如何从玩具走向生产工具
  • STM32 DAC实战指南:从基础配置到DMA任意波形输出
  • LLM生产环境部署成本拆解:从显存计算到推理框架落地实践
  • 面向开发者的AI Agent支付系统设计与安全实践
  • 朴素贝叶斯中文情感分析实战:豆瓣电影评论三分类系统
  • 学习周记实践指南:构建个人知识管理系统,对抗遗忘驱动成长
  • 三层 vs 五层定制纸箱:大件家电运输破损率与成本增量实测对比
  • 把Claude Code会话变成实时流程图:AI编程代理的可观察性探索
  • AI未来50年:Power的三重含义与工程化落地
  • 面向具身智能的TVA-VLA跨模态协同新范式
  • 新能源制造环境下的跨层调度:基于GPIO隔离的机器人梯控防抖实现
  • 导购、陈列、缺货预警——门店那些“小事儿”,胜券AI智能体来帮忙
  • 轮胎图像人工标记:工业级缺陷标注实战指南