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

使用應對手冊建構及測試訂購襯衫的服務專員。你可以透過智慧助理詢問商店位置、營業時間,或訂購襯衫。

事前準備

如果尚未設定,請按照設定操作說明進行。

關於應對手冊

代理程式由一或多個應對手冊組成。每本應對手冊都有明確定義的有限範圍。下表說明劇本中的資料:

X 項目
名稱 用於識別劇本的名稱。
目標 目標:簡要說明應對手冊應完成的工作。
操作說明 指示是為達成應對手冊目標而應採取的高階步驟。
範例 範例是使用者與代理程式之間的對話範例。這些範例實際上是 LLM 的少量樣本提示範例。

建立虛擬服務專員

如何建立代理程式:

  1. 前往 https://conversational-agents.cloud.google.com。
  2. 如果尚未選取或建立專案,請先這麼做。
  3. 點選「建立代理」
  4. 點按「自行建立」
  5. 輸入「Shirt Ordering - Playbooks」做為代理名稱。
  6. 輸入地點
  7. 輸入時區。
  8. 輸入預設語言
  9. 在「Conversation start」選項中選取「Playbook」
  10. 點選「建立」
  11. 使用者介面會將您帶往名為「Default Generative Playbook」的預設 Playbook。
  12. 按一下「返回」,返回劇本清單。

建立訂單應對手冊

Order 應對手冊會處理襯衫訂單。

如要建立應對手冊,請按照下列步驟操作:

  1. 點選「建立」
  2. 選取「工作應對手冊」選項。
  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. 按一下「返回」,返回劇本清單。

建立資訊應對手冊

資訊劇本會處理有關商店的問題。

如要建立應對手冊,請按照下列步驟操作:

  1. 點選「建立」
  2. 選取「工作應對手冊」選項。
  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. 按一下「返回」,返回劇本清單。

更新預設劇本

首次建立代理程式時,系統會為您建立預設應對手冊。這本教戰手冊會引導對話轉向以特定目標為主的適當教戰手冊。您可以參閱下列操作說明,瞭解預設教戰手冊如何參照其他教戰手冊。

如要更新劇本,請按照下列步驟操作:

  1. 按一下標示星號的預設劇本。
  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 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. 請注意,由於目前沒有範例,劇本參照會醒目顯示;您將在下一節中新增這些參照。

  6. 按一下「返回」,返回劇本清單。

提供範例

應對手冊可以運作,但提供範例可確保回覆品質。

開啟劇本後,您可以在「範例」分頁中提供範例; 不過,與代理程式對話並將對話儲存為範例通常會比較簡單。

預設的 Playbook 對話很簡短,本教戰手冊必須將對話導向其他教戰手冊。

如要與預設劇本對話,請按照下列步驟操作:

  1. 關閉或取消畫面右側可能顯示的任何面板。
  2. 輕觸頂端列導覽中的模擬器 按鈕。
  3. 在「資源」中,選取預設的劇本。
  4. 使用預設模型或選取其他模型。
  5. 在「Enter user input」(輸入使用者輸入內容) 欄位中輸入 Hello,然後按 Enter 鍵。
  6. 應對手冊會回覆問候語。

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

  1. 在「Invocation」(叫用) 清單中選取預設應對手冊。
  2. 按一下「儲存為範例」
  3. 在範例編輯器面板中,新增、編輯、刪除或重新排序動作。
  4. 輸入 Greeting 做為範例名稱。
  5. 視需要更新劇本回覆。
  6. 在「End example with output information」(以輸出資訊結尾的範例) 部分,於「Summary」(摘要) 欄位中輸入 The user is greeted.
  7. 按一下 [儲存]

為資訊劇本新增位置範例:

  1. 關閉或取消畫面右側的任何面板。
  2. 如有需要,請按一下「重設」 restart_alt 按鈕,重設對話。
  3. 在模擬器的「開始資源」選單中,選取資訊劇本。
  4. 輸入 Where are you located?,然後按 Enter 鍵。
  5. 在「Invocations」(叫用) 選單中選取資訊劇本。
  6. 按一下「儲存為範例」
  7. 輸入 Location 做為範例名稱。
  8. 刪除包含 Where are you located? 的動作,因為只有預設劇本範例可以從使用者動作開始。
  9. 展開「Summary of the preceding conversation」(先前對話的摘要) 區段,然後在「Starts example with input information」(以輸入資訊開始範例) 欄位中輸入 The customer asked "Where are you located?"
  10. 展開「劇本執行摘要」部分,然後在「End example with output information」(以輸出資訊結尾的範例) 欄位中輸入 The store is located at 1007 Mountain Drive, Gotham City, NJ.
  11. 按一下 [儲存]

在資訊劇本中新增營業時間範例:

  1. 在模擬工具中選取資訊應對手冊。
  2. 輸入訊息 What are your hours?
  3. 將對話儲存為名為 Hours 的範例。

請按照下列步驟,為訂單劇本新增選取範例:

  1. 將範例命名為 Selection
  2. 選取訂單應對手冊。
  3. 傳送下列訊息:
    • I want to buy a shirt
    • Large
    • Green
    • Yes

測試代理

現在可以測試代理程式了。開啟模擬工具面板,與代理進行對話。你可以進行與上述不同的對話。舉例來說,你可以詢問這個代理程式襯衫有哪些顏色。如果沒有獲得所需結果,請調整或新增範例,提升回覆品質。

使用 API 與代理程式互動

如要進一步瞭解如何與 API 互動,請參閱「與 API 互動」。