UiPath Documentation
getting-started
latest
false
入门开发者指南
  • 概述
    • 概述
  • UiPath 智能体入门
  • 开始使用 UiPath 智能体(采用 LangGraph)
    • 简介
    • 设置您的环境
    • 构建智能体
    • 评估智能体
    • 连接到 Studio Web
  • 在 Studio Web 中构建低代码智能体
  • 向 UiPath 智能体添加工具
重要 :
请注意,此内容已使用机器翻译进行了本地化。 新发布内容的本地化可能需要 1-2 周的时间才能完成。

构建智能体

运用您的编码智能体和 UiPath 技能,在本地构建、配置和运行 LangGraph 智能体。

安装 CLI、技能就位且您的帐户通过身份验证后,您就可以构建本地项目了。

步骤 4 - 设置本地项目

为您的智能体项目创建一个新文件夹,然后在 VS Code 中打开( “文件”→“打开文件夹”)。此步骤之后的所有命令都从项目文件夹根目录运行。

创建 Python 环境

创建固定到受支持的 Python 版本的虚拟环境并激活:

mkdir QuestIntake
cd QuestIntake

uv venv --python 3.13
source .venv/bin/activate
mkdir QuestIntake
cd QuestIntake

uv venv --python 3.13
source .venv/bin/activate
备注:

Windows:使用.venv\Scripts\activate代替source .venv/bin/activate

备注:

Python 版本:如果 3.13 不在您的路径上, uv会自动下载和管理 Python。支持的版本为 3.11、3.12 和 3.13。

安装 LangGraph 集成

LangGraph是一个 Python 框架,用于将有状态的 LLM 智能体构建为节点和边线图。uipath-langchain是 UiPath 集成层,用于打包 LangGraph 智能体,以便在 UiPath 平台上进行部署和评估。

将 UiPath LangGraph 包安装到活动虚拟机中。这也使该框架可在下一步中用于项目框架:

uv pip install uipath-langchain
uv pip install uipath-langchain

使用 UiPath CLI 注册 Python

告诉 CLI 与 UiPath 兼容的 Python 可执行文件所在的位置:

uip codedagent setup --force
uip codedagent setup --force

您应该会看到"Result": "Success" 。在使用uip codedagent命令之前,每台计算机都需要执行一次此步骤(在任何 venv 更改后)。

创建项目框架

创建 UiPath 项目结构。uip codedagent new检测已安装的框架并生成正确的框架文件:

uip codedagent new QuestIntake
uip codedagent new QuestIntake

这将创建pyproject.tomlmain.pylanggraph.jsonuipath.jsonentry-points.jsonbindings.json和编码智能体上下文文件( AGENTS.mdCLAUDE.md.agent/ )。main.py是占位符;您的编码智能体将在步骤 5 中替换它。

添加本地开发服务器依赖项并同步锁定文件:

uv add uipath-dev --dev
uv sync
uv add uipath-dev --dev
uv sync

生成入口点

运行 init,以从脚手架代码生成入口点架构:

uip codedagent init
uip codedagent init

此阶段项目有一个占位符入口点。在编码 Agent 写入真实智能体代码后,在步骤 5 中重新运行init


步骤 5 - 使用编码智能体构建智能体

这就是 UiPath 技能获得回报的地方。打开您的编码智能体,并提示其创建智能体逻辑。下面的提示很简短:描述了智能体应该执行的操作,而不是如何构建。

您的编码智能体安装的uipath-agents技能已经知道 LangGraph 集成模式、正确的 SDK 导入、Pygantic 架构约定和延迟 LLM 初始化要求(LLM 客户端必须在节点函数内初始化,而不是在模块加载时初始化 — UiPath 的容器运行时不支持模块级别的 LLM 对象;请参阅SDK 快速入门以获取工作示例)。如果没有技能,您需要在提示词中指定所有这些信息。

使用以下提示词(或根据您的用例进行调整):

Create a UiPath coded agent using LangGraph.

The agent is a quest intake classifier for a D&D adventurer's guild. Given a
description of an incoming quest, it classifies the difficulty as one of four tiers:
- Trivial: Simple errands anyone can handle (e.g., deliver a letter, clear rats from a cellar)
- Standard: Moderate quests requiring some skill (e.g., escort a merchant caravan)
- Heroic: Difficult quests requiring significant expertise (e.g., slay a wyvern, infiltrate a thieves' guild)
- Legendary: Extreme quests requiring top-tier heroes and special approval (e.g., defeat a lich, close a planar rift)

Return the classification tier and a brief reasoning.

Use these exact field names in the State schema:
- Input field: `description` (string)
- Output fields: `tier` (string) and `reasoning` (string)

Create a langgraph.json and an input.json with a sample D&D quest for testing.
Create a UiPath coded agent using LangGraph.

The agent is a quest intake classifier for a D&D adventurer's guild. Given a
description of an incoming quest, it classifies the difficulty as one of four tiers:
- Trivial: Simple errands anyone can handle (e.g., deliver a letter, clear rats from a cellar)
- Standard: Moderate quests requiring some skill (e.g., escort a merchant caravan)
- Heroic: Difficult quests requiring significant expertise (e.g., slay a wyvern, infiltrate a thieves' guild)
- Legendary: Extreme quests requiring top-tier heroes and special approval (e.g., defeat a lich, close a planar rift)

Return the classification tier and a brief reasoning.

Use these exact field names in the State schema:
- Input field: `description` (string)
- Output fields: `tier` (string) and `reasoning` (string)

Create a langgraph.json and an input.json with a sample D&D quest for testing.
重要提示:

编码智能体是非确定性的。您生成的代码将与此处显示的任何示例代码不同;这是预期的。重要的是main.py是否能够正常运行并返回分类。

备注:

交付问题:如果您的编码智能体提出“交付”问题(Studio Web、本地开发服务器或跳过),请选择“跳过 - 我现在已经完成” 。在步骤 9 中连接到 Studio Web。

编码智能体完成后,重新运行 init,以从新的 Pygantic 模式中获取更新的入口点:

uip codedagent init
uip codedagent init

您应该会看到确认检测到入口点的输出以及 ASCII 图表:

Created 'entry-points.json' file with 1 entrypoint(s).
Created 'entry-points.json' file with 1 entrypoint(s).

在继续操作之前,请打开pyproject.toml并在[project]下添加authors条目(如果尚未添加)。UiPath 需要此字段来打包项目:

authors = [{ name = "Your Name" }]
authors = [{ name = "Your Name" }]

智能体在本地运行并注册入口点后,您就可以运行智能体并在下一部分中构建评估集。

此页面有帮助吗?

连接

需要帮助? 支持

想要了解详细内容? UiPath Academy

有问题? UiPath 论坛

保持更新