借助“构建自己的 GenAI 辅助工具”,您可以创建文本生成器并将其与 Agent Assist 集成。文本生成器使用 Text Bison 和 Gemini 等先进的大语言模型 (LLM) 来生成建议。您可以使用这些建议来帮助客户服务对话的参与者(例如人工客服和用户)。生成器可以使用 Agent Assist 中的内置 LLM 调用,这些调用可针对大多数 LLM 任务进行配置。如需详细了解 Agent Assist 中的生成器,请参阅 Vertex AI 文档。
生成器输入
文本生成器需要以下输入:
指令:用于描述您希望文本生成器执行的任务的文本。在 Vertex AI 中,指令称为提示。
模型选项:实现最佳模型性能所需的模型选择和设置,例如温度、输出 token 数量上限、TopK 和 TopP。生成器的输出会受到这些设置的限制。您可以在创建生成器时点击模型选项来选择模型并设置模型选项,也可以使用默认设置。在 Vertex AI 中,模型选项称为形参值。
触发事件:以下事件之一,用于指示何时启动生成器:
END_OF_UTTERANCE
:在每次输入话语后触发生成器。MANUAL_CALL
:仅当您明确进行 API 调用来调用生成器时,才会触发生成器。CUSTOMER_MESSAGE
:仅在每条客户消息之后触发生成器。AGENT_MESSAGE
:仅在每条代理消息之后触发生成器。
生成器输出
向文本生成器提供输入内容后,“打造专属 GenAI 辅助工具”生成器会提供建议,例如文章链接、合适的回答或有关促销优惠的后端信息。 这些建议以文本格式提供,并且在生成时与客户服务对话的上下文相关。
使用场景
本部分将介绍三个应用场景,以展示如何实现“自行构建生成式 AI 辅助生成器”。您的模型可能会生成与以下示例不同的输出回答。
专业改写
您可以指示生成器以专业、礼貌和富有同理心的方式改述人工客服的发言,然后再回复客户,如下所示。
- 生成器名称:专业重写
- 触发事件:客服人员消息
说明:
# TASK DESCRIPTION: Output the agent's response under ## LAST UTTERANCE rewritten in a professional, polite and empathetic way in EXAMPLE 4. - DO NOT miss any information mentioned by the original text. - Only output rewritten response. - You're provided with EXAMPLE 1-3. Follow the format. # EXAMPLE 1 ## CONVERSATION: AGENT: Yo what's up it's Akshay. This is Amazon customer service. What do you want? ## LAST UTTERANCE: Yo what's up it's Akshay. This is Amazon customer service. What do you want? ## OUTPUT: Hi I'm Akshay. Thank you for choosing Amazon customer service. How can I assist you today? # EXAMPLE 2 ## CONVERSATION: CUSTOMER: Hi, I'm having some trouble with my Apple Music subscription. AGENT: Hey, I'm [name]. I can help, I guess. What's your name and account number? CUSTOMER: Sure, my name is [name] and my account number is [number]. AGENT: Alright. Checked that out. You are on Apple Music Individual plan, right? ## LAST UTTERANCE: Alright. Checked that out. You are on Apple Music Individual plan, right? ## OUTPUT: Thank you. I see that you're currently subscribed to the Apple Music Individual plan. Is that correct? # EXAMPLE 3 ## CONVERSATION: AGENT: What is your order number? CUSTOMER: 12345 AGENT: Hang on a sec. Looking. CUSTOMER: I'll wait. AGENT: Alright, it appears your order is not registered. Did you even submit the order? CUSTOMER: Let me double check. Shoot, someone canceled it. Must be the kids. AGENT: Yeah, watch your kids will you? CUSTOMER: I'm so sorry. AGENT: All good. Have a good one. ## LAST UTTERANCE: All good. Have a good one. ## OUTPUT: No problem. I'm glad I can help. Please have a good day! # EXAMPLE 4 ## CONVERSATION: ${parameter:transcript} ## LAST UTTERANCE: ${parameter:transcript_last_utterance} ## OUTPUT:
客户留存率
您还可以指示生成器建议用于挽留客户的客服回答,例如提供产品折扣、追加销售或交叉销售产品,以及解决问题,如下例所示。生成器会通过 IngestContextReferences
API 访问您提供的有关折扣和优惠的信息,作为上下文参考。
- 生成器名称:客户流失与留存
- 触发事件:客户消息
- 上下文参考:优惠
- One:11% 折扣
- Nest:5% 折扣
- 新客户折扣:10%
说明:
# TASK DESCRIPTION: You are an Agent who is helping a customer resolve an issue with complete understanding of the same. - Make sure you wait to understand the concern or query before making any suggestions. - If the customer informs about the issue, you need to ask the exact reason. If the reason is valid, you can give appropriate credit from the OFFERS section. - If the customer is about to cancel an order or subscription, make sure you offer something from the OFFERS section and try to retain the customer. - If a customer is inquiring about a new product, offer some combo for upselling another product. Below are two examples for detecting churn and generating suggestions for mitigation. The output should be a single message suggested to the agent according to the context of the conversation. # EXAMPLE 1 Customer: Hello Agent: Welcome to Google. How may I help you? Customer: I want to cancel order. Agent: Sure Let me have an order ID. Customer: Its 123321 Agent: I could see that you placed an order for Google Nest. May I know the reason for cancellation? Customer: It's available at cheaper rate now. Agent: Ohh.! I see. Let me check the current price and adjust the order price. Is it okay ? Customer: Sure..! I can purchase the product as long as I can get it at the discounted price. I'd definitely go with it Agent: Google Nest costs $200 at present. I can see that you paid $230. Customer: Yeah. Can you request to refund $30. I can buy it at $200. Agent : Sure. I have updated. You will get $30 refund once your order is delivered. Customer: Thanks. Agent : Welcome # EXAMPLE 2 Customer: Hello Agent: Welcome to Google. How may I help you? Customer: I am having Google One Subscription. I think I may need some more space in future. Agent: Okay. May I have your customer Id: Customer: Its 123321 Agent: I could see that you have 100GB Plan at present. How much are you expecting to need in future? Customer: I think I may need 100GB or more. Agent: I could check that you are a loyal customer who had subscriptions since last 6 months. I can provide you 10% discount. Customer: Sure..! That would be great. Agent: 200GB Subscription costs $180 per annum which I can offer you at $162. Customer: That's cool. Thank you. Agent: Is there anything else I can help you with? Customer: No thanks. ## CONTEXT ${parameter:transcript} ## OFFERS ${parameter:offers}
创建生成器
以下示例展示了如何创建“打造专属 GenAI 助理”文本生成器。
控制台
如需使用 Agent Assist 控制台创建生成器,请执行以下操作:
在控制台中,前往Build-your-own-assist页面。
点击创建。
输入生成器的名称。
从列表中选择触发事件。
输入指令以定义任务。
点击模型选项,然后从列表中选择一个模型。
设置参数或使用默认设置。
点击保存,然后再次点击保存以保存生成器。
REST
如需使用 API 创建生成器,请执行以下操作:
- 从 Generator 资源调用
CreateGenerator
方法。 - 在
description
字段中输入生成器的名称。 - 输入触发事件。
- 在 FreeFormContext.text 中输入指令以定义任务。
- 在
published_model
字段中输入模型名称,或将其留空以使用默认模型。 - 在
inference_parameter
字段中指定模型参数,或将其留空以使用默认值。
参数
您可以使用 ${parameter:<parameter_name>}
格式将字词标记为参数,使指令具有上下文相关性。您还可以使用数据提取 API,通过在对话中调用 IngestContextReferences 方法来导入参数的实际值。使用此方法,指令中的参数将在运行时被其值替换。
以下是一个 JSON 示例,展示了如何通过调用 IngestContextReferences 来导入参数值:
{ "contextReferences": { "glossary": { "contextContents": [ { "content": "east one", "contentFormat": "PLAIN_TEXT" } ] } } }
还有一些生成器参数不需要提取。这些内置参数包括:
${parameter:transcript}
:代理与用户之间的对话,包括用户最后一次发言。${parameter:transcript_last_utterance}
:对话中的最后一句话语。
任何指令中都应至少使用一个内置参数。
无论是内置还是提取,生成器参数都不同于创建生成器时设置的模型选项。这些生成器形参的值来自对话转写或提取的数据。另一方面,您可以为生成器整体设置模型选项的值。
测试生成器
在“构建自己的生成式 AI 辅助工具”控制台中,您可以在测试生成器部分测试生成器。
如需在“构建自己的 GenAI 助理”控制台中测试生成器,请执行以下操作:
控制台
- 添加对话的转写内容。您可以手动输入话语,也可以点击上传上传 JSON 格式的转写内容。
- 如需添加更多需要提取的数据,请依次点击 more_vert 和 note_add 添加注入的数据。
“打造专属的生成式 AI 助理”控制台会显示带有生成器名称注释的生成回答。
REST
如需使用 API 测试生成器,请执行以下操作:
- 在
generatorName
字段中输入生成器名称。 - 在
conversationContext
字段中提供对话。 - 在
contextReferences
字段中提供参数值(如有)。 - 在
triggerEvents
字段中输入生成建议的触发条件。 生成的建议位于generatorSuggestion
字段中。
对话资料
对话配置文件定义了一组参数,用于控制对话期间提出的建议。以下步骤将使用 HumanAgentAssistantConfig
对象创建 conversationProfile
资源。
控制台
- 在 Agent Assist 控制台中,前往对话配置文件页面。
- 点击 + 创建。
- 输入显示名称。
- 选择建议类型 check_box Build-your-own-assist。
- 输入生成器的名称,或从列表中选择生成器的名称。
REST
以下是对话个人资料的 JSON 示例。
{ "displayName": "build-your-own-assist-test", "humanAgentAssistantConfig": { "humanAgentSuggestionConfig": { "generators": "projects/PROJECT_ID/locations/global/generators/GENERATOR_ID" } } }
使用模拟器进行验证
您可以在 Agent Assist 模拟器中验证对话配置文件。模拟器会显示生成的响应,并附上生成器的名称。
测试提示
在“打造自己的 GenAI 助理”控制台中,您可以使用模拟器测试提示,就像验证对话配置文件一样。
下图所示的生成输出内容展示了 freeform-tool-test1
生成器遵循示例提示的程度。
运行时对话
对话是指客服人员(包括人工客服人员和虚拟客服人员)与支持客户或最终用户之间的互动。在运行时,当最终用户与人工客服之间开始对话时,您需要创建对话。如需查看建议,您必须创建最终用户参与者和人工客服参与者,并将其添加到对话中。
创建对话
如需创建对话,请执行以下操作:
- 从
conversation resource
调用create
方法。 - 在使用任何请求数据之前,请先进行以下替换:
- PROJECT_ID:您的项目 ID
- CONVERSATION_PROFILE_ID:您的对话配置文件 ID
HTTP 方法和网址:
POST https://dialogflow.googleapis.com/v2/projects/PROJECT_ID/conversations
请求 JSON 正文:
{ "conversationProfile": "projects/PROJECT_ID/conversationProfiles/CONVERSATION_PROFILE_ID", }
在 JSON 响应中,conversations
后面的路径段包含新对话 ID。JSON 响应应如下所示:
{ "name": "projects/PROJECT_ID/conversations/CONVERSATION_ID", "lifecycleState": "IN_PROGRESS", "conversationProfile": "projects/PROJECT_ID/conversationProfiles/CONVERSATION_PROFILE_ID", "startTime": "2023-11-05T21:05:45.622Z" }
创建最终用户参与者
如需创建最终用户参与者,请执行以下操作:
- 从
participants
资源调用create
方法。 - 在使用任何请求数据之前,请先进行以下替换:
- PROJECT_ID:您的项目 ID
- CONVERSATION_ID:您的对话 ID
为角色字段提供对话 ID 和“END_USER”,如下所示。
HTTP 方法和网址:
POST https://dialogflow.googleapis.com/v2/projects/PROJECT_ID/conversations/CONVERSATION_ID/participants
请求 JSON 正文:
{ "role": "END_USER", }
在 JSON 响应中,participants
后面的路径段包含新的最终用户参与者 ID。JSON 响应应如下所示:
{ "name": "projects/PROJECT_ID/conversations/CONVERSATION_ID/participants/USER_PARTICIPANT_ID", "role": "END_USER" }
创建人工客服参与者
如需创建人工客服参与者,请执行以下操作:
- 从
participants
资源调用create
方法。 - 在使用任何请求数据之前,请先进行以下替换:
- PROJECT_ID:您的项目 ID
- CONVERSATION_ID:您的对话 ID
为相应字段提供对话 ID 和 HUMAN_AGENT
角色,如下所示。
HTTP 方法和网址:
POST https://dialogflow.googleapis.com/v2/projects/PROJECT_ID/conversations/CONVERSATION_ID/participants
请求 JSON 正文:
{ "role": "HUMAN_AGENT", }
在 JSON 响应中,participants
后面的路径段包含新的人工客服参与者 ID。响应应类似如下所示:
{ "name": "projects/PROJECT_ID/conversations/CONVERSATION_ID/participants/AGENT_PARTICIPANT_ID", "role": "HUMAN_AGENT" }
分析消息
生成器还可以分析对话中的消息。在对话期间,您可以添加消息,生成器可以使用 participants
资源中的 analyzeContent
方法分析人工客服消息和最终用户消息。
如需添加和分析人工客服消息,请按以下步骤操作。
- 调用
analyzeContent
方法。 - 在使用任何请求数据之前,请先进行以下替换:
- PROJECT_ID:您的项目 ID
- CONVERSATION_ID:您的对话 ID
- PARTICIPANT_ID:您的人工客服参与者 ID
提供对话 ID 和人工客服参与者 ID。您的请求应包含类似以下内容:
HTTP 方法和网址:
POST https://dialogflow.googleapis.com/v2/projects/PROJECT_ID/conversations/CONVERSATION_ID/participants/PARTICIPANT_ID:analyzeContent
请求 JSON 正文:
{ "textInput": { "text": "Bonjour, ici le service client d'ABC fishing, comment puis-je vous aider aujourd'hui ?", "languageCode": "en-US" } }
您应该会收到类似以下内容的 JSON 响应:
{ "message": { "name": "projects/PROJECT_ID/conversations/CONVERSATION_ID/messages/MESSAGE_ID", "content": "Bonjour, ici le service client d'ABC fishing, comment puis-je vous aider aujourd'hui ?", "languageCode": "en-US", "participant": "PARTICIPANT_ID", "participantRole": "HUMAN_AGENT", "createTime": "2023-02-13T00:01:30.683Z" }, "humanAgentSuggestionResults": [{ "generateSuggestionsResponse": { "generatorSuggestionAnswers": [{ "generatorSuggestion": { "freeFormSuggestion": { "response": "Hello, this is ABC fishing customer service, how can I help you today?" } }, "sourceGenerator": "projects/PROJECT_ID/locations/global/generators/GENERATOR_ID", "answerRecord": "projects/PROJECT_ID/locations/global/answerRecords/ANSWER_RECORD_ID" }], "latestMessage": "projects/PROJECT_ID/locations/global/conversations/CONVERSATION_ID/messages/MESSAGE_ID" } }] }
添加和分析最终用户消息
- 调用
analyzeContent
方法。如果该方法已针对其他 Agent Assist 功能调用,请勿重复调用。 - 在使用任何请求数据之前,请先进行以下替换:
- PROJECT_ID:您的项目 ID
- CONVERSATION_ID:您的对话 ID
- PARTICIPANT_ID:您的人工客服参与者 ID
提供对话 ID 和人工客服参与者 ID。您的请求应包含类似以下内容:
HTTP 方法和网址:
POST https://dialogflow.googleapis.com/v2/projects/PROJECT_ID/conversations/CONVERSATION_ID/participants/PARTICIPANT_ID:analyzeContent
请求 JSON 正文:
{ "textInput": { "text": "Hi", "languageCode": "en-US" } }
您应该会收到类似以下内容的 JSON 响应:
{ "message": { "name": "projects/PROJECT_ID/conversations/CONVERSATION_ID/messages/MESSAGE_ID", "content": "Hi", "languageCode": "en-US", "participant": "PARTICIPANT_ID", "participantRole": "END_USER", "createTime": "2020-02-13T00:07:35.925Z" }, "humanAgentSuggestionResults": [{ "generateSuggestionsResponse": { "generatorSuggestionAnswers": [{ "generatorSuggestion": { "freeFormSuggestion": { "response": "Salut" } }, "sourceGenerator": "projects/PROJECT_ID/locations/global/generators/GENERATOR_ID", "answerRecord": "projects/PROJECT_ID/locations/global/answerRecords/ANSWER_RECORD_ID" }], "latestMessage": "projects/PROJECT_ID/locations/global/conversations/CONVERSATION_ID/messages/MESSAGE_ID" } }] }
如果对话已完成且未使用 analyzeContent
,您可以使用 messages 资源中的 batchCreate
方法导入和分析对话的历史消息。
获取建议
生成器还会在对话中的任何时间点针对消息提供建议。默认情况下,建议是针对任一参与者的最新消息。您还可以指定要获取建议的消息。默认情况下或使用以下资源之一获取建议。
使用内置建议
analyzeContent
的响应附带建议。触发的生成器会生成这些建议。您的 JSON 请求应包含类似以下内容:
HTTP 方法和网址:
POST https://dialogflow.googleapis.com/v2/projects/PROJECT_ID/conversations/CONVERSATION_ID/participants/PARTICIPANT_ID:analyzeContent
请求 JSON 正文:
{ "textInput": { "text": "I want to reserve a room.", "languageCode": "en-US" } }
使用 suggestions
资源
获取建议的另一种方法是按以下步骤操作。
- 从
suggestions
资源调用generate
方法。 - 在使用任何请求数据之前,请先进行以下替换:
- PROJECT_ID:您的项目 ID
- CONVERSATION_ID:您的对话 ID
- PARTICIPANT_ID:您的人工客服参与者 ID
提供对话 ID、任一参与者的最新消息 ID 以及触发事件。如果未设置消息 ID 字段,则默认情况下,建议基于任一参与者的最新消息。然后,系统会启动与触发事件关联的生成器。您的 JSON 请求应包含类似以下内容:
HTTP 方法和网址:
POST https://dialogflow.googleapis.com/v2/projects/PROJECT_ID/conversations/CONVERSATION_IDsuggestions:generate
请求 JSON 正文:
{ "latestMessage": "projects/PROJECT_ID/conversations/CONVERSATION_IDmessages/Message_ID", "triggerEvents": [ "END_OF_UTTERANCE" ] }
使用 statelessSuggestion
资源
获取建议的最后一种方法是按以下步骤操作。
- 从
statelessSuggestion
资源调用generate
方法。 - 在使用任何请求数据之前,请先进行以下替换:
- PROJECT_ID:您的项目 ID
- LOCATION_ID:您的位置 ID
提供生成器、对话的消息以及包含已提取数据的上下文引用。注入的数据会替换生成器指令中的参数。您的 JSON 请求应类似于以下内容:
HTTP 方法和网址:
https://dialogflow.googleapis.com/v2/projects/PROJECT_ID/locations/LOCATION_ID/statelessSuggestion:generate
请求 JSON 正文:
{ "generator": { "description": "Translation", "triggerEvent": "END_OF_UTTERANCE", "freeFormContext": { "text": "Read the conversation between agent and customer, and the last utterance. Output the last utterance from customer by following these instructions: - If the last utterance from AGENT, output the utterance by translating it to English. - If the last utterance from CUSTOMER, output the utterance by translating it to French. - Specific brand names and technical terms specified under 'GLOSSARY' section, such as 'Google Home,' should remain unchanged as per the glossary guidelines. # GLOSSARY ${parameter:glossary} # CONVERSATION: ${parameter:transcript} # LAST UTTERANCE: ${parameter:transcript_last_utterance} # OUTPUT: " } }, "contextReferences": { "glossary": { "contextContents": { "content": "east one", "contentFormat": "PLAIN_TEXT" } } }, "conversationContext": { "messageEntries": [ { "text": "hi", "languageCode": "en-US", "role": "END_USER", "createTime": { "seconds": "1400000000", "nanos": "10000000" } }, { "text": "Bonjour, comment puis-je vous aider aujourd\\'hui ?", "languageCode": "en-US", "role": "HUMAN_AGENT", "createTime": { "seconds": "1400000010", "nanos": "10000000" } } ] }, "triggerEvents": [ "END_OF_UTTERANCE" ] }
配额限制
您可以在 Dialogflow 配额页面上查看 Agent Assist 的配额和限制。构建自己的生成式 AI 助理包括以下配额限制:
名称 | 说明 | 限制 |
---|---|---|
每分钟的生成器管理器操作数(每个区域) | 每分钟可执行的生成器管理器操作数量上限,例如创建、列出或删除生成器。 | 300 |
生成器(每个区域) | 单个项目中可创建的生成器数量上限。 | 200 |
每种模型类型(每个区域)每分钟的生成器建议操作数 | 每分钟可接收的每种模型类型的生成器建议操作请求数量的限制。 | 10 |