本页介绍搜索以及 Vertex AI Search 和 展示了如何使用 API 调用来实现它。
如果要在搜索微件中添加带有跟进搜索功能,请参阅配置 搜索结果。
搜索并跟进功能不适用于 Vertex AI 客服应用。Vertex AI 客服应用使用可与最终用户就内容进行对话的客服。如需详细了解 Vertex AI Agent,请参阅 Vertex AI Agent 简介。
跟进搜索简介
跟进搜索基于生成式 AI 模型。跟进搜索 与常规非结构化数据不同, search,因为使用 跟进操作会考虑同一搜索会话中之前的搜索查询。
跟进搜索支持以下功能:
自然语言查询处理:处理和理解人类语言输入,识别查询背后的意图,并返回相关结果。
情境感知:它可以理解之前互动的情境,并提供情境感知型回答。
多轮对话:用户可以提出后续问题并获得相关回答。
跟进搜索示例
以下是带有跟进搜索的示例。假设您想了解墨西哥的度假信息:
您:一年中什么时候最适合去墨西哥度假?
跟进搜索:在干燥的天气下,墨西哥度假的最佳时间是 从 11 月持续到次年 4 月
您:汇率是多少?
跟进搜索:1 美元约等于 17.65 墨西哥比索。
您:12 月的平均温度是多少?
跟进搜索:平均体温在 70-78°F 之间。 Cancun 的平均气温约为 77°F。
通过常规搜索,您的问题“汇率是多少”?不会 因为常规搜索并不知道您是想查找墨西哥文字 汇率。同样,常规搜索不会保留上下文,因此无法为您提供墨西哥的温度。
对话简介
在搜索跟进搜索时,会话由 和响应。
这些查询和响应对有时被称为“消息”。在 在前面的示例中,第二条消息由“What is the rate?”(汇率是多少?)组成 “1 美元约等于 17.65 墨西哥比索”。
对话存储在非结构化数据所在的同一个数据存储区中 。在数据存储区中,对话由对话资源表示。除了包含询问和回复消息之外,对话资源还包含:
唯一名称(对话 ID)。
状态(进行中或已完成)。
用户伪 ID,即跟踪用户的访问者 ID。您可以通过编程方式进行分配。
开始时间和结束时间。
准备工作
请确保您满足以下前提条件。具体要求因情况而异 您的应用类型。
存储对话和获取回复
您可以使用命令行或客户端库生成搜索响应 以及存储搜索跟进对话。
REST
要使用命令行创建对话,并从 请按以下步骤操作:
指定您要存储对话记录的数据存储区:
curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID/conversations" \ -d '{ "user_pseudo_id": "USER_PSEUDO_ID" }'
PROJECT_ID:您的 Google Cloud 项目的项目编号或 ID
DATA_STORE_ID:与您的应用关联的数据存储区的 ID。
USER_PSEUDO_ID:这是用于跟踪 。例如,您可以使用 HTTP Cookie 用于在单个设备上唯一标识访问者。
点击查看
POST
命令。{ "name": "projects/12345/locations/global/collections/default_collection/dataStores/my-data-store_4321/conversations/11078281986791420687", "state": "IN_PROGRESS", "userPseudoId": "test_id", "startTime": "2023-08-15T20:08:12.094639Z" }
生成搜索响应,并将其添加到新会话或现有会话 您的数据存储区:
curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID/conversations/CONVERSATION_ID:converse" \ -d '{ "query": { "input": "FREE_TEXT"}, "filter": "FILTER" }'
PROJECT_ID:您的 Google Cloud 项目的项目编号或 ID
DATA_STORE_ID:与您的应用关联的数据存储区的 ID。
CONVERSATION_ID:对话的唯一 ID, 示例:
123456
。对于包含跟进问题的搜索对话,请在每轮对话中使用相同的对话 ID。FREE_TEXT:一个自由文本字符串,其中包含用户 问题,例如
what is bigquery?
FILTER:用于使用过滤表达式过滤搜索结果的文本字段。默认值为空字符串。过滤条件的构建方式因您拥有的是网站数据还是带有元数据的非结构化数据而异。有关详情,请参阅过滤 跟进搜索。
点击查看
POST
命令的示例响应。{ "reply": { "summary": { "summaryText": "BigQuery is a cloud-based data warehouse that enables businesses to analyze all their data very quickly. It is a fully managed service that provides a simple and cost-effective way to store and analyze large amounts of data." } }, "conversation": { "name": "projects/12345/locations/global/collections/default_collection/dataStores/my-data-store_4321/conversations/11078281986791420687", "state": "IN_PROGRESS", "userPseudoId": "test_id", "messages": [ { "userInput": { "input": "what is bigquery?" } }, { "reply": { "summary": { "summaryText": "BigQuery is a cloud-based data warehouse that enables businesses to analyze all their data very quickly. It is a fully managed service that provides a simple and cost-effective way to store and analyze large amounts of data." } } } ], "startTime": "2023-08-15T20:08:12.094639Z" }, "searchResults": [ { "id": "c86f19582746b56f71c9bb6929893835", "document": { "name": "projects/12345/locations/global/collections/default_collection/dataStores/my-data-store_4321/branches/0/documents/c86f19582746b56f71c9bb6929893835", "id": "c86f19582746b56f71c9bb6929893835", "derivedStructData": { "link": "gs://aquamuse-data-ucs-eval-dev/documents/94627ee0249dfdfda25b1b158c717bca.txt", "snippets": [ { "snippet_status": "SUCCESS", "snippet": "For larger websites, talk to the IT team and/or utilize a big data solution such as Google \u003cb\u003eBigQuery\u003c/b\u003e to extract all URLs. It may also be necessary to ask the ..." } ], "extractive_answers": [ { "content": "Alternatively, load the Server Log Files into Google BigQuery and use the Google BigQuery interface or the 360 Data Studio to analyze the data. To monitor the indexation numbers of the HTTP and the HTTPS version, keep an eye on all submitted XML Sitemaps." } ] } } }, { "id": "774bd7ce2a3509ab4bbd1fc876f39dc2", "document": { "name": "projects/12345/locations/global/collections/default_collection/dataStores/my-data-store_4321/branches/0/documents/774bd7ce2a3509ab4bbd1fc876f39dc2", "id": "774bd7ce2a3509ab4bbd1fc876f39dc2", "derivedStructData": { "snippets": [ { "snippet": "No snippet is available for this page.", "snippet_status": "NO_SNIPPET_AVAILABLE" } ], "extractive_answers": [ { "content": "This consists of a collection of virtual tables. A virtual table exists for every queryable object type (content type if you prefer) in the repository. Each row in these virtual tables correspond to an instance of the corresponding object type (or of one of its subtypes)." } ], "link": "gs://aquamuse-data-ucs-eval-dev/documents/28841ef8590a105e9415f1390648a811.txt" } } }, { "id": "3e1d306e49aefd9e23f2d5f7a66e6c76", "document": { "name": "projects/12345/locations/global/collections/default_collection/dataStores/my-data-store_4321/branches/0/documents/3e1d306e49aefd9e23f2d5f7a66e6c76", "id": "3e1d306e49aefd9e23f2d5f7a66e6c76", "derivedStructData": { "snippets": [ { "snippet": "No snippet is available for this page.", "snippet_status": "NO_SNIPPET_AVAILABLE" } ], "extractive_answers": [ { "content": "Other logo switches are based on search terms. For instance, if the term "ASCII art" is searched, an ASCII art version of the Google logo will appear next to the search box." } ], "link": "gs://aquamuse-data-ucs-eval-dev/documents/98008df3eef5d3ee1661c52f23189190.txt" } } }, { "id": "cf94e24aacd47cd2c2f5effcbdeda832", "document": { "name": "projects/12345/locations/global/collections/default_collection/dataStores/my-data-store_4321/branches/0/documents/cf94e24aacd47cd2c2f5effcbdeda832", "id": "cf94e24aacd47cd2c2f5effcbdeda832", "derivedStructData": { "extractive_answers": [ { "content": "The company is listed on the NASDAQ stock exchange under the ticker symbols GOOGL and GOOG, and on the Frankfurt Stock Exchange under the ticker symbol GGQ1. These ticker symbols now refer to Alphabet Inc., Google's holding company, since the fourth quarter of 2015." } ], "snippets": [ { "snippet": "No snippet is available for this page.", "snippet_status": "NO_SNIPPET_AVAILABLE" } ], "link": "gs://aquamuse-data-ucs-eval-dev/documents/d80204083ef1096799fa4b7257548b33.txt" } } }, { "id": "05bc6497a4e7e6ca36b2e495b354b764", "document": { "name": "projects/12345/locations/global/collections/default_collection/dataStores/my-data-store_4321/branches/0/documents/05bc6497a4e7e6ca36b2e495b354b764", "id": "05bc6497a4e7e6ca36b2e495b354b764", "derivedStructData": { "extractive_answers": [ { "content": "SQL injection countermeasures are designed to utilize secure programming methods. By changing the variables used by the application code, weaknesses in applications can be greatly minimized. This report will detail how to perform a SQL injection and explore the best countermeasures to prevent the attack." } ], "link": "gs://aquamuse-data-ucs-eval-dev/documents/7cba75d646f5774a21d96801bec68bb3.txt", "snippets": [ { "snippet_status": "NO_SNIPPET_AVAILABLE", "snippet": "No snippet is available for this page." } ] } } } ] }
针对对话中的每个新问题重复第 2 步。
Python
如需了解详情,请参阅 Vertex AI Agent Builder Python API 参考文档。
如需向 Vertex AI Agent Builder 进行身份验证,请设置应用默认凭据。 如需了解详情,请参阅为本地开发环境设置身份验证。
过滤后续跟进的搜索
使用“搜索并跟进”功能进行查询时,您可以添加 filter
字段,以限制用于派生回答的文档池。您可以使用过滤表达式构建过滤器。您使用的过滤表达式因您拥有的是网站数据还是包含元数据的非结构化数据而异。
网站数据的过滤表达式
如果您有包含网站数据的数据存储区,则可以使用高级网站索引编制中的过滤表达式中的过滤表达式,通过跟进查询过滤搜索结果。构建过滤条件表达式后,请在存储对话和获取响应的第 2 步中将其用作 filter
字段的值。
过滤包含元数据的非结构化数据的表达式
如果您的数据存储区包含带有元数据的非结构化数据,则可以过滤
执行后续查询,以便根据查询返回文档,
元数据字段。如需了解如何使用元数据过滤普通搜索(不进行后续跟进),请参阅过滤结构化或非结构化数据的搜索结果。您可以使用同样的原则,通过元数据过滤包含跟进信息的搜索。构建过滤条件表达式后,将其用作存储对话和获取响应的第 2 步中 filter
字段的值。
配置摘要
搜索(附带跟进)的响应消息是 summaryText
中返回的生成摘要。您可以通过多种方式配置生成的摘要。以下部分介绍了这些功能:
在搜索结果中获取引用
指定引用时,是指内嵌在搜索中的数字。 摘要。这些数字表示搜索结果中特定句子从 摘要。
如需获取引用,请执行以下操作:
请按照上文中的存储对话和获取聊天回复过程操作,但在第 2 步中,请运行以下命令,其中包含用于将
includeCitations
设置为 true 的summarySpec
字段。curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID/conversations/CONVERSATION_ID:converse" \ -d '{ "query": { "input": "FREE_TEXT"}, "summarySpec": { "include_citations": true } }'
点击即可查看部分回答内容 命令。
{ "reply": { "summary": { } "reply": { "summary": { "summaryText": "BigQuery is a cloud-based data warehouse that enables businesses to analyze all their data very quickly [1]. It is a fully managed service that provides a simple and cost-effective way to store and analyze large amounts of data [2, 3].", "safetyAttributes": { "categories": [ "Finance", "Legal" ] …
摘要文本中包含引用编号。引用编号是指
返回的搜索结果,并且从 1 开始编制索引。例如,[1]
表示
系统会将句子归因于第一个搜索结果。[2, 3]
表示该句子同时归因于第二个和第三个搜索结果。
忽略对抗性查询
恶意查询包含负面评论,或者旨在生成不安全、违反政策的输出。您可以指定不应显示任何搜索摘要
对抗性查询返回的值。当系统忽略对抗性查询时,summaryText
属性会包含表示未返回任何搜索摘要的样本文字。系统会针对对抗性查询返回搜索文档,但不会返回搜索摘要。
如需指定不应针对对抗性查询返回搜索摘要,请执行以下操作:
请按照上文中的存储对话和获取聊天回复过程操作,但在第 2 步中,请运行以下命令,其中包含用于将
ignoreAdversarialQuery
设置为 true 的summarySpec
字段。curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID/conversations/CONVERSATION_ID:converse" \ -d '{ "query": { "input": "FREE_TEXT"}, "summarySpec": { "ignoreAdversarialQuery": true } }'
点击可查看对抗性询问的部分回答。
"reply": { "summary": { "summaryText": "A summary could not be generated for your search query. Here are some search results.", "summarySkippedReasons": [ "ADVERSARIAL_QUERY_IGNORED" ] …
忽略非摘要查询
非摘要搜索查询返回的结果不适合 摘要。例如,“为什么天空是蓝色的”以及“谁是最棒的足球运动员” “世界上的球员?”查询摘要,而“旧金山国际机场”和“全世界” 2026 年杯”。这很可能是导航查询。您可以指定 不针对非摘要搜索查询返回任何搜索摘要。 对于非摘要搜索查询,即使执行搜索,也会返回搜索文档 摘要则不然。
如需指定不应针对非摘要查询返回搜索摘要,请执行以下操作:
请按照上文中的存储对话和获取聊天回复过程操作,但在第 2 步中,请运行以下命令,其中包含用于将
ignoreNonSummarySeekingQuery
设置为 true 的summarySpec
字段。curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID/conversations/CONVERSATION_ID:converse" \ -d '{ "query": { "input": "FREE_TEXT"}, "summarySpec": { "ignore_non_summary_seeking_query": true } }'
点击获取对抗性回答的部分内容 查询。
"reply": { "summary": { "summaryText": "A summary could not be generated for your search query. Here are some search results.", "summarySkippedReasons": [ "NON_SUMMARY_SEEKING_QUERY_IGNORED" ] …
设置摘要中要使用的结果数量
您可以指定用于生成摘要的结果数量。修改者
默认情况下,如果未设置 summaryResultCount
字段,则返回所有结果
用于生成摘要。
如需设置要用于摘要的热门结果数量,请执行以下操作:
请按照上文中的存储对话和获取聊天回复过程操作,但在第 2 步中,请运行以下包含用于设置
summaryResultCount
的summarySpec
字段的命令。curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID/conversations/CONVERSATION_ID:converse" \ -d '{ "query": { "input": "FREE_TEXT"}, "summarySpec": { "summary_result_count": NUMBER_OF_RESULTS } }'
NUMBER_OF_RESULTS:用于生成搜索摘要的热门搜索结果的数量。如果返回的结果数量少于
summaryResultCount
,系统会根据所有结果生成摘要。最大值为5
。
获取自定义摘要
你可以通过提供自然语言指令来获取自定义摘要,
modelPromptSpec.preamble
字段。
您可以请求自定义内容,如长度和详细程度、 输出内容(如“简单”)、输出语言、答案重点和格式(如 以表格、项目符号和 XML 的形式指定)。
例如,对于查询“BigQuery 有哪些优势?”,您可以输入自定义说明,如以下示例所示:
示例说明:
"please show the answer format in an ordered list"
回答示例:
The benefits of BigQuery are: 1. Increased business productivity 2. IT staff productivity 3. Reduced infrastructure costs 4. Loading and exporting data are free
示例说明:
give a very detailed answer
回答示例:
BigQuery is a serverless, highly scalable, and cost-effective cloud data warehouse that enables businesses to analyze all their data very quickly. It is a fully managed service that takes care of provisioning, scaling, and managing the underlying infrastructure, so you can focus on analyzing your data. BigQuery is also integrated with other Google Cloud services, such as Google Kubernetes Engine, Cloud Data Fusion, and Cloud Dataproc, making it easy to build and deploy data pipelines. Here are some of the benefits of using BigQuery: * **Fast and scalable:** BigQuery can process petabytes of data very quickly, and it can scale to handle even the most demanding workloads. * **Cost-effective:** BigQuery is a very cost-effective way to store and analyze data. You only pay for the data that you use, and there are no upfront costs or commitments. * **Secure:** BigQuery is a secure platform that meets the needs of even the most security-conscious organizations. * **Easy to use:** BigQuery is easy to use, even for non-technical users. It has a simple and intuitive user interface, and it supports a variety of data sources. * **Integrated with other Google Cloud services:** BigQuery is integrated with other Google Cloud services, making it easy to build and deploy data pipelines. If you are looking for a fast, scalable, and cost-effective way to analyze your data, then BigQuery is a great option.
如需获取自定义摘要,请执行以下操作:
按照上文中的存储对话和获取聊天回复过程操作,但在第 2 步中,运行以下命令,其中包含用于在
modelPromptSpec.preamble
中指定自定义说明的summarySpec
字段。curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID/conversations/CONVERSATION_ID:converse" \ -d '{ "query": { "input": "FREE_TEXT"}, "summarySpec": { "modelPromptSpec": { "preamble": "CUSTOMIZATION_INSTRUCTIONS" } } }'
- CUSTOMIZATION_INSTRUCTIONS: 自定义,以字符串表示。
对聊天回复应用安全搜索功能
安全搜索功能可用于从摘要回答中滤除露骨、不安全、违反政策的输出内容。如需详细了解安全搜索,请参阅 Vertex AI Search 的安全设置。
如需对聊天回复应用安全搜索,请执行以下操作:
请按照上文中的存储对话和获取聊天回复过程操作,但在第 2 步中,请在查询下方指定
safe_search
。curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID/conversations/CONVERSATION_ID:converse" \ -d '{ "query": { "input": "FREE_TEXT"}, "safe_search": true }'
查看和修改存储的对话
您可以使用命令行获取、删除、更新和列出存储的对话。
从数据存储区获取对话
如需从数据存储区获取特定对话的所有详细信息,请执行以下操作:
运行以下 curl 命令:
curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID/conversations/CONVERSATION_ID"
PROJECT_ID:您的 Google Cloud 项目的项目编号或 ID
DATA_STORE_ID:关联的数据存储区的 ID 应用互动情况
CONVERSATION_ID:对话的 ID
点击查看
GET
命令。{ "name": "projects/12345/locations/global/collections/default_collection/dataStores/my-data-store_4321/conversations/2040473575290303058", "state": "IN_PROGRESS", "userPseudoId": "2040473575290303058", "messages": [ { "userInput": { "input": "what is bigquery?" } }, { "reply": { "summary": { "summaryText": "BigQuery is a cloud-based data warehouse that enables businesses to analyze all their data very quickly. It is a fully managed service that provides a simple and cost-effective way to store and analyze large amounts of data." } } } ], "startTime": "2023-08-15T20:11:24.046735Z" }
从数据存储区中删除对话
默认情况下,系统会自动删除 60 天之前的对话。不过,如果您想删除特定对话(例如,如果对话中意外包含敏感内容),则可以使用此 API 调用进行删除。
如需从数据存储区中删除对话,请执行以下操作:
运行以下 curl 命令:
curl -X DELETE \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID/conversations/CONVERSATION_ID"
PROJECT_ID:您的 Google Cloud 项目的项目编号或 ID
DATA_STORE_ID:关联的数据存储区的 ID 应用互动情况
CONVERSATION_ID:对话 ID
DELETE
命令的响应如下所示:{}
更新对话
您可能出于多种原因而需要更新对话。例如,执行以下任一操作:
将会话标记为已完成
将一个会话中的邮件合并到另一个会话中
更改
user_pseudo_id
如需更新对话中的 state
,请执行以下操作:
运行以下 curl 命令:
curl -X PATCH \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID/conversations/CONVERSATION_ID?updateMask=state" \ -d '{ "state": "NEW_STATE" }'
PROJECT_ID:您的 Google Cloud 项目的项目编号或 ID
DATA_STORE_ID:与您的应用关联的数据存储区的 ID。
CONVERSATION_ID:您要更新的对话的 ID
NEW_STATE:状态的新值,例如
COMPLETED
点击查看
PATCH
命令。{ "name": "projects/12345/locations/global/collections/default_collection/dataStores/my-data-store_4321/conversations/11078281986791420687", "state": "COMPLETED", "userPseudoId": "test_id1", "messages": [ { "userInput": { "input": "what is bigquery?" } }, { "reply": { "summary": { "summaryText": "BigQuery is a cloud-based data warehouse that enables businesses to analyze all their data very quickly. It is a fully managed service that provides a simple and cost-effective way to store and analyze large amounts of data." } } } ], "startTime": "2023-08-15T20:08:12.094639Z" }
如需更新对话中的 user_pseudo_id
,请执行以下操作:
运行以下 curl 命令:
curl -X PATCH \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID/conversations/CONVERSATION_ID?updateMask=user_pseudo_id" \ -d '{ "user_pseudo_id": "NEW_USER_PSEUDO_ID" }'
PROJECT_ID:您的 Google Cloud 项目的项目编号或 ID
DATA_STORE_ID:与您的应用关联的数据存储区的 ID。
CONVERSATION_ID:您要更新的对话的 ID
NEW_USER_PSEUDO_ID:用户伪 ID 的新值
点击查看
PATCH
命令的示例响应。{ "name": "projects/12345/locations/global/collections/default_collection/dataStores/my-data-store_4321/conversations/11078281986791420687", "state": "IN_PROGRESS", "userPseudoId": "test_id1", "messages": [ { "userInput": { "input": "what is bigquery?" } }, { "reply": { "summary": { "summaryText": "BigQuery is a cloud-based data warehouse that enables businesses to analyze all their data very quickly. It is a fully managed service that provides a simple and cost-effective way to store and analyze large amounts of data." } } } ], "startTime": "2023-08-15T20:08:12.094639Z" }
上述命令展示了如何更改 user_pseudo_id.
。不过,
可以通过替换 user_pseudo_id
来更新对话中的其他字段
会话中的其他字段
资源。
列出所有会话
如需列出数据存储区中的所有对话,请执行以下操作:
运行以下 curl 命令:
curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID/conversations"
PROJECT_ID:您的 Google Cloud 项目的项目编号或 ID
DATA_STORE_ID:与您的应用关联的数据存储区的 ID。
点击查看
GET
命令的示例响应。{ "conversations": [ { "name": "projects/12345/locations/global/collections/default_collection/dataStores/my-data-store_4321/conversations/11078281986791420687", "state": "IN_PROGRESS", "userPseudoId": "test_id", "messages": [ { "userInput": { "input": "what is bigquery?" } }, { "reply": { "summary": { "summaryText": "BigQuery is a cloud-based data warehouse that enables businesses to analyze all their data very quickly. It is a fully managed service that provides a simple and cost-effective way to store and analyze large amounts of data." } } } ], "startTime": "2023-08-15T20:08:12.094639Z" }, { "name": "projects/12345/locations/global/collections/default_collection/dataStores/my-data-store_4321/conversations/2040473575290303058", "state": "IN_PROGRESS", "userPseudoId": "2040473575290303058", "messages": [ { "userInput": { "input": "what is bigquery?" } }, { "reply": { "summary": { "summaryText": "BigQuery is a cloud-based data warehouse that enables businesses to analyze all their data very quickly. It is a fully managed service that provides a simple and cost-effective way to store and analyze large amounts of data." } } } ] } ] }
响应包含会话列表和 next_page_token
。如果未返回 next_page_token
,则表示没有更多对话可列出。
默认页面大小为 50。
按过滤条件列出对话
与其列出数据存储区中的所有对话,不如列出 所有打开的会话或与特定 相关的所有会话 用户。
例如,您可以使用一个选项 重新打开其中一条规则
为此,您可以列出与给定过滤条件匹配的对话:user_pseudo_id
或 state
(IN_PROGRESS
或 COMPLETED
)。
列出用户的对话
如需列出与用户或访问者关联的对话,请执行以下操作:
运行以下 curl 命令:
curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID/conversations?filter=user_pseudo_id=USER_PSEUDO_ID"
PROJECT_ID:您的 Google Cloud 项目的项目编号或 ID
DATA_STORE_ID:与您的应用关联的数据存储区的 ID。
USER_PSEUDO_ID:其对话用户的伪 ID 列出。
GET
命令的响应如下所示:点击查看
GET
命令的示例响应。{ "conversations": [ { "name": "projects/12345/locations/global/collections/default_collection/dataStores/my-data-store_4321/conversations/11078281986791420687", "state": "IN_PROGRESS", "userPseudoId": "test_id", "messages": [ { "userInput": { "input": "what is bigquery?" } }, { "reply": { "summary": { "summaryText": "BigQuery is a cloud-based data warehouse that enables businesses to analyze all their data very quickly. It is a fully managed service that provides a simple and cost-effective way to store and analyze large amounts of data." } } } ], "startTime": "2023-08-15T20:08:12.094639Z" } ] }
列出用户和状态的对话
如需列出处于特定状态(打开或已关闭)且与用户或访问者相关的对话,请执行以下操作:
运行以下 curl 命令:
curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID/conversations?filter=user_pseudo_id=USER_PSEUDO_ID%20AND%20state=STATE"
PROJECT_ID:您的 Google Cloud 项目的项目编号或 ID
DATA_STORE_ID:与您的应用关联的数据存储区的 ID。
USER_PSEUDO_ID:您要列出对话的用户的假名 ID。
STATE:对话是处于打开还是关闭状态(
IN_PROGRESS
或COMPLETED
)
GET
命令的响应如下所示:点击查看
GET
命令的示例响应。{ "conversations": [ { "name": "projects/12345/locations/global/collections/default_collection/dataStores/my-data-store_4321/conversations/11078281986791420687", "state": "IN_PROGRESS", "userPseudoId": "test_id", "messages": [ { "userInput": { "input": "what is bigquery?" } }, { "reply": { "summary": { "summaryText": "BigQuery is a cloud-based data warehouse that enables businesses to analyze all their data very quickly. It is a fully managed service that provides a simple and cost-effective way to store and analyze large amounts of data." } } } ], "startTime": "2023-08-15T20:08:12.094639Z" } ] }
如需了解过滤语法的一般信息,请参阅 AIP-160 过滤。
相关问题
“相关问题”是一项处于预览阶段的功能,具有许可名单功能,除了搜索结果之外,还可以返回相关问题。
例如,当您询问“去墨西哥度假的最佳季节是什么?”时,除了回答您的问题外,搜索功能还会建议您可能要问的其他问题,例如“去墨西哥度假最便宜的月份是什么?”和“墨西哥的旅游旺季是什么月份?”
如果您希望搜索应用返回相关问题,请与您的 Google 联系 客户支持团队,告诉他们您希望咨询哪些项目和应用的问题 。如果您未使用默认服务配置,则需要执行以下操作: 提供服务配置的名称。
启用相关问题功能后,系统会在 ConverseConversationResponse
中以字符串的形式返回问题。
更多信息
如需详细了解
summaryResultCount
、includeCitations
、ignoreAdversarialQuery
、ignoreNonSummarySeekingQuery
字段,请参阅 Vertex AI Agent Builder API 文档中的 SummarySpec。如需有关获取搜索摘要的更多示例,请参阅获取摘要。