- 简介
- UiPath 智能体入门
- 开始使用 UiPath 智能体(采用 LangGraph)
- 在 Studio Web 中构建低代码智能体
- 向 UiPath 智能体添加工具
- Getting Started with UiPath Maestro Flow
运用您的编码智能体和 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.toml 、 main.py 、 langgraph.json 、 uipath.json 、 entry-points.json 、 bindings.json和编码智能体上下文文件( AGENTS.md 、 CLAUDE.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 技能获得回报的地方。打开您的编码智能体,并提示其创建智能体逻辑。下面的提示很简短:描述了智能体应该执行的操作,而不是如何构建。
The uipath-agents skill your coding agent has installed already knows the LangGraph integration patterns, correct SDK imports, Pydantic schema conventions, and relevant SDK requirements. Without these skills, you would need to specify all of this in the prompt itself.
使用以下提示词(或根据您的用例进行调整):
Update main.py to implement this UiPath coded agent using LangGraph as a single-node graph with no tools and no retry or error-handling logic.
The agent is a quest intake classifier for a fantasy 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` (a Literal type constrained to exactly "Trivial", "Standard", "Heroic", "Legendary" — not a plain string, so the model can't emit an out-of-vocabulary tier) and `reasoning` (string)
Update the existing langgraph.json to point at the new graph, and create an input.json with this exact sample quest: {"description": "Clear the rats out of the inn cellar"}.
Only touch main.py, langgraph.json, and input.json.
Don't run any uip codedagent commands or otherwise verify that the agent runs — I will do this myself.
Update main.py to implement this UiPath coded agent using LangGraph as a single-node graph with no tools and no retry or error-handling logic.
The agent is a quest intake classifier for a fantasy 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` (a Literal type constrained to exactly "Trivial", "Standard", "Heroic", "Legendary" — not a plain string, so the model can't emit an out-of-vocabulary tier) and `reasoning` (string)
Update the existing langgraph.json to point at the new graph, and create an input.json with this exact sample quest: {"description": "Clear the rats out of the inn cellar"}.
Only touch main.py, langgraph.json, and input.json.
Don't run any uip codedagent commands or otherwise verify that the agent runs — I will do this myself.
Why this prompt is so specific. It names the exact files to touch and tells the coding agent not to run any uip codedagent commands or verify its own work. That's deliberate here: the rest of this lab exercises those same CLI commands directly in the next steps, so verification is left to you instead of the coding agent running it first.
The prompt above is a good template to start from in your own projects, but you should remove the last two sentences to enable the coding agent to test its work and organize files to its own judgment.
编码智能体是非确定性的。您生成的代码将与此处显示的任何示例代码不同;这是预期的。重要的是main.py是否能够正常运行并返回分类。
And note that if your coding agent presents a 'Delivery' question (Studio Web, local dev server, or skip), select Skip - I'm done for now. Connect to Studio Web in Step 10.
编码智能体完成后,重新运行 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" }]
With the agent running locally and the entry points registered, you are ready to run it in the next step.
步骤 6 - 在本地运行智能体
使用您的编码智能体创建的示例输入文件运行智能体:
uip codedagent run agent --file input.json
uip codedagent run agent --file input.json
您应该会看到智能体对请求进行了分类,并返回一个带有推理的层级。
您也可以内联传递输入。这些示例使用 Bash 单引号语法;如果您使用的是 PowerShell,请改为将--file与 JSON 文件一起使用:
uip codedagent run agent '{"description": "Clear the rats out of the inn cellar"}'
uip codedagent run agent '{"description": "Clear the rats out of the inn cellar"}'
Try your own inputs to verify the classifications make sense, for example:
uip codedagent run agent '{"description": "Slay the ancient red dragon terrorizing the countryside"}'
uip codedagent run agent '{"description": "Slay the ancient red dragon terrorizing the countryside"}'
With the agent classifying correctly, you are ready to give it something to verify its answers against.