Microsoft Foundry 代理服务开发
在本练习中,您将使用 Microsoft Foundry 门户中的 Microsoft Foundry 代理服务工具创建一个航班预订代理。该代理能够与用户交互并提供有关航班的信息。
先决条件
要完成此练习,您需要以下内容:
- 具有有效订阅的 Azure 账户。免费创建账户。
- 您需要拥有创建 Microsoft Foundry 中枢的权限,或者由他人为您创建。
- 如果您的角色是贡献者或所有者,可以按照本教程中的步骤操作。
创建 Microsoft Foundry 中枢
注意: Microsoft Foundry 之前称为 Azure AI Studio。
按照 Microsoft Foundry 博客文章中的指南创建 Microsoft Foundry 中枢。
创建项目后,关闭显示的任何提示,查看 Microsoft Foundry 门户中的项目页面,页面应类似下图:

部署模型
在项目左侧窗格的 我的资产 部分中,选择 模型 + 端点 页面。
在 模型 + 端点 页面中,选择 模型部署 选项卡,在 + 部署模型 菜单中选择 部署基础模型。
在列表中搜索
gpt-5-mini模型,然后选择并确认部署。注意:降低 TPM 有助于避免过度使用您所使用订阅中的配额。

创建代理
现在您已经部署了模型,可以创建代理。代理是可用于与用户交互的对话式 AI 模型。
- 在项目左侧窗格的 构建与自定义 部分,选择 代理 页面。
- 点击 + 创建代理 创建一个新代理。在 代理设置 对话框中:
- 输入代理名称,例如
FlightAgent。 - 确保选中了之前创建的
gpt-5-mini模型部署。 - 根据您希望代理遵循的提示,设置 说明。示例如下:
You are FlightAgent, a virtual assistant specialized in handling flight-related queries. Your role includes assisting users with searching for flights, retrieving flight details, checking seat availability, and providing real-time flight status. Follow the instructions below to ensure clarity and effectiveness in your responses: ### Task Instructions: 1. **Recognizing Intent**: - Identify the user's intent based on their request, focusing on one of the following categories: - Searching for flights - Retrieving flight details using a flight ID - Checking seat availability for a specified flight - Providing real-time flight status using a flight number - If the intent is unclear, politely ask users to clarify or provide more details. 2. **Processing Requests**: - Depending on the identified intent, perform the required task: - For flight searches: Request details such as origin, destination, departure date, and optionally return date. - For flight details: Request a valid flight ID. - For seat availability: Request the flight ID and date and validate inputs. - For flight status: Request a valid flight number. - Perform validations on provided data (e.g., formats of dates, flight numbers, or IDs). If the information is incomplete or invalid, return a friendly request for clarification. 3. **Generating Responses**: - Use a tone that is friendly, concise, and supportive. - Provide clear and actionable suggestions based on the output of each task. - If no data is found or an error occurs, explain it to the user gently and offer alternative actions (e.g., refine search, try another query). - 输入代理名称,例如
NOTE
详情提示请查看此仓库了解更多信息。
此外,您可以添加 知识库 和 操作,以增强代理根据用户请求提供更多信息和执行自动任务的能力。对于此练习,可以跳过这些步骤。

- 若要创建新的多 AI 代理,只需点击 新建代理。新创建的代理将显示在代理页面上。
测试代理
创建代理后,您可以在 Microsoft Foundry 门户游乐场测试代理的响应。
在代理的 设置 面板顶部,选择 在游乐场中试用。
在 游乐场 面板中,您可以通过聊天窗口输入查询与代理交互。例如,您可以让代理搜索 28 日从西雅图到纽约的航班。
注意:由于本练习中未使用实时数据,代理可能无法给出准确答案。目的是测试代理基于所提供的说明理解和响应用户查询的能力。

测试完后,您可以通过添加更多意图、训练数据和操作进一步自定义代理以增强其功能。
清理资源
测试完代理后,您可以将其删除,以避免产生额外费用。
- 打开 Azure 门户,查看您用于本练习中部署中枢资源的资源组内容。
- 在工具栏选择 删除资源组。
- 输入资源组名称并确认删除。