Azure AI代理服务开发

在本练习中,您将使用 Microsoft Foundry 门户 中的 Azure AI 代理服务工具创建航班预订代理。该代理将能够与用户交互并提供有关航班的信息。

先决条件

要完成此练习,您需要具备以下条件:

  1. 具有有效订阅的 Azure 帐户。 免费创建帐户
  2. 您需要获得创建 Microsoft Foundry 中心的权限或有人为您创建一个中心。
    • 如果您的角色是贡献者或所有者,您可以按照本教程中的步骤操作。

创建 Microsoft Foundry 中心

注: Microsoft Foundry 以前称为 Azure AI Studio。

  1. 请按照 Microsoft Foundry 博客文章中的指南创建 Microsoft Foundry 中心。

  2. 创建项目后,关闭显示的所有提示并查看 Microsoft Foundry 门户中的项目页面,该页面应类似于下图:

    Microsoft Foundry 项目

部署模型

  1. 在项目左侧窗格的 我的资产 部分中,选择 模型 + 端点 页面。

  2. 模型 + 端点 页面的 模型部署 选项卡中,在 + 部署模型 菜单中,选择 部署基础模型

  3. 在列表中搜索gpt-4o-mini型号,然后选择并确认。

    注意:减少 TPM 有助于避免过度使用您正在使用的订阅中的可用配额。

    模型已部署

创建代理

现在您已经部署了模型,您可以创建代理。代理是一种对话式人工智能模型,可用于与用户交互。

  1. 在项目左侧窗格的 构建和自定义 部分中,选择 代理 页面。
  2. 单击 + 创建代理 以创建新代理。在 代理设置 对话框下:
    • 输入代理的名称,例如 FlightAgent
    • 确保选择您之前创建的 gpt-4o-mini 模型部署
    • 根据您希望客服人员遵循的提示设置说明。这是一个例子:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    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).

    [!注意]
    有关详细提示,您可以查看此存储库以获取更多信息。

此外,您可以添加知识库操作来增强代理的能力,以提供更多信息并根据用户请求执行自动化任务。对于本练习,您可以跳过这些步骤。

代理设置

  1. 要创建新的多 AI 代理,只需单击 新代理。新创建的代理将显示在代理页面上。

测试代理

创建代理后,您可以测试它以查看它如何响应 Microsoft Foundry 门户 Playground 中的用户查询。

  1. 在代理的 设置 窗格顶部,选择 在游乐场中尝试

  2. Playground 窗格中,您可以通过在聊天窗口中键入查询来与代理进行交互。例如,您可以让代理搜索 28 日从西雅图飞往纽约的航班。

    注意:代理可能无法提供准确的响应,因为此练习中没有使用实时数据。目的是测试代理根据提供的说明理解和响应用户查询的能力。

    特工游乐场

  3. 测试代理后,您可以通过添加更多意图、训练数据和操作来进一步自定义它,以增强其功能。

清理资源

当您完成代理测试后,您可以将其删除以避免产生额外费用。

  1. 打开 Azure 门户 并查看部署本练习中使用的中心资源的资源组的内容。
  2. 在工具栏上,选择“删除资源组”。
  3. 输入资源组名称并确认要删除它。

资源