公司动态
(LangGraph教程)0. Welcome to the course!
https://academy.langchain.com/courses/intro-to-langgraphhttps://github.com/shangxiang0907/langchain-academyhttps://github.com/shangxiang0907/langchain-academy/blob/main/module-0/basics.ipynb文章目录Getting Set UpIntroductionSetupPython versionClone repoCreate an environment and install dependenciesRunning notebooksSign up for LangSmithSet up OpenAI API keyTavily for web searchSet up LangSmith StudioNote: LangSmith Studio was formerly LangGraph StudioSlack CommunityModule 0 ResourcesGetting 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 --versionClone repo中文:克隆代码仓库git clone https://github.com/langchain-ai/langchain-academy.git $ cd langchain-academyCreate 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第一次报错了,不知道为啥为了方便,可以:按 Ctrl+Shift+P选择 Python: Select Interpreter选择或手动输入:/home/user/projects/langchain-academy/lc-academy-env/bin/pythonRunning notebooks中文:运行笔记本If you don’t have Jupyter set up, follow installation instructions here.如果你尚未设置 Jupyter,请按照此处的安装说明操作。$ jupyter notebookSign up for LangSmith中文:注册 LangSmithCreate 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.useEnvFileSet 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_KEYin 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_KEYin your environment.在你的环境中完成上述设置。Set up LangSmith Studio中文:设置 LangSmith StudioNote: 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 devYou 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/docshttps://aws.smith.langchain.com/studio/?baseUrl=http://127.0.0.1:2024Open 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:2024To 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.ipynbDownload Notebook onGitHub中文:在GitHub上下载笔记本。View Notebook onGoogle Colab中文:在Google Colab上查看笔记本。