在 agent.json 中定义智能体合同,编写系统提示词,并配置输入和输出架构。
安装 CLI 并连接 UiPath 帐户后,您就可以构建智能体了。
步骤 4 - 构建解决方案和智能体
低代码智能体位于解决方案中,即 CLI 上传到 Studio Web 的可部署单元。您需要先创建解决方案,然后在其中搭建智能体的框架。
-
创建工作目录并构建解决方案:
mkdir Monster-Selector-Lab cd Monster-Selector-Lab uip solution init MonsterSelectormkdir Monster-Selector-Lab cd Monster-Selector-Lab uip solution init MonsterSelector这将创建一个
MonsterSelector/目录,其中包含MonsterSelector.uipx(解决方案清单),以及使编码智能体适应解决方案结构的AGENTS.md和CLAUDE.md简报文件。 -
在解决方案目录中构建智能体项目:
uip agent init MonsterSelector/MonsterSelectoruip agent init MonsterSelector/MonsterSelectoruip agent init <path>在给定路径中创建智能体项目,并自动将其注册到解决方案中。它会生成agent.json(系统提示词、架构和模型设置)、entry-points.json、空的evals/框架和自动生成的项目 ID。 -
移至解决方案目录以执行剩余步骤:
cd MonsterSelectorcd MonsterSelector
两个名为MonasterSelector的目录。您的实验室目录现在包含MonsterSelector/ (解决方案),解决方案又包含另一个MonsterSelector/ (智能体项目)。这很正常:解决方案和智能体项目可以共享名称。在执行后续步骤时,请注意您所在的目录。最后,您将进入解决方案目录 ( Monster-Selector-Lab/MonsterSelector/ )。
步骤 5 - 配置智能体
智能体配置由agent.json和entry-points.json文件定义。您可以直接编辑这些内容,以从本实验开始实施设计,替换脚手架生成的占位符内容。
配置 agent.json
要替换框架,请打开MonsterSelector/agent.json (相对于您所在的解决方案目录)。将其全部内容替换为以下内容。一个例外是最后一行的projectId值;保留脚本生成的 UUID,而不是使用此处显示的占位符。
以下 JSON 将实现您正在构建的内容中的设计:
- 输入架构:
questDescription(字符串)和monsters(数组),均为必填项。 - 输出架构:
monsterIndex(字符串)。 - 系统提示词:
messages[0](system角色)中告诉模型如何进行推理的指令文本。 - 用户轮次:
messages[1](user角色)中的消息,在运行时将questDescription和monsters携带到提示词中:这是 LLM 对话轮次,而不是人类最终用户。
{
"version": "1.1.0",
"settings": {
"model": "gpt-4.1-2025-04-14",
"maxTokens": 16384,
"temperature": 0,
"engine": "basic-v2",
"maxIterations": 25,
"mode": "standard"
},
"inputSchema": {
"type": "object",
"properties": {
"questDescription": {
"type": "string",
"description": "Description of the quest"
},
"monsters": {
"type": "array",
"description": "Candidate monsters from the D&D 5e API"
}
},
"required": ["questDescription", "monsters"]
},
"outputSchema": {
"type": "object",
"properties": {
"monsterIndex": {
"type": "string",
"description": "The index slug of the chosen monster"
}
}
},
"metadata": {
"storageVersion": "50.0.0",
"isConversational": false,
"showProjectCreationExperience": false,
"targetRuntime": "pythonAgent"
},
"type": "lowCode",
"messages": [
{
"role": "system",
"content": "You are an RPG game master helping to select the most thematically appropriate monster for a quest. Given a quest description and a list of candidate monsters (each with a name and an index slug), pick the ONE monster whose lore, environment, or threat level best fits the quest. Return ONLY the index slug of your chosen monster. Do not return the full object or any commentary - just the string slug. If multiple candidates fit, favor the most iconic or thematically resonant choice.",
"contentTokens": [
{
"type": "simpleText",
"rawString": "You are an RPG game master helping to select the most thematically appropriate monster for a quest. Given a quest description and a list of candidate monsters (each with a name and an index slug), pick the ONE monster whose lore, environment, or threat level best fits the quest. Return ONLY the index slug of your chosen monster. Do not return the full object or any commentary - just the string slug. If multiple candidates fit, favor the most iconic or thematically resonant choice."
}
]
},
{
"role": "user",
"content": "{{input.questDescription}} {{input.monsters}}",
"contentTokens": [
{ "type": "variable", "rawString": "input.questDescription" },
{ "type": "simpleText", "rawString": " " },
{ "type": "variable", "rawString": "input.monsters" }
]
}
],
"projectId": "your-scaffold-generated-uuid-here"
}
{
"version": "1.1.0",
"settings": {
"model": "gpt-4.1-2025-04-14",
"maxTokens": 16384,
"temperature": 0,
"engine": "basic-v2",
"maxIterations": 25,
"mode": "standard"
},
"inputSchema": {
"type": "object",
"properties": {
"questDescription": {
"type": "string",
"description": "Description of the quest"
},
"monsters": {
"type": "array",
"description": "Candidate monsters from the D&D 5e API"
}
},
"required": ["questDescription", "monsters"]
},
"outputSchema": {
"type": "object",
"properties": {
"monsterIndex": {
"type": "string",
"description": "The index slug of the chosen monster"
}
}
},
"metadata": {
"storageVersion": "50.0.0",
"isConversational": false,
"showProjectCreationExperience": false,
"targetRuntime": "pythonAgent"
},
"type": "lowCode",
"messages": [
{
"role": "system",
"content": "You are an RPG game master helping to select the most thematically appropriate monster for a quest. Given a quest description and a list of candidate monsters (each with a name and an index slug), pick the ONE monster whose lore, environment, or threat level best fits the quest. Return ONLY the index slug of your chosen monster. Do not return the full object or any commentary - just the string slug. If multiple candidates fit, favor the most iconic or thematically resonant choice.",
"contentTokens": [
{
"type": "simpleText",
"rawString": "You are an RPG game master helping to select the most thematically appropriate monster for a quest. Given a quest description and a list of candidate monsters (each with a name and an index slug), pick the ONE monster whose lore, environment, or threat level best fits the quest. Return ONLY the index slug of your chosen monster. Do not return the full object or any commentary - just the string slug. If multiple candidates fit, favor the most iconic or thematically resonant choice."
}
]
},
{
"role": "user",
"content": "{{input.questDescription}} {{input.monsters}}",
"contentTokens": [
{ "type": "variable", "rawString": "input.questDescription" },
{ "type": "simpleText", "rawString": " " },
{ "type": "variable", "rawString": "input.monsters" }
]
}
],
"projectId": "your-scaffold-generated-uuid-here"
}
temperature: 0 。可以降低输出差异,但不会使模型完全具有确定性。即使为 0,模型有时也会在运行之间返回不同的有效输出。对于此智能体,可以选择任何可防御的生物;确切的字符串可重现性不是目标。
配置入口点.json
现在打开MonsterSelector/entry-points.json ,并将其全部内容替换为以下内容。再次保留框架生成的uniqueId值,而不是使用占位符。
下面的 JSON 定义了您在以下步骤中调用的agent入口点。一个解决方案可以公开多个入口点(例如,同一智能体的一个简单变体和一个扩展输入变体),但我们这里只需要一个。
{
"$schema": "https://cloud.uipath.com/draft/2024-12/entry-point",
"$id": "entry-points.json",
"entryPoints": [
{
"filePath": "/content/agent.json",
"uniqueId": "your-scaffold-generated-uuid-here",
"type": "agent",
"input": {
"type": "object",
"properties": {
"questDescription": {
"type": "string",
"description": "Description of the quest"
},
"monsters": {
"type": "array",
"description": "Candidate monsters from the D&D 5e API"
}
},
"required": ["questDescription", "monsters"]
},
"output": {
"type": "object",
"properties": {
"monsterIndex": {
"type": "string",
"description": "The index slug of the chosen monster"
}
}
}
}
]
}
{
"$schema": "https://cloud.uipath.com/draft/2024-12/entry-point",
"$id": "entry-points.json",
"entryPoints": [
{
"filePath": "/content/agent.json",
"uniqueId": "your-scaffold-generated-uuid-here",
"type": "agent",
"input": {
"type": "object",
"properties": {
"questDescription": {
"type": "string",
"description": "Description of the quest"
},
"monsters": {
"type": "array",
"description": "Candidate monsters from the D&D 5e API"
}
},
"required": ["questDescription", "monsters"]
},
"output": {
"type": "object",
"properties": {
"monsterIndex": {
"type": "string",
"description": "The index slug of the chosen monster"
}
}
}
}
]
}
了解 agent.json 和入口点.json
agent.json是智能体定义:模型设置、系统提示词以及输入和输出架构。entry-points.json向解决方案运行时公开这些架构。- 重要提示:两个文件中的
inputSchema和outputSchema块必须相同。不匹配会导致验证失败。
适应您的用例。要构建其他智能体,请将messages[0]中的content字符串替换为您的系统提示词,并更新inputSchema和outputSchema中的properties块,以匹配提示词引用的字段。在entry-points.json中镜像相同的更改。settings 、 metadata 、 type和消息结构保持不变。
步骤 6 - 验证智能体
在解决方案目录中,验证智能体:
uip agent validate MonsterSelector
uip agent validate MonsterSelector
您应该会看到带有"Status": "Valid"的"StorageVersion": "50.0.0"和显示"Validated" agent: true摘要。验证还会生成 Studio Web 使用的.agent-builder/文件;这些都是免费版。
如果验证失败,请确认inputSchema和outputSchema中的agent.json与entry-points.json相同,并且messages[1].content中的每个变量引用都使用input.前缀(例如{{input.questDescription}} )。
在本地验证智能体后,您就可以将其上传到 Studio Web 并在下一部分中运行实时测试。