Documentation Index
Fetch the complete documentation index at: https://nvd-54.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
本指南向你展示如何将智能体部署到 LangSmith Cloud,这是一个专为智能体工作负载设计的全托管平台。通过 Cloud 部署,你可以直接从 GitHub 仓库部署——LangSmith 处理基础设施、扩展和运维问题。
传统托管平台是为无状态、短时运行的 Web 应用构建的。LangSmith Cloud 专为有状态、长时间运行的智能体而构建,需要持久化状态和后台执行。
前提条件
在开始之前,请确保你具备以下条件:
部署你的智能体
1. 在 GitHub 上创建仓库
你的应用代码必须存放在 GitHub 仓库中才能部署到 LangSmith。支持公开和私有仓库。对于本快速入门,首先按照本地服务器设置指南确保你的应用兼容 LangGraph。然后,将代码推送到仓库。
2. 部署到 LangSmith
创建新部署
点击 + New Deployment 按钮。将打开一个面板,你可以在其中填写所需字段。
关联仓库
如果你是首次使用或添加之前未连接的私有仓库,请点击 Add new account 按钮并按照说明连接你的 GitHub 账户。
部署仓库
选择你的应用仓库。点击 Submit 进行部署。这可能需要大约 15 分钟完成。你可以在 Deployment details 视图中查看状态。
3. 在 Studio 中测试你的应用
应用部署完成后:
- 选择你刚创建的部署以查看更多详情。
- 点击右上角的 Studio 按钮。Studio 将打开并显示你的图。
4. 获取部署的 API URL
- 在 LangGraph 的 Deployment details 视图中,点击 API URL 将其复制到剪贴板。
- 点击
URL 将其复制到剪贴板。
5. 测试 API
现在你可以测试 API:
- 安装 LangGraph SDK:
npm install @langchain/langgraph-sdk
- 向智能体发送消息:
import { Client } from "@langchain/langgraph-sdk";
const client = new Client({ apiUrl: "your-deployment-url", apiKey: "your-langsmith-api-key" });
const streamResponse = client.runs.stream(
null, // 无线程运行
"agent", // 智能体名称。在 langgraph.json 中定义。
{
input: {
"messages": [
{ "role": "user", "content": "What is LangGraph?"}
]
},
streamMode: "messages",
}
);
for await (const chunk of streamResponse) {
console.log(`Receiving new event of type: ${chunk.event}...`);
console.log(JSON.stringify(chunk.data));
console.log("\n\n");
}
curl -s --request POST \
--url <DEPLOYMENT_URL>/runs/stream \
--header 'Content-Type: application/json' \
--header "X-Api-Key: <LANGSMITH API KEY> \
--data "{
\"assistant_id\": \"agent\", `# 智能体名称。在 langgraph.json 中定义。`
\"input\": {
\"messages\": [
{
\"role\": \"human\",
\"content\": \"What is LangGraph?\"
}
]
},
\"stream_mode\": \"updates\"
}"
将这些文档连接到 Claude、VSCode 等工具,通过 MCP 获取实时答案。