https://academy.langchain.com/courses/intro-to-langgraphhttps://github.com/shangxiang0907/langchain-academy文章目录[Optional] Lesson 8: DeploymentLangSmith Deployment was formerly LangGraph Platform.Deployment 部署Review 回顾Goals 目标Concepts 概念Testing Locally 本地测试StudioTesting with Cloud 使用云服务测试Create a New Repository on GitHub 在 GitHub 上新建仓库Add Your GitHub Repository as a Remote 将您的 GitHub 仓库添加为远程仓库Connect LangSmith to your GitHub Repository 将 LangSmith 连接到您的 GitHub 仓库Work with your deployment 与你的部署交互[Optional] Lesson 8: Deployment中文[可选] 第8课部署Currently, LangSmith Deployment is available only for LangSmith Plus plan users.中文目前LangSmith Deployment 仅向 LangSmith Plus 套餐用户开放。Lesson 8 in this course is optional.中文本课程的第8课为可选内容。LangSmith Deployment was formerly LangGraph Platform.中文LangSmith Deployment 原名为 LangGraph Platform。Notebook Reference: deployment.ipynb中文笔记本参考文件deployment.ipynbDownload Notebook onGitHub中文在GitHub上下载笔记本。View Notebook onGoogle Colab中文在Google Colab上查看笔记本。Deployment 部署Review 回顾We built up to an agent with memory:我们已构建出一个具备记忆能力的智能体act- let the model call specific toolsact— 允许模型调用特定工具observe- pass the tool output back to the modelobserve— 将工具输出传回模型reason- let the model reason about the tool output to decide what to do next (e.g., call another tool or just respond directly)reason— 让模型基于工具输出进行推理以决定下一步操作例如调用另一工具或直接响应persist state- use an in memory checkpointer to support long-running conversations with interruptionspersist state— 使用内存中的检查点器checkpointer支持带中断的长时间运行对话Goals 目标Now, we’ll cover how to actually deploy our agent locally to Studio and toLangGraph Cloud.接下来我们将介绍如何将智能体实际部署到本地 Studio 和LangGraph Cloud。%%capture--no-stderr%pip install--quiet-U langgraph_sdk langchain_coreConcepts 概念There are a few central concepts to understand -需理解若干核心概念 —LangGraph—LangGraph—Python and JavaScript libraryPython 与 JavaScript 库Allows creation of agent workflows支持创建智能体工作流LangGraph API—LangGraph API—Bundles the graph code封装图graph代码Provides a task queue for managing asynchronous operations提供任务队列用于管理异步操作Offers persistence for maintaining state across interactions提供持久化能力以在多次交互间维持状态LangSmith Deployment(formerlyLangGraph Cloud) –LangSmith Deployment原LangGraph Cloud——Hosted service for the LangGraph API托管式 LangGraph API 服务Allows deployment of graphs from GitHub repositories支持从 GitHub 仓库部署图Also provides monitoring and tracing for deployed graphs还为已部署的图提供监控与追踪功能Accessible via a unique URL for each deployment每个部署均通过唯一 URL 访问LangSmith Studio(formerlyLangGraph Studio) –LangSmith Studio原LangGraph Studio——Integrated Development Environment (IDE) for LangGraph applications面向 LangGraph 应用的集成开发环境IDEUses the API as its back-end, allowing real-time testing and exploration of graphs以后端 API 为基础支持对图进行实时测试与探索Can be run locally or with cloud-deployment. See below.可本地运行亦支持云部署。详见下文。LangGraph SDK–LangGraph SDK——Python library for programmatically interacting with LangGraph graphs用于以编程方式与 LangGraph 图交互的 Python 库Provides a consistent interface for working with graphs, whether served locally or in the cloud无论图是本地托管还是云端托管均提供统一接口Allows creation of clients, access to assistants, thread management, and execution of runs支持创建客户端、访问助手、线程管理及执行运行runTesting Locally 本地测试Studio⚠️ Notice⚠️ 注意Since filming these videos, we’ve updated Studio so that it can now be run locally and accessed through your browser.自录制本系列视频以来我们已更新 Studio使其现在可本地运行并可通过浏览器访问。This is the preferred way to run Studio instead of using the Desktop App shown in the video.这是运行 Studio 的首选方式而非视频中演示的桌面应用。It is now calledLangSmith Studioinstead ofLangGraph Studio.它现称为LangSmith Studio而非LangGraph Studio。Detailed setup instructions are available in the “Getting Setup” guide at the start of the course.详细安装说明请参阅本课程开头的“开始设置”指南。You can find a description of Studio here, and specific details for local deployment here.您可在此处查看 Studio 的说明文档 此处本地部署的具体细节请参见 此处。To start the local development server, run the following command in your terminal in the/studiodirectory in this module:要在本地启动开发服务器请在本模块的/studio目录下于终端中运行以下命令langgraph devYou should see the following output:您应看到如下输出- API: http://127.0.0.1:2024 - Studio UI: https://smith.langchain.com/studio/?baseUrlhttp://127.0.0.1:2024 - API Docs: http://127.0.0.1:2024/docsOpen your browser and navigate to theStudio UIURL shown above.打开浏览器并导航至上方显示的Studio UIURL。ifgoogle.colabinstr(get_ipython()):raiseException(Unfortunately LangGraph Studio is currently not supported on Google Colab)fromlanggraph_sdkimportget_client# This is the URL of the local development serverURLhttp://127.0.0.1:2024clientget_client(urlURL)# Search all hosted graphsassistantsawaitclient.assistants.search()assistants[-3]{assistant_id: fe096781-5601-53d2-b2f6-0d3403f7e9ca, graph_id: agent, config: {}, metadata: {created_by: system}, name: agent, created_at: 2025-03-04T22:57:28.42456500:00, updated_at: 2025-03-04T22:57:28.42456500:00, version: 1}# We create a thread for tracking the state of our runthreadawaitclient.threads.create()Now, we can run our agent withclient.runs.streamwith:现在我们可以使用client.runs.stream运行我们的智能体Thethread_idThegraph_idTheinputThestream_modeWe’ll discuss streaming in depth in a future module.我们将在后续模块中深入探讨流式处理streaming。For now, just recognize that we are streaming the full value of the state after each step of the graph withstream_modevalues.目前只需了解我们正以stream_modevalues方式 流式传输即在图每一步执行后输出完整状态值。The state is captured in thechunk.data.状态值保存在chunk.data中。fromlangchain_core.messagesimportHumanMessage# Inputinput{messages:[HumanMessage(contentMultiply 3 by 2.)]}# Streamasyncforchunkinclient.runs.stream(thread[thread_id],agent,inputinput,stream_modevalues,):ifchunk.dataandchunk.event!metadata:print(chunk.data[messages][-1]){content: Multiply 3 by 2., additional_kwargs: {example: False, additional_kwargs: {}, response_metadata: {}}, response_metadata: {}, type: human, name: None, id: cdbd7bd8-c476-4ad4-8ab7-4ad9e3654267, example: False} {content: , additional_kwargs: {tool_calls: [{index: 0, id: call_iIPryzZZxRtXozwwhVtFObNO, function: {arguments: {a:3,b:2}, name: multiply}, type: function}]}, response_metadata: {finish_reason: tool_calls, model_name: gpt-4o-2024-05-13, system_fingerprint: fp_157b3831f5}, type: ai, name: None, id: run-06c7243c-426d-4c81-a113-f1335dda5fb2, example: False, tool_calls: [{name: multiply, args: {a: 3, b: 2}, id: call_iIPryzZZxRtXozwwhVtFObNO, type: tool_call}], invalid_tool_calls: [], usage_metadata: None} {content: 6, additional_kwargs: {}, response_metadata: {}, type: tool, name: multiply, id: 988cb170-f6e6-43c1-82fd-309f519abe6d, tool_call_id: call_iIPryzZZxRtXozwwhVtFObNO, artifact: None, status: success} {content: The result of multiplying 3 by 2 is 6., additional_kwargs: {}, response_metadata: {finish_reason: stop, model_name: gpt-4o-2024-05-13, system_fingerprint: fp_157b3831f5}, type: ai, name: None, id: run-7bda0aa0-6895-4250-9625-18419c5dc171, example: False, tool_calls: [], invalid_tool_calls: [], usage_metadata: None}Testing with Cloud 使用云服务测试We can deploy to Cloud via LangSmith, as outlined here.我们可通过 LangSmith 部署至云服务具体步骤详见 此处。Create a New Repository on GitHub 在 GitHub 上新建仓库Go to your GitHub account前往您的 GitHub 账户Click on the “” icon in the upper-right corner and selectNew repository点击右上角的 “” 图标选择“New repository”Name your repository (e.g.,langchain-academy)为您的仓库命名例如langchain-academyAdd Your GitHub Repository as a Remote 将您的 GitHub 仓库添加为远程仓库Go back to your terminal where you clonedlangchain-academyat the start of this course返回本课程初始时克隆langchain-academy的终端Add your newly created GitHub repository as a remote将新创建的 GitHub 仓库添加为远程仓库git remote add origin https://github.com/your-username/your-repo-name.gitPush to it推送至该仓库git push -u origin mainConnect LangSmith to your GitHub Repository 将 LangSmith 连接到您的 GitHub 仓库Go to LangSmith访问 LangSmithClick ondeploymentstab on the left LangSmith panel点击 LangSmith 左侧面板中的deployments标签页Add New Deployment添加 新建部署Then, select the Github repository (e.g.,langchain-academy) that you just created for the course然后选择你为本课程刚刚创建的 GitHub 仓库例如langchain-academyPoint theLangGraph API config fileat one of thestudiodirectories将LangGraph API 配置文件指向某个studio目录For example, for module-1 use:module-1/studio/langgraph.json例如对于 module-1请使用module-1/studio/langgraph.jsonSet your API keys (e.g., you can just copy from yourmodule-1/studio/.envfile)设置你的 API 密钥例如可直接从module-1/studio/.env文件中复制Work with your deployment 与你的部署交互We can then interact with our deployment a few different ways:随后我们可通过几种不同方式与部署进行交互With the SDK, as before.使用 SDK方式与之前相同。With LangGraph Studio.使用 LangGraph Studio。To use the SDK here in the notebook, simply ensure thatLANGSMITH_API_KEYis set!若要在本笔记本中使用 SDK请确保已设置LANGSMITH_API_KEYimportos,getpassdef_set_env(var:str):ifnotos.environ.get(var):os.environ[var]getpass.getpass(f{var}: )_set_env(LANGSMITH_API_KEY)# Replace this with the URL of your deployed graphURLhttps://langchain-academy-8011c561878d50b1883f7ed11b32d720.default.us.langgraph.appclientget_client(urlURL)# Search all hosted graphsassistantsawaitclient.assistants.search()# Select the agentagentassistants[0]agent{assistant_id: fe096781-5601-53d2-b2f6-0d3403f7e9ca, graph_id: agent, created_at: 2024-08-23T17:58:02.72292000:00, updated_at: 2024-08-23T17:58:02.72292000:00, config: {}, metadata: {created_by: system}}fromlangchain_core.messagesimportHumanMessage# We create a thread for tracking the state of our runthreadawaitclient.threads.create()# Inputinput{messages:[HumanMessage(contentMultiply 3 by 2.)]}# Streamasyncforchunkinclient.runs.stream(thread[thread_id],agent,inputinput,stream_modevalues,):ifchunk.dataandchunk.event!metadata:print(chunk.data[messages][-1]){content: Multiply 3 by 2., additional_kwargs: {example: False, additional_kwargs: {}, response_metadata: {}}, response_metadata: {}, type: human, name: None, id: 8ea04559-f7d4-4c82-89d9-c60fb0502f21, example: False} {content: , additional_kwargs: {tool_calls: [{index: 0, id: call_EQoolxFaaSVU8HrTnCmffLk7, function: {arguments: {a:3,b:2}, name: multiply}, type: function}]}, response_metadata: {finish_reason: tool_calls, model_name: gpt-4o-2024-05-13, system_fingerprint: fp_3aa7262c27}, type: ai, name: None, id: run-b0ea5ddd-e9ba-4242-bb8c-80eb52466c76, example: False, tool_calls: [{name: multiply, args: {a: 3, b: 2}, id: call_EQoolxFaaSVU8HrTnCmffLk7, type: tool_call}], invalid_tool_calls: [], usage_metadata: None} {content: 6, additional_kwargs: {}, response_metadata: {}, type: tool, name: multiply, id: 1bf558e7-79ef-4f21-bb66-acafbd04677a, tool_call_id: call_EQoolxFaaSVU8HrTnCmffLk7, artifact: None, status: success} {content: 3 multiplied by 2 equals 6., additional_kwargs: {}, response_metadata: {finish_reason: stop, model_name: gpt-4o-2024-05-13, system_fingerprint: fp_3aa7262c27}, type: ai, name: None, id: run-ecc4b6ad-af15-4a85-a76c-de2ed0ed8ed9, example: False, tool_calls: [], invalid_tool_calls: [], usage_metadata: None}
企业数字化 ERP 产品动态
相关推荐
【Atlas】世界模型的架构级分水岭:空间上下文机制与全息模型实现原理深度解析 摘要
Atlas 是 World Labs 于 2026 年 9 月发布的全息世界模型,一个从零预训练的多模态自回归扩散 Transformer。它的技术分水岭不在骨干网络,而在于把文本、图像、相机位姿、3D 深度图统一接地到 3D 空间位置构成"空间上下文",使… · 2026/9/24 17:11:05
TCP协议栈管理、文件符表映射机制与TCP资源关闭流程介绍 文章目录
一、进程与内核
1.用户态的Java程序进程
2.内核态的操作系统内核
2.1操作系统
2.1.1内核
二、文件描述符与表引用
1.文件描述符
2.文件描述符表
3.引用比例
三、TCP资源管理与连接维护
1.TCP协议栈
1.1TCB
1.1.1端点
1.1.1.1TCP连接状态
四、Socket引用… · 2026/9/24 17:52:44
基于 Java Spring Boot 的幼儿早教微信小程序设计与实现 温馨提示:本人主页置顶文章(点我)开头有 CSDN 平台官方提供的学长联系方式的名片!
1. 引言
随着移动互联网的普及和微信生态的快速发展,微信小程序凭借其即用即走、无需下载安装、传播便捷等优势,已成为教育服务领域的重要载体。… · 2026/9/24 17:52:44
视频素材格式转换:多款视频转换工具能力客观记录 自媒体素材整理、课件转码、监控视频归档时,经常遇到视频格式不兼容、平台上传受限的问题。批量转格式、压缩体积、提取音频、转 GIF,不同工具支持的格式种类、批量上限、编码自定义范围差别较大。下文客观记录多款视频转换工具基础能力与使用边界&#… · 2026/9/24 17:52:38
教学反思怎么写才不只是感想:四步各留一处能回查的痕迹 一节课上完,随笔写下几行,往往只是当堂的感受;真正立得住的反思,是每一步都留下了一处日后能翻回来核对的凭据。知学术AIPaperGPT 把这条线看得比字数更重。先要一个框架,让免费智能大纲接手;图表这类素材&… · 2026/9/24 17:52:38
独立站建站平台有哪些?Shopify、WooCommerce和外贸建站方案盘点 搜索“独立站建站平台有哪些”的企业,往往已经决定不只依赖第三方平台或社媒入口,而是希望拥有自己的官网、产品展示、询盘或交易阵地。但独立站并不是单一工具,它包括B2B外贸询盘站、跨境电商交易站、品牌展示站、内容型网站和复杂定制系统&… · 2026/9/24 17:52:19
Large Bin Attack 学习 Large Bin Attack,最重要的一点是不要被它的名字吓倒。虽然它属于高级的堆利用技巧,但它的本质其实非常简单:利用 glibc 在维护“有序双向链表”时,缺乏足够的安全检查,从而让我们能在一个任意的内存地址里&#… · 2026/9/24 17:52:19
基于YOLOv8的渔船作业监控系统:从环境搭建到边缘部署全流程 简介:这是一套面向计算机、人工智能、自动化等专业学生与教师的毕业设计级项目资源,围绕YOLOv8实现渔船作业监控系统,可用于毕设、课程设计、大作业或项目立项演示。压缩包共97个文件,约24.21MB,以70个Python源码文件为… · 2026/9/24 0:00:13
1D-CNN时间序列建模实战:从Conv1d原理到工业落地 简介:面向时间序列数据建模的一维卷积神经网络完整实现,适合深度学习入门者及需要快速验证时序模型的研究者,能够从音频、文本、传感器或股价等序列中挖掘局部特征与时间依赖。压缩包体积很小,只有3KB,内含3个Python脚… · 2026/9/24 0:00:26
柔软的L:汉语语流中被忽视的舌肌张力控制 1. 这个“L”不是字母表里的L,而是舌尖上的L最近在几个方言群和语音教学社群里,反复看到有人发一句:“也说字母L:柔软的长舌”。初看以为是英语发音课笔记,点开才发现全是方言爱好者、播音系学生、语言康复师甚至戏曲演… · 2026/9/24 0:00:44