使用應對手冊建構及測試襯衫訂購代理。使用代理詢問商店位置、取得營業時間或訂購襯衫。
事前準備
如果您尚未完成設定,請按照操作說明進行。
關於應對手冊
代理包含一或多個 playbook。每份應對手冊都有明確定義且有限的範圍。下表說明教戰手冊中的資料:
| X | 項目 |
|---|---|
| 名稱 | 用於識別教戰手冊的名稱。 |
| 目標 | 目標代表應對手冊需完成的工作。 |
| 操作說明 | 指令是達成應對手冊目標所需的高階步驟。 |
| 範例 | 範例是使用者與代理之間的對話樣本。這些範例實際上是 LLM 的少量樣本提示範例。 |
建立虛擬服務專員
如何建立代理:
- 前往 https://conversational-agents.cloud.google.com。
- 選取或建立專案 (如果尚未建立)。
- 點選「建立代理」。
- 點按「自行建立」。
- 輸入「Shirt Ordering - Playbooks」做為代理名稱。
- 輸入位置。
- 輸入時區。
- 輸入預設語言。
- 在「Conversation start」選項中選取「Playbook」。
- 點選「建立」。
- 使用者介面會將您導向預設的生成式代理應對手冊,名為「Default Generative Playbook」。
- 按一下「返回」,回到應對手冊清單。
建立訂單應對手冊
Order 應對手冊會處理襯衫訂單。
如要建立應對手冊,請按照下列步驟操作:
- 點選「建立」。
- 選取「工作應對手冊」選項。
- 輸入應對手冊名稱:
Order。 輸入下列目標:
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.輸入下列指示:
- 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.按一下 [儲存]。
按一下「返回」,回到應對手冊清單。
建立資訊應對手冊
資訊:處理與商店相關的問題。
如要建立應對手冊,請按照下列步驟操作:
- 點選「建立」。
- 選取「工作應對手冊」選項。
- 輸入應對手冊名稱:
Information。 輸入下列目標:
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.輸入下列指示:
- 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.按一下 [儲存]。
按一下「返回」,回到應對手冊清單。
更新預設應對手冊
首次建立代理時,系統會為您建立預設的應對手冊。這份教戰手冊會將對話引導至具有特定目標的適當教戰手冊。您可以按照下列操作說明,瞭解預設教戰手冊如何參照其他教戰手冊。
如要更新教戰手冊,請按照下列步驟操作:
- 按一下標有星號的預設教戰手冊。
輸入下列目標:
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.輸入下列指示:
- 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}按一下 [儲存]。
請注意,Playbook 參照會醒目顯示,因為目前還沒有範例。您將在下一節新增範例。
按一下「返回」,回到應對手冊清單。
提供範例
應對手冊可正常運作,但提供範例可確保回覆品質。
開啟 Playbook 時,您可以透過「Examples」(範例) 分頁提供範例。不過,與代理對話並將對話儲存為範例,通常會比較容易。
預設的 Playbook 對話很簡短。這個應對手冊需要將對話導向其他應對手冊。
如要與預設的 Playbook 對話,請按照下列步驟操作:
- 關閉或取消畫面右側可能顯示的任何面板。
- 輕觸頂端列導覽中的模擬器按鈕 。
- 在「資源」部分選取預設的 Playbook。
- 使用預設模型或選取其他模型。
- 在「Enter user input」(輸入使用者輸入內容) 欄位中輸入
Hello,然後按下 Enter 鍵。 - 應對手冊會回覆問候語。
如要將這段對話儲存為範例,請按照下列步驟操作:
- 在「Invocations」(叫用) 清單中,選取預設應對手冊。
- 按一下「儲存為範例」。
- 在範例編輯器面板中,新增、編輯、刪除或重新排序動作。
- 輸入
Greeting做為範例名稱。 - 視需要更新教戰手冊回覆。
- 在「End example with output information」(以輸出資訊結束範例) 部分,在「Summary」(摘要) 欄位中輸入
The user is greeted.。 - 按一下 [儲存]。
新增資訊教戰手冊的位置範例:
- 關閉或取消畫面右側的任何面板。
- 如有需要,請使用「重設」restart_alt 按鈕重設對話。
- 在模擬器的「Start Resource」選單中,選取資訊 Playbook。
- 輸入
Where are you located?,然後按下 Enter 鍵。 - 在「叫用」選單中,選取資訊教戰手冊。
- 按一下「儲存為範例」。
- 輸入
Location做為範例名稱。 - 刪除含有
Where are you located?的動作,因為只有預設的教戰手冊範例可以從使用者動作開始。 - 展開「Summary of the preceding conversation」(先前對話摘要) 區段,然後在「Starts example with input information」(以輸入資訊開始範例) 欄位中輸入
The customer asked "Where are you located?"。 - 展開「Summary of the playbook execution」(Playbook 執行摘要) 區段,然後在「End example with output information」(以輸出資訊結束範例) 欄位中輸入
The store is located at 1007 Mountain Drive, Gotham City, NJ.。 - 按一下 [儲存]。
在資訊教戰手冊中新增營業時間範例:
- 在模擬工具中選取資訊應對手冊。
- 輸入訊息
What are your hours?。 - 將對話儲存為範例,並命名為
Hours。
請按照下列步驟,為訂購範本新增選取範例:
- 將範例命名為
Selection。 - 選取訂單應對手冊。
- 傳送下列訊息:
I want to buy a shirtLargeGreenYes
測試代理
現在可以測試代理了。開啟模擬工具面板,與代理對話。您可以進行與上述不同的對話。舉例來說,您可以詢問這個代理,襯衫有哪些顏色。如果未達到所需結果,請修正或新增樣本,提升回覆品質。
使用 API 與代理互動
如要進一步瞭解如何與 API 互動,請參閱「與 API 互動」。