使用應對手冊建構代理程式

本指南說明如何使用 Playbook 建構及測試簡單的襯衫訂購服務。與這位服務專員互動時,你可以詢問商店位置、營業時間,或訂購襯衫。

事前準備

閱讀本指南之前,請先完成下列工作:

  1. 如果您尚未設定,請按照設定說明操作。

關於應對手冊

代理人由一或多個應對手冊組成。每個應對手冊的範圍都已明確界定且受限。Playbook 包含以下資料:

X 項目
名稱 用於識別 Playbook 的名稱。
目標 目標:概略說明 Playbook 應達成的目標。
操作說明 操作說明:為了達成 Playbook 的目標,應採取的高階步驟。
範例 「示例」是指使用者和服務專員之間的對話示例。這些範例對 LLM 來說,就是少量樣本提示。

建立代理程式

如要建立代理程式,請按照下列步驟操作:

  1. 前往 Conversational Agents 控制台:

    Conversational Agents 控制台

  2. 選取或建立專案 (如果沒有的話)。

  3. 按一下「建立服務專員」

  4. 按一下「建立自己的內容」

  5. 請將「Shirt Ordering - Playbooks」提供為代理商名稱。

  6. 提供位置

  7. 提供時區。

  8. 提供預設語言

  9. 在「Conversation start」選項中選取「Playbook」

  10. 按一下 [建立]。

  11. 使用者介面會將您導向名為「Default Generative Playbook」的預設 Playbook。

  12. 按一下返回按鈕,查看 Playbook 清單。

建立訂單應對手冊

訂單應對手冊會處理上衣訂單。如要建立這個應對手冊,請按照下列步驟操作:

  1. 按一下 [建立]。
  2. 選取「Task playbook」選項。
  3. 輸入應對手冊名稱:Order
  4. 輸入以下目標:

    You are a shirt store ordering assistant. Help customers purchase shirts.
    Help the customer choose a size and color.
    The shirts come in small, medium, and large.
    The shirts can be red, green, or blue.
    
  5. 輸入下列指示:

    - If the customer has not provided a size, ask them to choose a size.
    - If the customer has not provided a color, ask them to choose a color.
    - Once the customer has selected a size and color for the shirt,
      repeat the selection to the customer, and ask them to confirm the selection.
    - Once the customer has confirmed their selection,
      let them know that the shirt is now ordered.
    - Do not provide prices or collect payment.
    - Do not collect the customer's name or address.
    
  6. 按一下 [儲存]

  7. 按一下返回按鈕,即可返回 Playbook 清單。

建立資訊應對手冊

資訊手冊可處理商店相關問題。如要建立這個應對手冊,請按照下列步驟操作:

  1. 按一下 [建立]。
  2. 選取「Task playbook」選項。
  3. 輸入應對手冊名稱:Information
  4. 輸入以下目標:

    You provide information about a shirt store.
    The store is open between 8 AM and 6 PM every day.
    The store is located at 1007 Mountain Drive, Gotham City, NJ.
    
  5. 輸入下列指示:

    - If the customer asks for the store location, provide them with the address.
    - If the customer asks for the store hours, provide them with the hours.
    
  6. 按一下 [儲存]

  7. 按一下返回按鈕,即可返回 Playbook 清單。

更新預設 Playbook

您首次建立應用程式時,系統會為您建立預設 Playbook。這個應對手冊應將對話引導至具有特定目標的適當應對手冊。在下方操作說明中,您可以瞭解預設應對手冊如何參照其他應對手冊。如要更新這個教戰手冊,請按照下列步驟操作:

  1. 按一下預設 Playbook。這個教戰手冊有一個醒目的星號。
  2. 輸入以下目標:

    You are an assistant for a shirt store.
    Your name is "Samantha".
    Your job is to direct customers to other playbooks based on the customer's questions.
    
  3. 輸入下列指示:

    - If the customer hasn't been greeted yet, greet the customer,
      introduce yourself, and ask the user how you can help.
    - If the customer wants information about the store,
      route them to ${PLAYBOOK: Information}
    - If the customer wants to purchase a shirt,
      route them to ${PLAYBOOK: Order}
    
  4. 按一下 [儲存]

  5. 請注意,由於尚未提供範例,因此 Playbook 參照會以醒目顯示。這些內容會在下一節中加入。

  6. 按一下返回按鈕,即可返回 Playbook 清單。

提供範例

此時,您的 playbook 已可正常運作。不過,您必須提供示例,才能確保回覆品質。

您可以開啟 Playbook 後,從「Examples」分頁手動提供範例。不過,使用運作中的 Playbook 進行對話,並將對話儲存為範例,通常會更容易。

使用預設劇本的對話範例很短。這個教戰手冊只需要將您導向其他教戰手冊。如要與預設 Playbook 對話:

  1. 關閉或取消畫面右側的任何面板。
  2. 按一下頂端導覽列中的模擬器 按鈕。
  3. 在「資源」中,選取預設的應對手冊。
  4. 使用預設模型或選取其他模型。
  5. 在「Enter user input」文字方塊中輸入 Hello,然後按下 Enter 鍵。
  6. 劇本會回覆問候語。

如要將這場對話儲存為範例:

  1. 在「Invocations」下拉式選單中選取預設 Playbook。
  2. 按一下介面右上方附近的「Save as example」按鈕。
  3. 範例編輯器面板隨即開啟。您可以使用這個編輯器新增、編輯、刪除或重新排序動作。
  4. 提供範例名稱:Greeting
  5. 視需要更新劇本集回覆。
  6. 向下捲動至「End example with output information」,然後在「Summary」部分輸入 The user is greeted.
  7. 按一下儲存圖示。

為資訊策略書新增地點範例:

  1. 關閉或取消畫面右側的任何面板。
  2. 如有需要,請使用重設 restart_alt 按鈕重設對話。
  3. 在模擬器的「Start Resource」下拉式選單中選取資訊劇本集。
  4. 輸入訊息:Where are you located?
  5. 劇本回應地點。
  6. 在「叫用」下拉式選單中選取資訊劇本。
  7. 按一下「另存為範例」按鈕。
  8. 提供範例名稱:Location
  9. 在將這段對話儲存為範例前,請務必刪除包含「Where are you located」的動作。只有預設的 Playbook 範例可以從使用者動作開始。
  10. 如要提供對話開始時的背景資訊,請展開「先前對話摘要...」部分,然後在「開始示例的輸入資訊」欄位中輸入以下內容:The customer asked "Where are you located?"
  11. 如要提供包含完整對話脈絡的範例,請展開「Playbook 執行摘要...」部分,然後在「包含輸出資訊的結尾範例」欄位中輸入以下內容:The store is located at 1007 Mountain Drive, Gotham City, NJ.
  12. 按一下儲存圖示。

為資訊手冊新增營業時間範例:

  1. 與上述步驟類似,但請輸入訊息:What are your hours?,並將範例命名為:Hours

為訂單應對手冊新增選項範例:

  1. 與上述步驟類似,但請將範例命名為 Selection,選取訂單劇本,然後傳送以下訊息:

    • I want to buy a shirt
    • Large
    • Green
    • Yes

測試代理程式

你的服務機器人現在可以進行測試。 開啟模擬器面板,並與服務專員對話。您不必與上述對話相同。舉例來說,你可以詢問這個服務人員襯衫有哪些顏色。如果您沒有獲得預期的行為,請調整示例並建立新的示例,以改善回應。

使用 API 與代理程式互動

請參閱「與 API 互動」一節。