本页介绍了 Vertex AI Search 的搜索功能,包括回答和后续跟进,并展示了如何使用方法调用为通用搜索应用实现此功能。
搜索并显示回答和后续问题取决于答案方法。answer 方法取代了旧版 search 方法的摘要功能以及已废弃的 converse 方法的所有功能。回答方法还具有一些重要的附加功能,例如能够处理复杂的查询。
回答方法的特点
该回答方法的主要特点如下:
能够生成复杂查询的答案。例如,回答方法可以将复合查询(例如以下查询)细分为多个较小的查询,以返回更好的结果,从而提供更准确的回答:
- “2024 年 Google Cloud 和 Google Ads 分别能带来多少收入?”
- “Google 成立多少年后收入达到 10 亿美元?”
能够在多轮对话中通过在每轮对话中调用 answer 方法来组合搜索和回答生成。
能够与搜索方法搭配使用,以缩短搜索延迟时间。您可以单独调用搜索方法和回答方法,并在不同时间在不同的 iframe 中呈现搜索结果和回答。这意味着,您可以在几毫秒内向用户显示搜索结果(10 个蓝色链接)。您无需等待系统生成回答,即可显示搜索结果。
回答和跟进功能可分为查询、搜索和回答三个阶段:
何时使用“回答”功能,何时使用“搜索”功能
Vertex AI Search 有两种用于查询应用的方法。它们具有不同的但重叠的功能。
在以下情况下,请使用 answer 方法:
您希望 AI 生成搜索结果的答案(或摘要)。
您需要多轮搜索,也就是说,搜索会保留上下文,以便进行后续问题。
在以下情况下,请使用搜索方法:
您只需要搜索结果,而不需要生成的回答。
您有以下任一情况:
- 媒体或医疗保健数据
- 您自己的嵌入
- 同义词控件或重定向控件
- 分面
- 用户的国家/地区代码
在以下情况下,请结合使用“回答”和“搜索”方法:
您希望返回超过 10 条搜索结果,并且希望系统生成回答。
您遇到了延迟问题,希望在系统返回生成的回答之前快速返回并显示搜索结果。
查询阶段功能
“回答和跟进”功能支持自然语言查询处理。
本部分介绍并展示了查询重述和分类的各种选项。
重述查询
查询重述功能默认处于开启状态。此功能会自动选择最佳方式来重写查询,以便改进搜索结果。此功能还可以处理不需要重述的询问。
将复杂查询分解为多个查询,并执行同步子查询。
例如:将一个复杂的查询拆分为四个更小、更简单的查询。
用户输入 从复杂查询创建的子查询 Andie Ram 和 Arnaud Clément 有哪些共同的工作和爱好? - Andie Ram 的职业
- Arnaud Clément 的职业
- Andie Ram 的爱好
- Arnaud Clément 的爱好
合成多轮询问,使后续问题具有上下文感知能力和状态。
例如:每次轮到用户输入时,系统合成的查询可能如下所示:
用户输入 合成的查询 第 1 回:适合上学的笔记本电脑 适合学校使用的笔记本电脑 第 2 步:不是 Mac 学校用笔记本电脑,不是 Mac 第 3 个选项:更大的屏幕,我还需要无线键盘和鼠标 适用于学校的大屏笔记本电脑(不是 Mac),配有无线键盘和鼠标 第 4 页:以及一个背包 适用于学校的大屏笔记本电脑(不是 Mac),配有无线键盘和鼠标,以及一个背包 简化长查询,以提高检索效率。
例如:长查询会缩短为简单查询。
用户输入 简化了查询 我正在尝试找出网站上的“添加到购物车”按钮无法正常运行的原因。似乎当用户点击该按钮时,商品不会添加到购物车,并且他们会收到错误消息。我检查了代码,发现代码似乎没有问题,因此我不确定问题可能出在哪里。您能帮我排查这个问题吗? 网站上的“添加到购物车”按钮无法正常使用。 执行多步推理
多步推理基于 ReAct(推理 + 行动)范式,该范式使 LLM 能够使用自然语言推理来解决复杂任务。默认情况下,步骤数量上限为 5。
例如:
用户输入 生成回答的两步 Google 成立多少年后,收入达到了 10 亿美元? 第 1 步:
[思考]:我需要知道 Google 成立的时间,然后才能查询自那时起的收入。
[行动] 搜索:Google 是什么时候成立的?[观察搜索结果]:“1998 年”
Google 是什么时候首次突破 10 亿美元的?
[思考]:现在,我需要查询 Google 自 1998 年以来的年收入,并找出其首次突破 10 亿美元的时间。第 2 步:
[操作] 搜索:1998 年以来的 Google 收入
[观察搜索结果] Google 1998 年的收入、Google 1999 年的收入……
[答案]:Google 于 1998 年成立 [2],在 5 年后的 2003 年收入就超过了 10 亿美元 [1]。
查询分类
查询分类选项用于识别对抗性查询和非查询答案查询。默认情况下,查询分类选项处于关闭状态。
如需详细了解对抗性询问和非回答询问,请参阅忽略对抗性询问和忽略非摘要询问。
搜索阶段功能
对于搜索,答案方法与搜索方法具有相同的选项。例如:
应用过滤条件以将搜索范围限制为特定文档。如需了解详情,请参阅过滤通用搜索结果,以查找结构化或非结构化数据。
应用安全搜索过滤掉露骨内容,例如暴力和色情内容。如需了解详情,请参阅 Vertex AI Search 的安全设置。
指定提升条件,以提升或降低搜索返回的文档的排名。如需了解详情,请参阅提升搜索结果排名。
回答阶段功能
在回答阶段,当系统根据搜索结果生成回答时,您可以启用与搜索方法相同的功能。例如:
获取引用,以指明回答中每个句子的来源。如需了解详情,请参阅添加引文。
使用提示前言可自定义回答的语气、风格和详细程度等。如需了解详情,请参阅指定自定义前言。
选择要用于生成回答的 Vertex AI 模型。如需了解详情,请参阅回答生成模型版本和生命周期。
选择是否忽略被归类为对抗性或非查询性质的询问。
搜索方法中不提供的其他回答阶段功能包括:
为每个断言(生成的回答中的句子)获取支持得分。 支持得分是一个介于 [0,1] 范围内的浮点值,表示声明在数据存储区中的数据中有多可靠。如需了解详情,请参阅返回接地支持得分。
获取答案的汇总支持得分。支持得分表示回答与数据存储区中的数据的相关程度。如需了解详情,请参阅返回接地支持得分。
仅返回有依据的回答。您可以选择仅返回满足特定支持得分阈值的回答。如需了解详情,请参阅仅显示有依据的回答。
准备工作
根据您所拥有的应用类型,完成以下要求:
如果您有结构化或非结构化搜索应用,请确保已启用以下功能:高级 LLM 功能
如果您有网站搜索应用,请确保已开启以下功能:
如果您有混合搜索应用(即与多个数据存储区关联的应用),请与您的 Google 客户支持团队联系,请求将您的应用添加到支持混合搜索的 Answer API 的许可名单中。
搜索和回答(基本)
以下命令展示了如何调用 answer 方法,并返回生成的回答和搜索结果列表(其中包含指向来源的链接)。
此命令仅显示必需的输入。将选项保留为默认值。
如需进行搜索并获取包含生成的回答的结果,请执行以下操作:
运行以下 curl 命令:
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/engines/APP_ID /servingConfigs/default_search:answer" \ -d '{ "query": { "text": "QUERY "} }'替换以下内容:
PROJECT_ID
:您的 Google Cloud 项目的 ID。APP_ID
:您要查询的 Vertex AI Search 应用的 ID。QUERY
:包含问题或搜索查询的自由文本字符串。例如,“比较 BigQuery 和 Spanner 数据库?”。
命令和部分结果示例
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://discoveryengine.googleapis.com/v1/projects/my-project-123/locations/global/collections/default_collection/engines/my-app/servingConfigs/default_search:answer" \ -d '{"query": { "text": "Which database is faster, bigquery or spanner?"}}'
{ "answer": { "state": "SUCCEEDED", "answerText": "The provided sources do not directly compare the speed of BigQuery and Spanner. However, they do highlight the performance capabilities of each database. BigQuery is described as having strong query performance, particularly for short and complex queries. It also offers a serverless architecture that provides consistent performance regardless of query complexity. Spanner is described as having high performance at virtually unlimited scale, with single-digit millisecond latency for strongly-consistent reads and writes. It also offers a five-nines availability SLA. Ultimately, the best database for a particular use case will depend on the specific requirements of the application. \n", "steps": [ { "state": "SUCCEEDED", "description": "Rephrase the query and search.", "actions": [ { "searchAction": { "query": " What is the performance of BigQuery?" }, "observation": { "searchResults": [ { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/9ab3ef91bcfde1fcd091efe9df7c699c", "uri": "https://cloud.google.com/bigquery/docs/best-practices-performance-overview", "title": "Introduction to optimizing query performance | BigQuery | Google Cloud", "snippetInfo": [ { "snippet": "After a query begins execution, \u003cb\u003eBigQuery\u003c/b\u003e calculates how many slots each query stage uses based on the stage size and complexity and the number of slots ...", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/4e545c5cb69b06b251265114d9099cb4", "uri": "https://cloud.google.com/bigquery/docs/query-insights", "title": "Get query performance insights | BigQuery | Google Cloud", "snippetInfo": [ { "snippet": "This document describes how to use the query execution graph to diagnose query \u003cb\u003eperformance\u003c/b\u003e issues, and to see query \u003cb\u003eperformance\u003c/b\u003e insights. \u003cb\u003eBigQuery\u003c/b\u003e offers ...", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/d34672d877eefe596f9c7d1a3d7076b1", "uri": "https://cloud.google.com/bigquery/docs/best-practices-performance-compute", "title": "Optimize query computation | BigQuery | Google Cloud", "snippetInfo": [ { "snippet": "After addressing the query \u003cb\u003eperformance\u003c/b\u003e insights, you can further optimize your query by performing the following tasks: Reduce data that is to be processed ...", "snippetStatus": "SUCCESS" } ] }, ... { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/75ce2f05833683e60ddc21a11ce0466f", "uri": "https://cloud.google.com/blog/products/data-analytics/troubleshoot-and-optimize-your-bigquery-analytics-queries-with-query-execution-graph/", "title": "Troubleshoot and optimize your BigQuery analytics queries with query execution graph | Google Cloud Blog", "snippetInfo": [ { "snippet": "Since query \u003cb\u003eperformance\u003c/b\u003e is multi-faceted, \u003cb\u003eperformance\u003c/b\u003e insights might only provide a partial picture of the overall query \u003cb\u003eperformance\u003c/b\u003e. Execution graph. When ...", "snippetStatus": "SUCCESS" } ] } ] } }, { "searchAction": { "query": " What is the performance of Spanner?" }, "observation": { "searchResults": [ { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/f3d036b60379873acf7c73081c5e5b5c", "uri": "https://cloud.google.com/spanner/docs/performance", "title": "Performance overview | Spanner | Google Cloud", "snippetInfo": [ { "snippet": "These \u003cb\u003eperformance\u003c/b\u003e improvements should result in higher throughput and better latency in \u003cb\u003eSpanner\u003c/b\u003e nodes in both regional and multi-region instance configurations.", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/422496248ade354c73b4c906b8eb9b5f", "uri": "https://cloud.google.com/blog/products/databases/announcing-cloud-spanner-price-performance-updates", "title": "Announcing Cloud Spanner price-performance updates | Google Cloud Blog", "snippetInfo": [ { "snippet": "Alongside lower costs, Cloud \u003cb\u003eSpanner\u003c/b\u003e provides single-digit ms latencies and strong consistency across multiple availability zones in the same region.", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/53c2a1a6990480ba4aa05cc6b4404562", "uri": "https://cloud.google.com/blog/topics/developers-practitioners/understanding-cloud-spanner-performance-metrics-scale-key-visualizer", "title": "Understanding Cloud Spanner performance metrics at scale with Key Visualizer | Google Cloud Blog", "snippetInfo": [ { "snippet": "Designed for \u003cb\u003eperformance\u003c/b\u003e tuning and instance sizing, you can use Key Visualizer today in the web-based Cloud Console for all \u003cb\u003eSpanner\u003c/b\u003e databases at no additional ...", "snippetStatus": "SUCCESS" } ] }, ... { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/a6501ecd5d6391e3ade49097bab0ad3a", "uri": "https://cloud.google.com/blog/products/databases/a-technical-overview-of-cloud-spanners-query-optimizer", "title": "A technical overview of Cloud Spanner's query optimizer | Google Cloud Blog", "snippetInfo": [ { "snippet": "... performance. Typically, a join will ... Google is continuously improving out-of-the-box \u003cb\u003eperformance of Spanner\u003c/b\u003e and reducing the need for manual tuning.", "snippetStatus": "SUCCESS" } ] } ] } } ] } ] }, "answerQueryToken": "NMwKDAj1_d62BhC72_X_AhIkNjZkN2I4YWEtMDAwMC0yYTdiLWIxMmMtMDg5ZTA4MjhlNzY0" }在此示例中,查询被分解为以下部分:“Spanner 的性能如何?”和“BigQuery 的性能如何?”
如需了解详情,请参阅 Vertex AI Agent Builder Python API 参考文档。
如需向 Vertex AI Agent Builder 进行身份验证,请设置应用默认凭据。 如需了解详情,请参阅为本地开发环境设置身份验证。
查询阶段命令
本部分介绍了如何为 answer 方法调用的查询阶段指定选项。
搜索和回答(已停用重述功能)
以下命令展示了如何调用 answer 方法并返回生成的答案和搜索结果列表。由于重述选项已停用,因此回答可能会与上一个回答不同。
如需搜索并获取包含生成答案的结果,而不应用查询重述功能,请执行以下操作:
运行以下 curl 命令:
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/engines/APP_ID /servingConfigs/default_search:answer" \ -d '{ "query": { "text": "QUERY "}, "queryUnderstandingSpec": { "queryRephraserSpec": { "disable": true } } }'替换以下内容:
PROJECT_ID
:您的 Google Cloud 项目的 ID。APP_ID
:Vertex AI Search 应用的 ID。QUERY
:包含问题或搜索查询的自由文本字符串。例如,“比较 BigQuery 和 Spanner 数据库?”。
命令和部分结果示例
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://discoveryengine.googleapis.com/v1/projects/my-project-123/locations/global/collections/default_collection/engines/my-app/servingConfigs/default_search:answer" \ -d '{ "query": { "text": "Which database is faster, bigquery or spanner?"}, "queryUnderstandingSpec": { "queryRephraserSpec": { "disable": true } } }'
{ "answer": { "state": "SUCCEEDED", "answerText": "The sources provided do not directly compare the speed of BigQuery and Spanner. They do mention that Spanner is optimized for transactional workloads and BigQuery is optimized for analytical workloads. Spanner is a fully managed relational database that provides seamless replication across regions in Google Cloud. BigQuery is a serverless, highly scalable, and cost-effective multi-cloud data warehouse. Spanner is designed to scale horizontally across multiple regions and continents. BigQuery is designed for business agility. \n", "steps": [ { "state": "SUCCEEDED", "description": "Rephrase the query and search.", "actions": [ { "searchAction": { "query": "Which database is faster, bigquery or spanner?" }, "observation": { "searchResults": [ { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/ecc0e7547253f4ca3ff3328ce89995af", "uri": "https://cloud.google.com/blog/topics/developers-practitioners/how-spanner-and-bigquery-work-together-handle-transactional-and-analytical-workloads", "title": "How Spanner and BigQuery work together to handle transactional and analytical workloads | Google Cloud Blog", "snippetInfo": [ { "snippet": "A federated \u003cb\u003equery\u003c/b\u003e might not be as \u003cb\u003efast\u003c/b\u003e as querying local \u003cb\u003eBigQuery tables\u003c/b\u003e. There may be higher latency because of the small wait time for the source \u003cb\u003edatabase\u003c/b\u003e to ...", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/d7e238f73608a860e00b752ef80e2941", "uri": "https://cloud.google.com/blog/products/databases/cloud-spanner-gets-stronger-with-bigquery-federated-queries", "title": "Cloud Spanner gets stronger with BigQuery-federated queries | Google Cloud Blog", "snippetInfo": [ { "snippet": "... \u003cb\u003equick\u003c/b\u003e lookup on \u003cb\u003edata\u003c/b\u003e that's in \u003cb\u003eSpanner\u003c/b\u003e -- you can ... Set up an external \u003cb\u003edata\u003c/b\u003e source for the \u003cb\u003eSpanner\u003c/b\u003e shopping \u003cb\u003edatabase\u003c/b\u003e in \u003cb\u003eBigQuery\u003c/b\u003e. ... The \u003cb\u003equery\u003c/b\u003e is executed in ...", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/f3d036b60379873acf7c73081c5e5b5c", "uri": "https://cloud.google.com/spanner/docs/performance", "title": "Performance overview | Spanner | Google Cloud", "snippetInfo": [ { "snippet": "The information on this page applies to both GoogleSQL and PostgreSQL \u003cb\u003edatabases\u003c/b\u003e. Note: We are in the process of rolling out \u003cb\u003eperformance\u003c/b\u003e and storage changes that ...", "snippetStatus": "SUCCESS" } ] }, ... { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/47b09cb5ad5e3ab3b1eb93d99ecb0896", "uri": "https://cloud.google.com/blog/products/databases/rewe-uses-cloud-spanner-to-optimize-for-speed-and-performance", "title": "REWE uses Cloud Spanner to optimize for speed and performance | Google Cloud Blog", "snippetInfo": [ { "snippet": "As a fully managed relational \u003cb\u003edatabase\u003c/b\u003e, \u003cb\u003eSpanner\u003c/b\u003e provides unlimited scale, strong consistency, and up to 99.999% availability. By choosing this approach to ...", "snippetStatus": "SUCCESS" } ] } ] } } ] } ] }, "answerQueryToken": "M8gKCwjp_t62BhC7wOFMEiQ2NmQ3YjhhZS0wMDAwLTJhN2ItYjEyYy0wODllMDgyOGU3NjQ" }
如需了解详情,请参阅 Vertex AI Agent Builder Python API 参考文档。
如需向 Vertex AI Agent Builder 进行身份验证,请设置应用默认凭据。 如需了解详情,请参阅为本地开发环境设置身份验证。
搜索和回答(指定步骤数上限)
以下命令展示了如何调用 answer 方法并返回生成的答案和搜索结果列表。由于重述步骤的数量增加,因此答案与之前的答案不同。
如需搜索并获取包含生成的答案的结果(最多允许 5 次重述步骤),请执行以下操作:
运行以下 curl 命令:
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/engines/APP_ID /servingConfigs/default_search:answer" \ -d '{ "query": { "text": "QUERY "}, "queryUnderstandingSpec": { "queryRephraserSpec": { "maxRephraseSteps":MAX_REPHRASE } } }'替换以下内容:
PROJECT_ID
:您的 Google Cloud 项目的 ID。APP_ID
:您要查询的 Vertex AI Search 应用的 ID。QUERY
:包含问题或搜索查询的自由文本字符串。例如,“比较 BigQuery 和 Spanner 数据库?”。MAX_REPHRASE
:重述步骤的数量上限。允许的最大值为5
。如果未设置或设置的值小于1
,则值为默认值1
。
示例命令
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://discoveryengine.googleapis.com/v1/projects/my-project-123/locations/global/collections/default_collection/engines/my-app/servingConfigs/default_search:answer" \ -d '{ "query": { "text": "How much longer does it take to train a recommendations model than a search model"}, "queryUnderstandingSpec": { "queryRephraserSpec": { "maxRephraseSteps": 5 } } }'
如需了解详情,请参阅 Vertex AI Agent Builder Python API 参考文档。
如需向 Vertex AI Agent Builder 进行身份验证,请设置应用默认凭据。 如需了解详情,请参阅为本地开发环境设置身份验证。
使用查询分类进行搜索和回答
以下命令展示了如何调用 answer 方法来询问询问是敌对性询问、非答案询问,还是两者都不是。
响应包含查询的分类类型,但答案本身不会受到分类的影响。如果您想根据询问类型更改回答行为,可以在回答阶段执行此操作。请参阅忽略对抗性询问和忽略非摘要查询。
如需确定询问是恶意询问还是非答案询问,请执行以下操作:
运行以下 curl 命令:
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/engines/APP_ID /servingConfigs/default_search:answer" \ -d '{ "query": { "text": "QUERY "}, "queryUnderstandingSpec": { "queryClassificationSpec": { "types": ["QUERY_CLASSIFICATION_TYPE "] } } }'替换以下内容:
PROJECT_ID
:您的 Google Cloud 项目的 ID。APP_ID
:您要查询的 Vertex AI Search 应用的 ID。QUERY
:包含问题或搜索查询的自由文本字符串。例如“hello”。QUERY_CLASSIFICATION_TYPE
:您要识别的查询类型:ADVERSARIAL_QUERY
和/或NON_ANSWER_SEEKING_QUERY
。
命令和部分结果示例
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://discoveryengine.googleapis.com/v1/projects/my-project-123/locations/global/collections/default_collection/engines/my-app/servingConfigs/default_search:answer" \ -d '{ "query": { "text": "Hello!"}, "queryUnderstandingSpec": { "queryClassificationSpec": { "types": ["ADVERSARIAL_QUERY", "NON_ANSWER_SEEKING_QUERY"] } } }'
{ "answer": { "state": "SUCCEEDED", "answerText": "A user reported that their Google Voice account was randomly sending \"Hello!\" replies to incoming texts. The user was frustrated because they did not want to send these replies and found the behavior random. The user was unable to find any linked accounts, Google extensions, or other settings that could be causing the issue. The user confirmed that Google Voice does not have auto-reply functions. The user was seeking help to stop the automatic replies. \n", "steps": [ { "state": "SUCCEEDED", "description": "Rephrase the query and search.", "actions": [ { "searchAction": { "query": "Hello!" }, "observation": { "searchResults": [ { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/69e92e5b1de5b1e583fbe95f94dd4cbf", "uri": "https://support.google.com/voice/thread/152245405/google-voice-is-randomly-automatically-sending-hello-replies-to-incoming-texts?hl=en", "title": "Google voice is randomly/automatically sending \"Hello!\" replies to incoming texts", "snippetInfo": [ { "snippet": "There IS a new "Smart reply" feature on the Android or iOS client apps, but you'd have to a) receive a SMS/MMS, b) open it up, c) look at the three suggested ...", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/44fb313bcc09877e7239f3810ddb132b", "uri": "https://support.google.com/mail/thread/58174131/gmail-sends-random-email-saying-hello-to-my-emails-without-me-touching-it?hl=en", "title": "Gmail sends random email saying \"Hello!!\" to my emails without me touching it", "snippetInfo": [ { "snippet": "Gmail sends random email saying "\u003cb\u003eHello\u003c/b\u003e!!" to my emails without me touching it. Whenever I email somebody and they reply, a random email from my Gmail is sent to ...", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/16d65e2af7fa854d1a00995525646dc3", "uri": "https://support.google.com/voice/thread/112990484/google-voice-sending-hello-in-response-to-text-messages?hl=en", "title": "Google Voice sending \"Hello,\" in response to text messages", "snippetInfo": [ { "snippet": "When I receive text messages, a reply is instantly sent out reading "\u003cb\u003eHello\u003c/b\u003e," and I cannot figure out how this is happening. I have no linked accounts, ...", "snippetStatus": "SUCCESS" } ] }, ... { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/a828eb8f442f1dfbdda06dbeb52841b0", "uri": "https://support.google.com/a/thread/161821861/hello-hello-the-lost-phone?hl=en", "title": "Hello.Hello the lost phone - Google Workspace Admin Community", "snippetInfo": [ { "snippet": "\u003cb\u003eHello\u003c/b\u003e the lost phone. My wife lost her phone but she cannot remember her emails pasward to help track .", "snippetStatus": "SUCCESS" } ] } ] } } ] } ], "queryUnderstandingInfo": { "queryClassificationInfo": [ { "type": "ADVERSARIAL_QUERY" }, { "type": "NON_ANSWER_SEEKING_QUERY", "positive": true } ] } }, "answerQueryToken": "NMwKDAjVloK3BhCdt8u9AhIkNjZkYmFhNWItMDAwMC0yZTBkLTg0ZDAtMDg5ZTA4MmRjYjg0" }在此示例中,“hello”这个查询不是对抗性查询,但被归类为非寻求答案的查询。
如需了解详情,请参阅 Vertex AI Agent Builder Python API 参考文档。
如需向 Vertex AI Agent Builder 进行身份验证,请设置应用默认凭据。 如需了解详情,请参阅为本地开发环境设置身份验证。
搜索阶段命令:使用搜索结果选项进行搜索和回答
本部分介绍了如何为 answer 方法调用的搜索阶段部分指定选项,例如设置返回的文档数量上限、提升和过滤等选项,以及如何在您提供自己的搜索结果时获取回答。
以下命令演示了如何调用 answer 方法,以及如何指定返回搜索结果的方式的各种选项。(搜索结果与回答无关。)
如需设置与返回搜索结果的选项和方式相关的各种选项,请执行以下操作:
运行以下 curl 命令:
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/engines/APP_ID /servingConfigs/default_search:answer" \ -d '{ "query": { "text": "QUERY "}, "searchSpec": { "searchParams": { "maxReturnResults":MAX_RETURN_RESULTS , "filter": "FILTER ", "boostSpec":BOOST_SPEC , "orderBy": "ORDER_BY ", "searchResultMode":SEARCH_RESULT_MODE } } }'替换以下内容:
PROJECT_ID
:您的 Google Cloud 项目的 ID。APP_ID
:您要查询的 Vertex AI Search 应用的 ID。QUERY
:包含问题或搜索查询的自由文本字符串。例如,“比较 BigQuery 和 Spanner 数据库?”MAX_RETURN_RESULTS
:要返回的搜索结果数。默认值为10
。最大值为25
。FILTER
:过滤条件用于指定要查询的文档。如果文档的元数据符合过滤条件规范,则系统会对该文档进行查询。如需了解详情(包括过滤条件语法),请参阅过滤结构化或非结构化数据的通用搜索。BOOST_SPEC
:借助提升规范,您可以在搜索结果中提升某些文档的排名,这可能会影响回答。如需了解详情(包括提升幅度规范的语法),请参阅提升搜索结果的排名。ORDER_BY
:文档的返回顺序。文档可以按 Document 对象中的字段进行排序。orderBy
表达式区分大小写。 如果无法识别此字段,则返回INVALID_ARGUMENT
。SEARCH_RESULT_MODE
:用于指定搜索结果模式:DOCUMENTS
或CHUNKS
。如需了解详情,请参阅解析和分块文档以及 ContentSearchSpec。 此字段仅在 v1alpha 版的 API 中可用。
命令和结果示例
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://discoveryengine.googleapis.com/v1/projects/my-project-123/locations/global/collections/default_collection/engines/my-app/servingConfigs/default_search:answer" \ -d '{ "query": { "text": "Does spanner database have an API?"}, "searchSpec": { "searchParams": { "maxReturnResults": 3 } } }'
{ "answer": { "state": "SUCCEEDED", "answerText": "Spanner database has an API that provides programmatic access to the database. The API is available through client libraries, RPC, and REST. The client libraries allow you to interact with Spanner in your preferred language. The RPC API and REST API provide programmatic access to Spanner. The Cloud Spanner API is a managed, mission-critical, globally consistent and scalable relational database service. \n", "steps": [ { "state": "SUCCEEDED", "description": "Rephrase the query and search.", "actions": [ { "searchAction": { "query": "Does spanner database have an API?" }, "observation": { "searchResults": [ { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/d135b46c4a44d0cc6b652538c1887f4d", "uri": "https://cloud.google.com/spanner/docs/apis", "title": "APIs & reference | Spanner | Google Cloud", "snippetInfo": [ { "snippet": "The client libraries, the RPC \u003cb\u003eAPI\u003c/b\u003e, and the REST \u003cb\u003eAPI\u003c/b\u003e provide programmatic access to \u003cb\u003eSpanner\u003c/b\u003e. \u003cb\u003eSpanner\u003c/b\u003e client libraries. \u003cb\u003eGet\u003c/b\u003e started with \u003cb\u003eSpanner\u003c/b\u003e in your language ...", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/7a744d43e61ccd33539de74d5c1f6313", "uri": "https://cloud.google.com/spanner/docs/reference/rest", "title": "Cloud Spanner API", "snippetInfo": [ { "snippet": "Returns permissions that the caller \u003cb\u003ehas\u003c/b\u003e on the specified \u003cb\u003edatabase\u003c/b\u003e or backup resource. updateDdl, PATCH /v1/{\u003cb\u003edatabase\u003c/b\u003e=projects/*/instances/*/\u003cb\u003edatabases\u003c/b\u003e/*}/ddl", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/70834ebf4b72b6dc69e06c44ee80f90b", "uri": "https://cloud.google.com/spanner/docs/reference/rpc", "title": "Cloud Spanner API", "snippetInfo": [ { "snippet": "ChangeQuorum \u003cb\u003eis\u003c/b\u003e strictly restricted to \u003cb\u003edatabases\u003c/b\u003e ... Returns the schema of a Cloud \u003cb\u003eSpanner database\u003c/b\u003e ... Returns permissions that the caller \u003cb\u003ehas\u003c/b\u003e on the specified ...", "snippetStatus": "SUCCESS" } ] } ] } } ] } ] }, "answerQueryToken": "NMwKDAj2l4K3BhCqiv66ARIkNjZkYmFhNmMtMDAwMC0yZTBkLTg0ZDAtMDg5ZTA4MmRjYjg0" }在此示例中,返回的文档数量上限为 3 个。
如需了解详情,请参阅 Vertex AI Agent Builder Python API 参考文档。
如需向 Vertex AI Agent Builder 进行身份验证,请设置应用默认凭据。 如需了解详情,请参阅为本地开发环境设置身份验证。
回答阶段命令
本部分介绍了如何为 answer 方法调用指定特定于答案的选项。
忽略对抗性查询和非查询答案的查询
以下命令展示了如何在调用 answer 方法时避免回答对抗性询问和非查询询问。
如需跳过回答对抗性或非查询性质的询问,请执行以下操作:
运行以下 curl 命令:
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/engines/APP_ID /servingConfigs/default_search:answer" \ -d '{ "query": { "text": "QUERY "}, "answerGenerationSpec": { "ignoreAdversarialQuery": true, "ignoreNonAnswerSeekingQuery": true } }'替换以下内容:
PROJECT_ID
:您的 Google Cloud 项目的 ID。APP_ID
:您要查询的 Vertex AI Search 应用的 ID。QUERY
:包含问题或搜索查询的自由文本字符串。
命令和部分结果示例
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json" "https://discoveryengine.googleapis.com/v1/projects/my-project-123/locations/global/collections/default_collection/engines/my-app/servingConfigs/default_search:answer" \ -d '{ "query": { "text": "Hello"}, "answerGenerationSpec": { "ignoreAdversarialQuery": true, "ignoreNonAnswerSeekingQuery": true } }'
{ "answer": { "state": "SUCCEEDED", "answerText": "A summary could not be generated for your search query. Here are some search results.", "steps": [ { "state": "SUCCEEDED", "description": "Rephrase the query and search.", "actions": [ { "searchAction": { "query": "Hello" }, "observation": { "searchResults": [ { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/69e92e5b1de5b1e583fbe95f94dd4cbf", "uri": "https://support.google.com/voice/thread/152245405/google-voice-is-randomly-automatically-sending-hello-replies-to-incoming-texts?hl=en", "title": "Google voice is randomly/automatically sending \"Hello!\" replies to incoming texts", "snippetInfo": [ { "snippet": "There IS a new "Smart reply" feature on the Android or iOS client apps, but you'd have to a) receive a SMS/MMS, b) open it up, c) look at the three suggested ...", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/16d65e2af7fa854d1a00995525646dc3", "uri": "https://support.google.com/voice/thread/112990484/google-voice-sending-hello-in-response-to-text-messages?hl=en", "title": "Google Voice sending \"Hello,\" in response to text messages", "snippetInfo": [ { "snippet": "When I receive text messages, a reply is instantly sent out reading "\u003cb\u003eHello\u003c/b\u003e," and I cannot figure out how this is happening. I have no linked accounts, ...", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/b3bdde4957f588a1458c533269626d09", "uri": "https://support.google.com/voice/thread/4307458/lately-an-automatic-text-response-saying-hello-is-going-out-how-do-i-stop-this?hl=en", "title": "Lately an automatic text response saying, \"Hello\" is going out. How do I stop this? - Google Voice Community", "snippetInfo": [ { "snippet": "You need to find out what app is causing it and deactivate or delete it. Last edited Apr 16, 2019.", "snippetStatus": "SUCCESS" } ] }, ... { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/a828eb8f442f1dfbdda06dbeb52841b0", "uri": "https://support.google.com/a/thread/161821861/hello-hello-the-lost-phone?hl=en", "title": "Hello.Hello the lost phone - Google Workspace Admin Community", "snippetInfo": [ { "snippet": "\u003cb\u003eHello\u003c/b\u003e the lost phone. My wife lost her phone but she cannot remember her emails pasward to help track .", "snippetStatus": "SUCCESS" } ] } ] } } ] } ], "answerSkippedReasons": [ "NON_ANSWER_SEEKING_QUERY_IGNORED" ] }, "answerQueryToken": "NMwKDAjFgN-2BhDlsKaZARIkNjZkN2I0NmItMDAwMC0yZmQ5LTkwMDktZjQwMzA0M2E5YTg4" }在此示例中,系统判定该查询并非寻求答案,因此不会生成任何答案。
如需了解详情,请参阅 Vertex AI Agent Builder Python API 参考文档。
如需向 Vertex AI Agent Builder 进行身份验证,请设置应用默认凭据。 如需了解详情,请参阅为本地开发环境设置身份验证。
仅显示相关回答
Vertex AI Search 可以评估搜索结果与查询的相关性。如果没有结果被判定为足够相关,那么您可以选择返回回退回答“We do not have a summary for your query.
”,而不是根据不相关或相关性较低的结果生成回答
以下命令展示了如何在调用 answer 方法时返回不相关结果时的回退回答。
如需在未找到任何相关结果时返回后备答案,请执行以下操作:
运行以下 curl 命令:
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/engines/APP_ID /servingConfigs/default_search:answer" \ -d '{ "query": { "text": "QUERY "}, "answerGenerationSpec": { "ignoreLowRelevantContent": true } }'替换以下内容:
PROJECT_ID
:您的 Google Cloud 项目的 ID。APP_ID
:您要查询的 Vertex AI Search 应用的 ID。QUERY
:包含问题或搜索查询的自由文本字符串。
命令和结果示例
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://discoveryengine.googleapis.com/v1/projects/my-project-123/locations/global/collections/default_collection/engines/my-app/servingConfigs/default_search:answer" \ -d '{"query": { "text": "foobar"}, "answerGenerationSpec": { "ignoreLowRelevantContent": true } }'
{ "answer": { "state": "SUCCEEDED", "answerText": "We do not have a summary for your query.", "steps": [ { "state": "SUCCEEDED", "description": "Rephrase the query and search.", "actions": [ { "searchAction": { "query": "foobar" }, "observation": { "searchResults": [ { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/719b79786f0c143717c569eade5305d9", "uri": "https://support.google.com/websearch/thread/261714267/google-foobar-bug-console-disappeared?hl=en", "title": "Google Foobar Bug - Console Disappeared", "snippetInfo": [ { "snippet": "Google \u003cb\u003eFoobar\u003c/b\u003e Bug - Console Disappeared. After I logged in today the top bar says "The \u003cb\u003eFoobar\u003c/b\u003e Challenge will be turned down on 1 April 2024. If you run out of ...", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/932369826585ff45f6ab3eba01ba6933", "uri": "https://support.google.com/websearch/thread/95251114/unable-to-contact-foobar-recruiter?hl=en", "title": "Unable to contact Foobar Recruiter - Google Search Community", "snippetInfo": [ { "snippet": "Access is by invitation only so you will need to have the proper credentials to login. You can always reach out using the contact us button, but there is no ...", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/fb736a30ff90d058be755f0a04a522a8", "uri": "https://support.google.com/websearch/thread/121151780/foobar-challenge-appeared-to-me-then-disappeared?hl=en", "title": "Foobar challenge appeared to me then disappeared - Google Search Community", "snippetInfo": [ { "snippet": "Hi. I got the \u003cb\u003efoobar\u003c/b\u003e challenge some months ago. But then it disappeared immediately, maybe by misclick (though I don't think I misclicked).", "snippetStatus": "SUCCESS" } ] }, ... { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/f56f2656b0d02b839509d0e67e60c1c9", "uri": "https://support.google.com/chrome/thread/159931759/cannot-access-google-foobar-challenge?hl=en", "title": "Cannot Access Google FooBar Challenge", "snippetInfo": [ { "snippet": "I knew I wouldn't have time for it today, so I just kept the tab in the background. Tonight, I went to go close all my tabs, but the page had changed. It said " ...", "snippetStatus": "SUCCESS" } ] } ] } } ] } ], "answerSkippedReasons": [ "NO_RELEVANT_CONTENT" ] }, "answerQueryToken": "M8gKCwiokvy2BhDtv8EDEiQ2NmQ5NDQxZC0wMDAwLTIxMGQtOWU2Yi1mNDAzMDQ1ZGJkMzA" }在此示例中,系统判定结果与查询不够相关,因此返回了回退答案,而不是生成的答案和结果。
如需了解详情,请参阅 Vertex AI Agent Builder Python API 参考文档。
如需向 Vertex AI Agent Builder 进行身份验证,请设置应用默认凭据。 如需了解详情,请参阅为本地开发环境设置身份验证。
返回基准支持分数
以下命令展示了如何返回回答和声明的依据支持得分。
如需了解 Vertex AI 中的依据的一般信息,请参阅使用 RAG 检查依据。回答方法会调用 groundingConfigs.check
方法。
如需返回每个断言(答案中的句子)的支持得分以及答案的汇总支持得分,请执行以下操作:
运行以下 curl 命令:
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/engines/APP_ID /servingConfigs/default_search:answer" \ -d '{ "query": { "text": "QUERY "}, "groundingSpec": { "includeGroundingSupports": true, } }'替换以下内容:
PROJECT_ID
:您的 Google Cloud 项目的 ID。APP_ID
:您要查询的 Vertex AI Search 应用的 ID。QUERY
:包含问题或搜索查询的自由文本字符串。
命令和部分结果示例
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json" "https://discoveryengine.googleapis.com/v1/projects/123456/locations/global/collections/default_collection/engines/my-app/servingConfigs/default_search:answer" -d '{ "query": { "text": "What is SQL?"}, "groundingSpec": { "includeGroundingSupports": true, } }'
{ "answer": { "state": "SUCCEEDED", "answerText": "SQL stands for Structured Query Language. It is a database management programming language that is used to access and manage data in a database. SQL is used to create, update, and delete data in a database. It can also be used to query data and retrieve information. SQL is a standard language that is used by many different database systems.", "groundingScore" 0.9 "groundingSupports": [ { "endIndex": "41", "sources": [ { "referenceId": "1" } ] "groundingScore": 0.9 "groundingCheckRequired": true }, { "startIndex": "42", "endIndex": "144", "sources": [ { "referenceId": "1" } ] "groundingScore": 0.8 "groundingCheckRequired": true }, { "startIndex": "267", "endIndex": "342", "sources": [ { "referenceId": "2" } ] "groundingScore": 0.6 "groundingCheckRequired": true } ], "references": [ { "chunkInfo": { "content": "There are a lot of Databases available in the market such as MS Access, Oracle and many others.For you to write programs that interact with these databases easily, there has to be a way where you could get information from all these databases using the same method.For this purpose SQL was developed.It is a kind of language (simple when compared to the likes of C or C++) which enables you to ask all your queries to a database without bothering about the exact type of database.When you use this Query the database engine would first find the table called people.Then it would find a column called firstname.Next it would compare all the values in that column with 'Reena'.Finally it would return all the details wherever it finds a match for the firstname.When you write a database program in VC++ or Java or any other language for that matter, you would make a database connection to your database and then you would query the database using SQL queries.When you query the database with any SQL query the database returns a recordset.A recordset is basically a set of records (all the entries that your query returns).This recordset is received in your program and all languages have a data structure which represents a recordset.", "documentMetadata": { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/d993d922043374f5ef7ba297c158b106", "uri": "gs://my-bucket-123/documents/058dee0ec23a3e92f9bfd7cd29840e8f.txt" "structData": { "fields": [ { "key": "cdoc_url" "value": { "stringValue": "058dee0ec23a3e92f9bfd7cd29840e8f" } }, { "key": "doc_id" "value": { "stringValue": "d993d922043374f5ef7ba297c158b106" } } ] } } } }, { "chunkInfo": { "content": "The Structured Query Language (SQL) is a database management programming language.SQL is a tool for accessing databases, and more specifically, relational databases, and can be used with different database products.This chapter will prepare you to learn basic database management using this language.SQLite – To implement SQL as a library, you need SQLite.SQLite is intended to provide users and programs a way to store data using a SQL interface within the program.SQLite3 can be used to manipulate SQLite databases for major Linux distros.SQL is used to access relational databases.Each database contains more or less tables which in turn contain more or less rows and columns.Hereby a single row is seen as a separate object with features represented by the tables' columns.To access a table's data you first have to connect to its database.With the same table, the query SELECT * FROM T WHERE C1 = 1 will result in all the elements of all the rows where the value of column C1 is '1' being shown.A WHERE clause specifies that a SQL statement should only affect rows that meet specified criteria.The criteria are expressed in the form of predicates.WHERE clauses are not mandatory clauses of SQL statements, but should be used to limit the number of rows affected by a SQL DML statement or returned by a query.", "documentMetadata": { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/3825eac51ef9e934bbc558faa42f4c71", "uri": "gs://my-bucket-123/documents/26f5872b0719790cb966a697bfa1ea27.txt" "structData": { "fields": [ { "key": "cdoc_url" "value": { "stringValue": "26f5872b0719790cb966a697bfa1ea27" } }, { "key": "doc_id" "value": { "stringValue": "3825eac51ef9e934bbc558faa42f4c71" } } ] } } } }, { "chunkInfo": { "content": "This chapter focuses on using Paradox as a client/server development tool.It does not talk about connecting; it is assumed you have already connected.If you are having trouble connecting to a particular SQL server, then refer to the Connection Guide for that particular server.This chapter does review what a user can do interactively with Paradox and how to use ObjectPAL with SQL servers.Structured Query Language (SQL) was developed to create a standard for accessing database information.The ANSI standard for SQL allows a user to become familiar with the commands needed to query many different types of data.After you learn ANSI SQL, you then can query many different databases.Is SQL a solid standard?Yes and no.Yes, the core ANSI SQL commands are solid and consistent from vendor to vendor.Every vendor, however, adds capability to its version of SQL.These improvements are expected because ANSI SQL does not go far enough to cover every feature of every high-end DBMS.The SQL standard is used by many companies for their high-end products.They include Oracle, Sybase, Microsoft SQL, Informix, and Interbase.Paradox also provides the capability to use standard ANSI SQL commands on local Paradox and dBASE tables.Although SQL by definition is a standard, various flavors are on the market.", "documentMetadata": { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/b3e88db8676b87b99af1e6ecc7d8757f", "uri": "gs://my-bucket-123/documents/073c21335d37d8d14982cb3437a721c0.txt" "structData": { "fields": [ { "key": "cdoc_url" "value": { "stringValue": "073c21335d37d8d14982cb3437a721c0" } }, { "key": "doc_id" "value": { "stringValue": "b3e88db8676b87b99af1e6ecc7d8757f" } } ] } } } } ], ... "steps": [ { "state": "SUCCEEDED", "description": "Rephrase the query and search.", "actions": [ { "searchAction": { "query": "What is SQL?" }, "observation": { "searchResults": [ { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/d993d922043374f5ef7ba297c158b106", "uri": "gs://my-bucket-123/documents/058dee0ec23a3e92f9bfd7cd29840e8f.txt", "chunkInfo": [ { "content": "There are a lot of Databases available in the market such as MS Access, Oracle and many others.For you to write programs that interact with these databases easily, there has to be a way where you could get information from all these databases using the same method.For this purpose SQL was developed.It is a kind of language (simple when compared to the likes of C or C++) which enables you to ask all your queries to a database without bothering about the exact type of database.When you use this Query the database engine would first find the table called people.Then it would find a column called firstname.Next it would compare all the values in that column with 'Reena'.Finally it would return all the details wherever it finds a match for the firstname.When you write a database program in VC++ or Java or any other language for that matter, you would make a database connection to your database and then you would query the database using SQL queries.When you query the database with any SQL query the database returns a recordset.A recordset is basically a set of records (all the entries that your query returns).This recordset is received in your program and all languages have a data structure which represents a recordset." } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/3825eac51ef9e934bbc558faa42f4c71", "uri": "gs://my-bucket-123/documents/26f5872b0719790cb966a697bfa1ea27.txt", "chunkInfo": [ { "content": "The Structured Query Language (SQL) is a database management programming language.SQL is a tool for accessing databases, and more specifically, relational databases, and can be used with different database products.This chapter will prepare you to learn basic database management using this language.SQLite – To implement SQL as a library, you need SQLite.SQLite is intended to provide users and programs a way to store data using a SQL interface within the program.SQLite3 can be used to manipulate SQLite databases for major Linux distros.SQL is used to access relational databases.Each database contains more or less tables which in turn contain more or less rows and columns.Hereby a single row is seen as a separate object with features represented by the tables' columns.To access a table's data you first have to connect to its database.With the same table, the query SELECT * FROM T WHERE C1 = 1 will result in all the elements of all the rows where the value of column C1 is '1' being shown.A WHERE clause specifies that a SQL statement should only affect rows that meet specified criteria.The criteria are expressed in the form of predicates.WHERE clauses are not mandatory clauses of SQL statements, but should be used to limit the number of rows affected by a SQL DML statement or returned by a query." } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/b3e88db8676b87b99af1e6ecc7d8757f", "uri": "gs://my-bucket-123/documents/073c21335d37d8d14982cb3437a721c0.txt", "chunkInfo": [ { "content": "This chapter focuses on using Paradox as a client/server development tool.It does not talk about connecting; it is assumed you have already connected.If you are having trouble connecting to a particular SQL server, then refer to the Connection Guide for that particular server.This chapter does review what a user can do interactively with Paradox and how to use ObjectPAL with SQL servers.Structured Query Language (SQL) was developed to create a standard for accessing database information.The ANSI standard for SQL allows a user to become familiar with the commands needed to query many different types of data.After you learn ANSI SQL, you then can query many different databases.Is SQL a solid standard?Yes and no.Yes, the core ANSI SQL commands are solid and consistent from vendor to vendor.Every vendor, however, adds capability to its version of SQL.These improvements are expected because ANSI SQL does not go far enough to cover every feature of every high-end DBMS.The SQL standard is used by many companies for their high-end products.They include Oracle, Sybase, Microsoft SQL, Informix, and Interbase.Paradox also provides the capability to use standard ANSI SQL commands on local Paradox and dBASE tables.Although SQL by definition is a standard, various flavors are on the market." } ] }, ... { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/3dd4014e41044c5dd6a0fe380847f369", "uri": "gs://my-bucket-123/documents/76245cb33a66f4fbd9030a2a11eea00d.txt", "chunkInfo": [ { "content": "SQL injection is a code injection technique that might destroy your database.You can read more here OWASP sql injection testing sheet.Description: SQL injection ( second order) SQL injection vulnerabilities arise when user- controllable data is incorporated sheet into database SQL queries in an unsafe manner.This sheet cheat wiki assumes you have a basic understanding of SQL injection, please go here for an introduction if you are unfamiliar.Bypass login page with sql SQL injection [ closed].Gone are the days when knowledge sheet of just sql SQL Injection or XSS could help you land a lucrative high- paying InfoSec job.There is many sheet differnet variations you would login have probably have to try to make this exploit work ( sql especially if it is sql a blind SQL exploit).SQL injection usually occurs when you ask a user for input, like their.ゲストブック/ コメントの例.Submit Text Post.Get an ad- free experience with special benefits, and directly support Reddit.get reddit premium.SQL Injection Cheat.Many web applications have an authentication system: a user provides a user name and password, the web application checks them and stores the corresponding user id in the session hash.Login # 1 Login # 2 Login # 3 Login # 4." } ] } ] } } ] } ] } }在此示例中,系统会为每个引用返回一个支持得分 (`groundingScore`)。
仅显示有依据的回答
以下命令展示了如何仅返回被认为在语料库(数据存储区中的信息)中扎实可靠的答案。系统会滤除缺乏依据的回答。
您可以为接地支持分数选择低或高级别阈值。然后,只有当回答达到或超过该水平时,系统才会返回该回答。您可以使用这两个过滤阈值和不使用任何阈值进行实验,以确定哪种过滤级别最有可能为用户提供最佳结果。
如需了解 Vertex AI 中的依据的一般信息,请参阅使用 RAG 检查依据。回答方法会调用 groundingConfigs.check
方法。
如需仅在答案达到支持得分阈值时返回该答案,请执行以下操作:
运行以下 curl 命令:
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/engines/APP_ID /servingConfigs/default_search:answer" \ -d '{ "query": { "text": "QUERY "}, "groundingSpec": { "filteringLevel": "FILTER_LEVEL " } }'替换以下内容:
PROJECT_ID
:您的 Google Cloud 项目的 ID。APP_ID
:您要查询的 Vertex AI Search 应用的 ID。QUERY
:包含问题或搜索查询的自由文本字符串。FILTER_LEVEL
:用于根据基准支持得分过滤回答的枚举。选项包括:FILTERING_LEVEL_LOW
和FILTERING_LEVEL_HIGH
。如果未包含filteringLevel
,则不会对答案应用支持得分过滤器。
命令和部分结果示例
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://discoveryengine.googleapis.com/v1/projects/123456/locations/global/collections/default_collection/engines/my-app/servingConfigs/default_search:answer" \ -d '{ "query": { "text": "When can an NCD be made?"}, "groundingSpec": { "filtering_level": "FILTERING_LEVEL_HIGH" } }'
{ answer { state: SUCCEEDED answer_text: "We do not have a summary for your query." steps { state: SUCCEEDED description: "Rephrase the query and search." actions { search_action { query: "test?" } observation { search_results { document: "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/f7f5cfde02" uri: "gs://my-bucket-123/data/CoverageDocumentation.pdf" title: "ABC345_0101" chunk_info { content: "This notice implements part of section 731 of the Medicare Prescription Drug, Improvement, and Modernization Act of 2003 by describing a method of developing, and making available to the public, guidance documents under the Medicare program… " } ... search_results { document: "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/f7f5cfde02" uri: "gs://my-bucket-123/data/CoverageDocumentation.pdf" title: "ABC345_0101" chunk_info { content: "For the purposes of this notice, the term guidance documents means documents prepared for our staff, potential requestors of National Coverage Determinations, and other interested parties explaining the NCD process… " } } } } } answer_skipped_reasons: LOW_GROUNDED_CONTENT }在此示例中,由于未达到高阈值,因此系统未返回任何答案。
指定回答模型
以下命令展示了如何更改用于生成回答的模型版本。
如需了解支持的模型,请参阅回答生成模型版本和生命周期。
如需使用与默认模型不同的模型生成回答,请执行以下操作:
运行以下 curl 命令:
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/engines/APP_ID /servingConfigs/default_search:answer" \ -d '{ "query": { "text": "QUERY "}, "answerGenerationSpec": { "modelSpec": { "modelVersion": "MODEL_VERSION ", } } }'替换以下内容:
PROJECT_ID
:您的 Google Cloud 项目的 ID。APP_ID
:您要查询的 Vertex AI Search 应用的 ID。QUERY
:包含问题或搜索查询的自由文本字符串。MODEL_VERSION
:您要用于生成回答的模型版本。如需了解详情,请参阅回答生成模型版本和生命周期。
命令和部分结果示例
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://discoveryengine.googleapis.com/v1/projects/my-project-123/locations/global/collections/default_collection/engines/my-app/servingConfigs/default_search:answer" \ -d '{"query": { "text": "Compare bigquery with spanner database?"}, "answerGenerationSpec": { "modelSpec": { "modelVersion": "preview", } } }'
{ "answer": { "state": "SUCCEEDED", "answerText": "Cloud Spanner is a fully managed relational database optimized for transactional workloads. BigQuery is a serverless, highly scalable, and cost-effective multi-cloud data warehouse designed for business agility. BigQuery is optimized for ad-hoc analysis and reporting. Both Spanner and BigQuery are built on Google's distributed storage system, Colossus, and their internal cluster management system, Borg. They are also built on Jupiter, Google's in-house custom network hardware and software.\n\nBigQuery can query data stored in Spanner in real time without moving or copying the data. This is possible with BigQuery's query federation support. To run a federated query, you need to configure an external data source in BigQuery that points to the intended Spanner instance. You can then write queries that can be used to populate a BigQuery table on demand or scheduled to run as needed. You can also join the query with another BigQuery result set dynamically.\n\nYou can also use Dataflow to copy data from Spanner to BigQuery. Dataflow is a service that can be used to ingest Spanner data into BigQuery. This is useful for more complex transformations or external dependencies. For example, an online gaming company might use Spanner to store game data and BigQuery to perform analytics on player behavior. They can replicate data from Spanner into BigQuery and perform analytics against local data, or they can use federated queries to retrieve data from Spanner on-demand.\n", "steps": [ { "state": "SUCCEEDED", "description": "Rephrase the query and search.", "actions": [ { "searchAction": { "query": "Compare bigquery with spanner database?" }, "observation": { "searchResults": [ { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/ecc0e7547253f4ca3ff3328ce89995af", "uri": "https://cloud.google.com/blog/topics/developers-practitioners/how-spanner-and-bigquery-work-together-handle-transactional-and-analytical-workloads", "title": "How Spanner and BigQuery work together to handle transactional and analytical workloads | Google Cloud Blog", "snippetInfo": [ { "snippet": "Using Cloud \u003cb\u003eSpanner\u003c/b\u003e and \u003cb\u003eBigQuery\u003c/b\u003e also allows customers to build their \u003cb\u003edata\u003c/b\u003e clouds using Google Cloud, a unified, open approach to \u003cb\u003edata\u003c/b\u003e-driven transformation ...", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/d7e238f73608a860e00b752ef80e2941", "uri": "https://cloud.google.com/blog/products/databases/cloud-spanner-gets-stronger-with-bigquery-federated-queries", "title": "Cloud Spanner gets stronger with BigQuery-federated queries | Google Cloud Blog", "snippetInfo": [ { "snippet": "As enterprises compete for market share, their need for real-time insights has given rise to increased demand for transactional \u003cb\u003edatabases\u003c/b\u003e to support \u003cb\u003edata\u003c/b\u003e ...", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/e10a5a3c267dc61579e7c00fefe656eb", "uri": "https://cloud.google.com/blog/topics/developers-practitioners/replicating-cloud-spanner-bigquery-scale", "title": "Replicating from Cloud Spanner to BigQuery at scale | Google Cloud Blog", "snippetInfo": [ { "snippet": "... \u003cb\u003eSpanner data\u003c/b\u003e into \u003cb\u003eBigQuery\u003c/b\u003e for analytics. In this post, you will learn how to efficiently use this feature to replicate large tables with high throughput ...", "snippetStatus": "SUCCESS" } ] }, ... { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/648c220055c1d2ac369165007d9f6650", "uri": "https://cloud.google.com/blog/products/databases/choosing-cloud-spanner-for-game-development", "title": "Choosing Cloud Spanner for game development | Google Cloud Blog", "snippetInfo": [ { "snippet": "To get started with \u003cb\u003eSpanner\u003c/b\u003e, create a \u003cb\u003edatabase\u003c/b\u003e, or try it out with a \u003cb\u003eSpanner\u003c/b\u003e Qwiklab. ... AlloyDB \u003cb\u003evs\u003c/b\u003e. ... SQL for SQL Server to \u003cb\u003eBigQuery\u003c/b\u003e. By Alexander ...", "snippetStatus": "SUCCESS" } ] } ] } } ] } ] }, "answerQueryToken": "NMwKDAivmvy2BhCxnsqdARIkNjZkOTQ0NWEtMDAwMC0yMTBkLTllNmItZjQwMzA0NWRiZDMw" }在此示例中,使用的是模型的预览版,而不是默认模型。
如需了解详情,请参阅 Vertex AI Agent Builder Python API 参考文档。
如需向 Vertex AI Agent Builder 进行身份验证,请设置应用默认凭据。 如需了解详情,请参阅为本地开发环境设置身份验证。
指定自定义前导码
以下命令展示了如何为生成的回答设置序言。前言包含用于自定义回答的自然语言说明。您可以请求自定义设置,例如长度、详细程度、输出风格(例如“简单”)、输出语言、答案重点和格式(例如表格、项目符号和 XML)。例如,前言可以是“用 10 岁孩子的语言进行说明”。
序言可能会对生成的回答的质量产生重大影响。如需了解应在前言中写入的内容以及优秀前言的示例,请参阅自定义前言简介。
如需使用与默认模型不同的模型生成回答,请执行以下操作:
运行以下 curl 命令:
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/engines/APP_ID /servingConfigs/default_search:answer" \ -d '{ "query": { "text": "QUERY "}, "answerGenerationSpec": { "promptSpec": { "preamble": "PREAMBLE ", } } }'替换以下内容:
PROJECT_ID
:您的 Google Cloud 项目的 ID。APP_ID
:您要查询的 Vertex AI Search 应用的 ID。QUERY
:包含问题或搜索查询的自由文本字符串。PREAMBLE
:用于自定义回答的自然语言说明。例如,请尝试使用show the answer format in an ordered list
或give a very detailed answer
。
命令和结果示例
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json" "https://discoveryengine.googleapis.com/v1/projects/my-project-123/locations/global/collections/default_collection/engines/my-app/servingConfigs/default_search:answer" \ -d '{ "query": { "text": "what is bigquery?"}, "answerGenerationSpec": { "promptSpec": { "preamble": "Explain like you are a ten years old kid", } } }'
{ "answer": { "state": "SUCCEEDED", "answerText": "BigQuery is like a super-powered storage space for your data, but it's in the cloud, not on your computer. It's like a giant warehouse for all your information, but you don't have to build or manage it yourself. You can use BigQuery to find patterns and insights in your data, like figuring out what people like to buy or how many people visited your website. It's like having a super-smart assistant that can help you understand your data better. BigQuery is really good at working with lots of data, even billions of pieces of information. \n", "steps": [ { "state": "SUCCEEDED", "description": "Rephrase the query and search.", "actions": [ { "searchAction": { "query": "What is BigQuery?" }, "observation": { "searchResults": [ { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/2d032dc582689e8c0ecea7fc7bfa3189", "uri": "https://cloud.google.com/bigquery", "title": "BigQuery enterprise data warehouse | Google Cloud", "snippetInfo": [ { "snippet": "\u003cb\u003eBigQuery\u003c/b\u003e is a fully managed, AI-ready data analytics platform that helps you maximize value from your data and is designed to be multi-engine, multi-format, ...", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/4474f4a5a18ecd611dedfe323dfe55d9", "uri": "https://cloud.google.com/bigquery/docs/introduction", "title": "BigQuery overview | Google Cloud", "snippetInfo": [ { "snippet": "\u003cb\u003eBigQuery\u003c/b\u003e is a fully managed, AI-ready data platform that helps you manage and analyze your data with built-in features like machine learning, search, ...", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/c840fdef90d86328f13bbedbdbf0ac10", "uri": "https://cloud.google.com/bigquery/docs/query-overview", "title": "Overview of BigQuery analytics | Google Cloud", "snippetInfo": [ { "snippet": "\u003cb\u003eBigQuery\u003c/b\u003e lets you save queries and share queries with others. When you save a query, it can be private (visible only to you), shared at the project level ( ...", "snippetStatus": "SUCCESS" } ] }, ... { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/5cbfab8ce1d5f6ffe45fef22900c9a00", "uri": "https://cloud.google.com/curated-resources/bigquery", "title": "Guides BigQuery | Google Cloud", "snippetInfo": [ { "snippet": "\u003cb\u003eBigQuery\u003c/b\u003e is Google Cloud's fully managed and serverless enterprise data warehouse solution, designed to help you make informed decisions quickly, so you can ...", "snippetStatus": "SUCCESS" } ] } ] } } ] } ] }, "answerQueryToken": "NMwKDAi8hN-2BhC0jMCPARIkNjZkN2I4MzItMDAwMC0yMTliLTkxN2EtMDg5ZTA4MjA0YjFj" }在此示例中,前言请求的答案比默认答案更简单。
如需了解详情,请参阅 Vertex AI Agent Builder Python API 参考文档。
如需向 Vertex AI Agent Builder 进行身份验证,请设置应用默认凭据。 如需了解详情,请参阅为本地开发环境设置身份验证。
添加引用
以下命令展示了如何请求在回答中添加引文。
如需使用与默认模型不同的模型生成回答,请执行以下操作:
运行以下 curl 命令:
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/engines/APP_ID /servingConfigs/default_search:answer" \ -d '{ "query": { "text": "QUERY "}, "answerGenerationSpec": { "includeCitations":INCLUDE_CITATIONS } }'替换以下内容:
PROJECT_ID
:您的 Google Cloud 项目的 ID。APP_ID
:您要查询的 Vertex AI Search 应用的 ID。QUERY
:包含问题或搜索查询的自由文本字符串。INCLUDE_CITATIONS
:指定是否要在回答中添加引文元数据。默认值为false
。
命令和部分结果示例
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://discoveryengine.googleapis.com/v1/projects/my-project-123/locations/global/collections/default_collection/engines/my-app/servingConfigs/default_search:answer" \ -d '{"query": { "text": "What is SQL"}, "answerGenerationSpec": { "includeCitations": true } }'
{ "answer": { "state": "SUCCEEDED", "answerText": "SQL stands for Structured Query Language and is a programming language used to manage, query, and retrieve data in a relational database. It is the standard language used by relational database management systems (RDBMS) such as PostgreSQL, SQL Server, MySQL, and Oracle Database. SQL statements are written in a statement format for queries and other database operations, allowing users to manipulate data in relational database tables. SQL is used to create and update the structure of tables, read and write data, manage user permissions, and perform administrative tasks. While originally created for relational databases, SQL is now a foundation for many technology capabilities, making SQL knowledge essential for many technology roles. \n", "citations": [ { "endIndex": "137", "sources": [ { "referenceId": "0" }, { "referenceId": "1" } ] }, { "startIndex": "138", "endIndex": "437", "sources": [ { "referenceId": "3" } ] }, { "startIndex": "438", "endIndex": "575", "sources": [ { "referenceId": "2" } ] }, { "startIndex": "576", "endIndex": "742", "sources": [ { "referenceId": "3" } ] } ], "references": [ { "chunkInfo": { "content": "There may be a second table that stores visit information. A relational database uses a unique ID for each row to maintain the linked patient information across the two tables. This way, you can quickly look up the visits of each patient. Sign up for a free trial for any of Google Cloud's SQL databases, which include AlloyDB, Cloud SQL, and Spanner. Get started for free What is SQL? SQL (Structured Query Language) is a programming language used to store, retrieve, and manage data in a relational database. SQL statements are English-like, making the language accessible to software developers, data analysts, and other practitioners. Benefits of SQL databases Enterprises choose SQL databases for being: Efficient. Relational databases are incredibly efficient in managing complex queries. Fast. SQL databases can retrieve large amounts of data, quickly. This makes them highly desirable for real-time transactional data. Reliable. SQL databases provide a high degree of data integrity and are ACID-compliant. SQL database engines There are numerous SQL database engines (products) used to build software applications. Some of the most popular include PostgreSQL, MySQL, SQL Server, and Oracle. Some database engines are open source while others are commercial offerings. ", "relevanceScore": 0.9, "documentMetadata": { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/7218ff4f57328d86059246d4af3a9953", "uri": "https://cloud.google.com/discover/what-are-sql-databases", "title": "SQL Databases | Google Cloud" } } }, { "chunkInfo": { "content": "PostgreSQL vs. SQL Server: What's the difference? | Google Cloud Page Contents Topics PostgreSQL vs. SQL PostgreSQL vs SQL Server: What are the key differences? Trying to find the right database for your applications? When it comes to choosing a database technology, the most common SQL options to consider are PostgreSQL vs. SQL Server. While both systems share many core features, there are some key differences—the major one being that PostgreSQL is open source and SQL Server is owned by Microsoft. Today, it is more vital than ever for companies to be able to manage, store, and activate data for modern business operations. With the growing assortment of databases available to choose from, it can be overwhelming to pick the right one for your applications. The most important thing to remember is that no single database will be a good match for every project requirement, so it's critical to understand the option that will work best for your specific use case. So, what is PostgreSQL vs. SQL Server? In this short guide, we'll discuss the basic differences between PostgreSQL and SQL Server. Get started for freeStay informed What is SQL? Structured Query Language or SQL, as it's more commonly known, is a programming language used to manage, query, and retrieve data in a relational database. ", "relevanceScore": 0.8, "documentMetadata": { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/f7cd9afab1282a9f57cdcee1885bb4c6", "uri": "https://cloud.google.com/learn/postgresql-vs-sql", "title": "PostgreSQL vs. SQL Server: What's the difference? | Google Cloud" } } }, { "chunkInfo": { "content": "SQL Databases | Google Cloud Page Contents Topics What are SQL databases? What are SQL databases? A SQL database, also known as a relational database, is a system that stores and organizes data into highly structured tables of rows and columns. These databases offer Structured Query Language (SQL) to read and write the data, and are categorized as relational database management systems (RDBMS). SQL statements are used to create and update the structure of tables, read and write data, manage user permissions, and perform administrative tasks. For example, a CREATE statement is used to create a table, an INSERT statement adds a new row to a table, and a SELECT statement performs a database query. Statements that make structural or administrative changes are usually reserved for software developers and administrators, while read and write operations are performed by end-user applications. A relational database maintains the ability to link information across multiple tables. This format makes it easy to quickly gain insights about the relationships between various columns or data points in these tables. A relational database can create indexes for particular columns for faster lookups. For example, a healthcare facility might maintain a table containing rows of patient information, where each row is one patient and the columns contain data points, such as the patient's name, insurance information, and contact details. ", "relevanceScore": 0.8, "documentMetadata": { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/7218ff4f57328d86059246d4af3a9953", "uri": "https://cloud.google.com/discover/what-are-sql-databases", "title": "SQL Databases | Google Cloud" } } }, { "chunkInfo": { "content": "It is the standard language used by relational database management systems (RDBMS), including PostgreSQL, SQL Server, MySQL, and Oracle Database. SQL typically uses commands written in statement format for queries and other database operations, which allow users to manipulate data in relational database tables. While originally created for relational databases, SQL acts as a foundation for many of today's technology capabilities, making SQL knowledge an essential skill for many technology roles today, including data analysts, database engineers, and even backend programming. However, you will find that there are different variants of SQL depending on the database or database management system that you choose. What is Microsoft SQL Server? SQL Server is a leading RDBMS that is built on top of SQL and developed by Microsoft. It is used to manage and store data to support numerous enterprise use cases for business intelligence, transaction processing, data analytics, and machine learning services. SQL Server has a row-based table structure that allows you to connect related data elements from different tables without having to store data multiple times in a database. In general, Microsoft SQL Server is known for its high availability, fast performance when handling large workloads, and easy integration with other applications to gain business intelligence across your entire data estate. For more information, we recommend reviewing the official SQL Server documentation. ", "relevanceScore": 0.8, "documentMetadata": { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/f7cd9afab1282a9f57cdcee1885bb4c6", "uri": "https://cloud.google.com/learn/postgresql-vs-sql", "title": "PostgreSQL vs. SQL Server: What's the difference? | Google Cloud" } } }, { "chunkInfo": { "content": "Send feedback The GoogleSQL language in Spanner bookmark_borderbookmark Stay organized with collections Save and categorize content based on your preferences. Dismiss Got it GoogleSQL is the new name for Google Standard SQL! New name, same great SQL dialect. This page provides an overview of supported statements in GoogleSQL. GoogleSQL is an ANSI compliant Structured Query Language (SQL) which includes the following types of supported statements: Query statements, also known as Data Query Language (DQL) statements, are the primary method to analyze data in Spanner. They scan one or more tables or expressions and return the computed result rows. Data Definition Language (DDL) statements let you create and modify database objects such as tables, views, and database roles. Data Manipulation Language (DML) statements enable you to update, insert, and delete data from your Spanner tables. Data Access Control statements let you grant and revoke access privileges at the table and column level. Transaction Control statements allow you to manage transactions for data modifications. Was this helpful? Send feedback Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. ", "relevanceScore": 0.7, "documentMetadata": { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/0c5c094170756eeb6bdfec6eb5c7d081", "uri": "https://cloud.google.com/spanner/docs/reference/standard-sql/overview", "title": "The GoogleSQL language in Spanner | Google Cloud" } } }, { "chunkInfo": { "content": "FAQ Expand all What is Cloud SQL? Cloud SQL is a service that delivers fully managed relational databases in the cloud. It offers MySQL, PostgreSQL, and SQL Server database engines. How is Cloud SQL different from other cloud databases? Cloud SQL is valued for its openness, ease of use, security, cost-efficiency, and Google Cloud integration—in fact, more than 95% of Google Cloud's top 100 customers use it. If you're comparing PostgreSQL options on Google Cloud, view our comparison chart. What's the difference between the Enterprise and Enterprise Plus editions? For PostgreSQL, the Enterprise Plus edition brings enhanced availability, performance, and data protection capabilities. Specifically, it provides a 99.99% availability SLA with near-zero downtime maintenance, optimized hardware and software configurations, intelligent data caching for read-intensive transactional workloads, a configurable data cache option and 35 days of log retention. For MySQL, the Enterprise Plus edition brings enhanced availability, performance, and data protection capabilities. Specifically, it provides a 99.99% availability SLA with near-zero downtime maintenance, optimized hardware and software configurations, intelligent data caching for read-intensive transactional workloads, a configurable data cache option, 35 days of log retention and advanced disaster recovery capabilities like orchestrated failover and switchback. ", "relevanceScore": 0.7, "documentMetadata": { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/931f2c8e19ed54a407857f1cad3b5aaa", "uri": "https://cloud.google.com/sql", "title": "Cloud SQL for MySQL, PostgreSQL, and SQL Server | Google Cloud" } } }, { "chunkInfo": { "content": "PostgreSQL versus SQL PostgreSQL is an open-source, object-relational database (ORDBMS) designed for enterprise-level performance and is valued for its reliability and robust features. Its long history of development and its use of SQL makes it one of the most popular open source databases worldwide. Its default procedural language is an extension of pgSQL (PL/pgSQL), with procedural language extensions of Tcl, Perl, and Python included in the standard distribution (written as PL/Tcl, PL/Perl, and PL/Python). Many more languages are supported through extensions, including Java, Ruby, C, C++, Delphi, and JavaScript. For a more in-depth comparison, visit our PostgreSQL versus SQL guide. MySQL versus SQL MySQL is a popular open source relational database created in 1995 and currently sponsored by Oracle. It supports SQL queries and can be administered either through a graphical user interface (GUI) or a command line. MySQL can be deployed manually on a physical machine or through a cloud service provider. Enterprises are increasingly choosing fully managed services to reduce the maintenance burden of their databases. What is SQL Server? SQL Server is a Microsoft-owned database that runs SQL queries. Dive into the differences between PostgreSQL and SQL Server. ", "relevanceScore": 0.6, "documentMetadata": { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/7218ff4f57328d86059246d4af3a9953", "uri": "https://cloud.google.com/discover/what-are-sql-databases", "title": "SQL Databases | Google Cloud" } } }, { "chunkInfo": { "content": "Send feedback On this page BigQuery SQL dialects Changing from the default dialect What's next Introduction to SQL in BigQuery bookmark_borderbookmark Stay organized with collections Save and categorize content based on your preferences. Dismiss Got it GoogleSQL is the new name for Google Standard SQL! New name, same great SQL dialect. This document provides an overview of supported statements and SQL dialects in BigQuery. GoogleSQL is an ANSI compliant Structured Query Language (SQL) which includes the following types of supported statements: Query statements, also known as Data Query Language (DQL) statements, are the primary method to analyze data in BigQuery. They scan one or more tables or expressions and return the computed result rows. Procedural language statements are procedural extensions to GoogleSQL that allow you to execute multiple SQL statements in one request. Procedural statements can use variables and control-flow statements, and can have side effects. Data Definition Language (DDL) statements let you create and modify database objects such as tables, views, functions, and row-level access policies. Data Manipulation Language (DML) statements enable you to update, insert, and delete data from your BigQuery tables. Data Control Language (DCL) statements let you control BigQuery system resources such as access and capacity. Transaction Control Language (TCL) statements allow you to manage transactions for data modifications. ", "relevanceScore": 0.6, "documentMetadata": { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/2f6fc3e29873518196cb50195d7ded45", "uri": "https://cloud.google.com/bigquery/docs/introduction-sql", "title": "Introduction to SQL in BigQuery | Google Cloud" } } }, { "chunkInfo": { "content": "Database administration Cloud SQL pricing Connect to a Cloud SQL managed database Cloud SQL updates Configuration updates System updates What's next Home Cloud SQL Documentation Guides Was this helpful? Send feedback Cloud SQL overview bookmark_borderbookmark Stay organized with collections Save and categorize content based on your preferences. Dismiss Got it On this page Database configurations with Cloud SQL Use cases for Cloud SQL What Cloud SQL provides What is a Cloud SQL instance? Database administration Cloud SQL pricing Connect to a Cloud SQL managed database Cloud SQL updates Configuration updates System updates What's next Cloud SQL is a fully managed relational database service for MySQL, PostgreSQL, and SQL Server. This frees you from database administration tasks so that you have more time to manage your data. This page discusses basic concepts and terminology for Cloud SQL, which provides SQL data storage for Google Cloud. For a more in-depth explanation of key concepts, see the key terms and features pages. For information about how Cloud SQL databases compare with one another, see Cloud SQL feature support by database engine. Database configurations with Cloud SQL The following video shows you the benefits of using Cloud SQL. ", "relevanceScore": 0.6, "documentMetadata": { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/4098ae11bfa400e8f1b8e9ba59d2b71b", "uri": "https://cloud.google.com/sql/docs/introduction", "title": "Cloud SQL overview" } } }, { "chunkInfo": { "content": "Cloud SQL documentation View all product documentation Cloud SQL is a fully-managed database service that helps you set up, maintain, manage, and administer your relational databases on Google Cloud Platform. You can use Cloud SQL with MySQL, PostgreSQL, or SQL Server. Not sure what database option is right for you? Learn more about our database services. Learn more about Cloud SQL. Documentation resources Find quickstarts and guides, review key references, and get help with common issues. format_list_numbered Guides Cloud SQL overview Database engine feature support MySQL PostgreSQL SQL Server find_in_page Reference gcloud commands REST API Client libraries info Resources Pricing Release notes Resources Try Cloud SQL for yourself Create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads. Try Cloud SQL free Was this helpful? Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Last updated 2024-08-29 UTC. ", "relevanceScore": 0.5, "documentMetadata": { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/37935181d99a6ad3b4897e673a7a7986", "uri": "https://cloud.google.com/sql/docs", "title": "Cloud SQL documentation" } } } ], "steps": [ { "state": "SUCCEEDED", "description": "Rephrase the query and search.", "actions": [ { "searchAction": { "query": "What is SQL?" }, "observation": { "searchResults": [ { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/7218ff4f57328d86059246d4af3a9953", "uri": "https://cloud.google.com/discover/what-are-sql-databases", "title": "SQL Databases | Google Cloud", "snippetInfo": [ { "snippet": "\u003cb\u003eSQL\u003c/b\u003e (Structured Query Language) is a programming language used to store, retrieve, and manage data in a relational database. \u003cb\u003eSQL\u003c/b\u003e statements are English-like, ...", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/f7cd9afab1282a9f57cdcee1885bb4c6", "uri": "https://cloud.google.com/learn/postgresql-vs-sql", "title": "PostgreSQL vs. SQL Server: What's the difference? | Google Cloud", "snippetInfo": [ { "snippet": "\u003cb\u003eSQL\u003c/b\u003e typically uses commands written in statement format for queries and other database operations, which allow users to manipulate data in relational database ...", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/3afdede140d0906c2146a2f2b3a7821e", "uri": "https://cloud.google.com/blog/topics/developers-practitioners/what-cloud-sql", "title": "What is Cloud SQL? | Google Cloud Blog", "snippetInfo": [ { "snippet": "It is a fully managed relational database for MySQL, PostgreSQL and \u003cb\u003eSQL\u003c/b\u003e Server. It reduces maintenance cost and automates database provisioning, storage ...", "snippetStatus": "SUCCESS" } ] }, ... { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/0c5c094170756eeb6bdfec6eb5c7d081", "uri": "https://cloud.google.com/spanner/docs/reference/standard-sql/overview", "title": "The GoogleSQL language in Spanner | Google Cloud", "snippetInfo": [ { "snippet": "\u003cb\u003eGoogleSQL\u003c/b\u003e is the new name for Google Standard \u003cb\u003eSQL\u003c/b\u003e! New name, same great \u003cb\u003eSQL\u003c/b\u003e dialect. This page provides an overview of supported statements in \u003cb\u003eGoogleSQL\u003c/b\u003e.", "snippetStatus": "SUCCESS" } ] } ] } } ] } ] }, "answerQueryToken": "NMwKDAiFm_y2BhC_nfrYAxIkNjZkYjg3NjItMDAwMC0yZTBkLTg0ZDAtMDg5ZTA4MmRjYjg0" }
如需了解详情,请参阅 Vertex AI Agent Builder Python API 参考文档。
如需向 Vertex AI Agent Builder 进行身份验证,请设置应用默认凭据。 如需了解详情,请参阅为本地开发环境设置身份验证。
设置答案语言代码
以下命令展示了如何为回答设置语言代码。
如需使用与默认模型不同的模型生成回答,请执行以下操作:
运行以下 curl 命令:
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/engines/APP_ID /servingConfigs/default_search:answer" \ -d '{ "query": { "text": "QUERY "}, "answerGenerationSpec": { "answerLanguageCode": "ANSWER_LANGUAGE_CODE " } }'替换以下内容:
PROJECT_ID
:您的 Google Cloud 项目的 ID。APP_ID
:您要查询的 Vertex AI Search 应用的 ID。QUERY
:包含问题或搜索查询的自由文本字符串。ANSWER_LANGUAGE_CODE
:答案的语言代码。请使用 BCP47:用于标识语言的标记中定义的语言标记。
命令和结果示例
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://discoveryengine.googleapis.com/v1/projects/my-project-123/locations/global/collections/default_collection/engines/my-app/servingConfigs/default_search:answer" \ -d '{"query": { "text": "What is SQL"}, "answerGenerationSpec": { "answerLanguageCode": "es" } }'
{ "answer": { "state": "SUCCEEDED", "answerText": "SQL, que significa Structured Query Language, es un lenguaje de programación utilizado para almacenar, recuperar y administrar datos en una base de datos relacional. Las instrucciones de SQL son similares al inglés, lo que hace que el lenguaje sea accesible para desarrolladores de software, analistas de datos y otros profesionales. Las bases de datos SQL se utilizan para administrar y almacenar datos para apoyar numerosos casos de uso empresariales, como la inteligencia empresarial, el procesamiento de transacciones, el análisis de datos y los servicios de aprendizaje automático. SQL es el lenguaje estándar utilizado por los sistemas de gestión de bases de datos relacionales (RDBMS), incluidos PostgreSQL, SQL Server, MySQL y Oracle Database. SQL se utiliza para crear y actualizar la estructura de las tablas, leer y escribir datos, administrar los permisos de los usuarios y realizar tareas administrativas. \n", "steps": [ { "state": "SUCCEEDED", "description": "Rephrase the query and search.", "actions": [ { "searchAction": { "query": "What is SQL?" }, "observation": { "searchResults": [ { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/7218ff4f57328d86059246d4af3a9953", "uri": "https://cloud.google.com/discover/what-are-sql-databases", "title": "SQL Databases | Google Cloud", "snippetInfo": [ { "snippet": "\u003cb\u003eSQL\u003c/b\u003e (Structured Query Language) is a programming language used to store, retrieve, and manage data in a relational database. \u003cb\u003eSQL\u003c/b\u003e statements are English-like, ...", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/f7cd9afab1282a9f57cdcee1885bb4c6", "uri": "https://cloud.google.com/learn/postgresql-vs-sql", "title": "PostgreSQL vs. SQL Server: What's the difference? | Google Cloud", "snippetInfo": [ { "snippet": "\u003cb\u003eSQL\u003c/b\u003e typically uses commands written in statement format for queries and other database operations, which allow users to manipulate data in relational database ...", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/3afdede140d0906c2146a2f2b3a7821e", "uri": "https://cloud.google.com/blog/topics/developers-practitioners/what-cloud-sql", "title": "What is Cloud SQL? | Google Cloud Blog", "snippetInfo": [ { "snippet": "It is a fully managed relational database for MySQL, PostgreSQL and \u003cb\u003eSQL\u003c/b\u003e Server. It reduces maintenance cost and automates database provisioning, storage ...", "snippetStatus": "SUCCESS" } ] }, ... { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/0c5c094170756eeb6bdfec6eb5c7d081", "uri": "https://cloud.google.com/spanner/docs/reference/standard-sql/overview", "title": "The GoogleSQL language in Spanner | Google Cloud", "snippetInfo": [ { "snippet": "\u003cb\u003eGoogleSQL\u003c/b\u003e is the new name for Google Standard \u003cb\u003eSQL\u003c/b\u003e! New name, same great \u003cb\u003eSQL\u003c/b\u003e dialect. This page provides an overview of supported statements in \u003cb\u003eGoogleSQL\u003c/b\u003e.", "snippetStatus": "SUCCESS" } ] } ] } } ] } ] }, "answerQueryToken": "NMwKDAjim_y2BhDftIjEAhIkNjZkOTQ0NWQtMDAwMC0yMTBkLTllNmItZjQwMzA0NWRiZDMw" }在此示例中,虽然来源文档是英文的,但答案是西班牙语的。
如需了解详情,请参阅 Vertex AI Agent Builder Python API 参考文档。
如需向 Vertex AI Agent Builder 进行身份验证,请设置应用默认凭据。 如需了解详情,请参阅为本地开发环境设置身份验证。
用于提问的命令
跟进问题是多轮询问。在后续会话中的首次询问后,系统会在后续的“回合”中考虑之前的互动。借助跟进问题,回答方法还可以建议相关问题,供用户选择,而无需输入自己的跟进问题。
您可以将前面部分中介绍的所有回答和跟进功能(例如引文、过滤条件、安全搜索、忽略某些类型的询问,以及使用前言自定义回答)与跟进问题一起使用。
后续会话示例
以下是包含跟进信息的会话示例。假设您想了解墨西哥的度假信息:
第 1 步:
你:一年中什么时候去墨西哥度假最合适?
回答并进行跟进:在墨西哥度假的最佳时间是从 11 月到 4 月的旱季。
第 2 步:
您:汇率是多少?
回答并进行跟进:1 美元约等于 17.65 墨西哥比索。
第 3 个回合:
您:12 月的平均温度是多少?
回答并进行跟进:平均温度在 70-78°F 之间。坎昆的平均温度约为 77°F。
如果不进行跟进,系统就无法回答“汇率是多少?”这个问题,因为常规搜索无法知道您想要的是墨西哥汇率。同样,如果没有跟进,我们就无法获得提供墨西哥具体温度所需的背景信息。
相关问题示例
当您询问“去墨西哥度假的最佳季节是什么?”时,除了回答您的问题外,回答和跟进问题还可以建议您可能要问的其他问题,例如“去墨西哥度假最便宜的月份是什么?”和“墨西哥的旅游旺季是什么月份?”
启用相关问题功能后,系统会在 ConverseConversationResponse 中以字符串的形式返回问题。
关于会话
如需了解跟进在 Vertex AI Search 中的运作方式,您需要了解会话。
会话由用户提供的文本查询和 Vertex AI Search 提供的回答组成。
这些询问和回答对有时也称为“回合”。在上例中,第二轮对话由“汇率是多少?”和“1 美元大约等于 17.65 墨西哥比索”组成。
会话会与应用一起存储。在应用中,会话由会话资源表示。
除了包含查询和响应消息之外,会话资源还包含:
唯一名称(会话 ID)。
状态(进行中或已完成)。
用户伪 ID,即用于跟踪用户的访问者 ID。可以通过编程方式进行分配。
开始时间和结束时间。
回合,即询问-回答对。
存储会话信息并获取响应
您可以使用命令行生成搜索回答和解答,并将这些内容以及会话中的每项询问存储起来。
如需使用命令行创建会话并根据用户的输入生成回答,请按以下步骤操作:
指定要存储会话的应用:
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/engines/APP_ID /sessions" \ -d '{ "userPseudoId": "USER_PSEUDO_ID " }'替换以下内容:
PROJECT_ID
:您的 Google Cloud 项目的 ID。APP_ID
:Vertex AI Search 应用的 ID。USER_PSEUDO_ID
:这是用于跟踪搜索访问者的唯一标识符。例如,您可以使用 HTTP Cookie 来实现此功能,HTTP Cookie 可唯一标识单个设备上的访问者。
命令和结果示例
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json" "https://discoveryengine.googleapis.com/v1/projects/my-project-123/locations/global/collections/default_collection/engines/my-app/sessions" -d '{ "userPseudoId": "test_user" }'
{ "name": "projects/123456/locations/global/collections/default_collection/engines/my-app/sessions/16002628354770206943", "state": "IN_PROGRESS", "userPseudoId": "test_user", "startTime": "2024-09-13T18:47:10.465311Z", "endTime": "2024-09-13T18:47:10.465311Z" }记下 JSON 响应中
name:
字段末尾的数字,即会话 ID。在示例结果中,ID 为5386462384953257772
。下一步中需要用到此 ID。生成回答并将其添加到应用中的会话:
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/engines/APP_ID /servingConfigs/default_search:answer" \ -d '{ "query": { "text": "QUERY "}, "session": "projects/PROJECT_ID /locations/global/collections/default_collection/engines/APP_ID /sessions/SESSION_ID ", "searchSpec":{ "searchParams": {"filter": "FILTER "} } }'替换以下内容:
PROJECT_ID
:您的 Google Cloud 项目的 ID。APP_ID
:Vertex AI Search 应用的 ID。QUERY
:包含问题或搜索查询的自由文本字符串。SESSION_ID
:您在第 1 步中创建的会话的 ID。这些是name:
字段末尾的数字,请参阅第 2 步。对于会话,请在每轮对话中使用相同的会话 ID。FILTER
:用于使用过滤条件表达式过滤搜索结果的文本字段。默认值为空字符串。过滤条件的构建方式因您拥有的非结构化数据是否包含元数据、结构化数据或网站数据而异。如需了解详情,请参阅过滤结构化或非结构化数据的通用搜索和过滤网站搜索。
命令和结果示例
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json" "https://discoveryengine.googleapis.com/v1/projects/my-project-123/locations/global/collections/default_collection/engines/my-app/servingConfigs/default_search:answer" -d '{ "query": { "text": "Compare bigquery with spanner database?"}, "session": "projects/123456/locations/global/collections/default_collection/engines/my-app/sessions/16002628354770206943", }'
{ "answer": { "name": "projects/123456/locations/global/collections/default_collection/engines/my-app/sessions/16002628354770206943/answers/4861507376861383072", "state": "SUCCEEDED", "answerText": "BigQuery and Spanner are both powerful tools that can be used together to handle transactional and analytical workloads. Spanner is a fully managed relational database optimized for transactional workloads, while BigQuery is a serverless data warehouse designed for business agility. Spanner provides seamless replication across regions in Google Cloud and processes over 1 billion requests per second at peak. BigQuery analyzes over 110 terabytes of data per second. Users can leverage federated queries to read data from Spanner and write to a native BigQuery table. \n", "steps": [ { "state": "SUCCEEDED", "description": "Rephrase the query and search.", "actions": [ { "searchAction": { "query": "Compare bigquery with spanner database?" }, "observation": { "searchResults": [ { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/ecc0e7547253f4ca3ff3328ce89995af", "uri": "https://cloud.google.com/blog/topics/developers-practitioners/how-spanner-and-bigquery-work-together-handle-transactional-and-analytical-workloads", "title": "How Spanner and BigQuery work together to handle transactional and analytical workloads | Google Cloud Blog", "snippetInfo": [ { "snippet": "Using Cloud \u003cb\u003eSpanner\u003c/b\u003e and \u003cb\u003eBigQuery\u003c/b\u003e also allows customers to build their \u003cb\u003edata\u003c/b\u003e clouds using Google Cloud, a unified, open approach to \u003cb\u003edata\u003c/b\u003e-driven transformation ...", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/d7e238f73608a860e00b752ef80e2941", "uri": "https://cloud.google.com/blog/products/databases/cloud-spanner-gets-stronger-with-bigquery-federated-queries", "title": "Cloud Spanner gets stronger with BigQuery-federated queries | Google Cloud Blog", "snippetInfo": [ { "snippet": "As enterprises compete for market share, their need for real-time insights has given rise to increased demand for transactional \u003cb\u003edatabases\u003c/b\u003e to support \u003cb\u003edata\u003c/b\u003e ...", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/e10a5a3c267dc61579e7c00fefe656eb", "uri": "https://cloud.google.com/blog/topics/developers-practitioners/replicating-cloud-spanner-bigquery-scale", "title": "Replicating from Cloud Spanner to BigQuery at scale | Google Cloud Blog", "snippetInfo": [ { "snippet": "... \u003cb\u003eSpanner data\u003c/b\u003e into \u003cb\u003eBigQuery\u003c/b\u003e for analytics. In this post, you will learn how to efficiently use this feature to replicate large tables with high throughput ...", "snippetStatus": "SUCCESS" } ] }, ... { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/8100ad36e1cac149eb9fc180a41d8f25", "uri": "https://cloud.google.com/blog/products/gcp/from-nosql-to-new-sql-how-spanner-became-a-global-mission-critical-database", "title": "How Spanner became a global, mission-critical database | Google Cloud Blog", "snippetInfo": [ { "snippet": "... SQL \u003cb\u003evs\u003c/b\u003e. NoSQL dichotomy may no longer be relevant." The \u003cb\u003eSpanner\u003c/b\u003e SQL query processor, while recognizable as a standard implementation, has unique ...", "snippetStatus": "SUCCESS" } ] } ] } } ] } ] }, "session": { "name": "projects/123456/locations/global/collections/default_collection/engines/my-app/sessions/16002628354770206943", "state": "IN_PROGRESS", "userPseudoId": "test_user", "turns": [ { "query": { "queryId": "projects/123456/locations/global/questions/741830", "text": "Compare bigquery with spanner database?" }, "answer": "projects/123456/locations/global/collections/default_collection/engines/my-app/sessions/16002628354770206943/answers/4861507376861383072" } ], "startTime": "2024-09-13T18:47:10.465311Z", "endTime": "2024-09-13T18:47:10.465311Z" }, "answerQueryToken": "NMwKDAjFkpK3BhDU24uZAhIkNjZlNDIyZWYtMDAwMC0yMjVmLWIxMmQtZjQwMzA0M2FkYmNj" }针对会话中的每个新查询重复第 3 步。
如需了解详情,请参阅 Vertex AI Agent Builder Python API 参考文档。
如需向 Vertex AI Agent Builder 进行身份验证,请设置应用默认凭据。 如需了解详情,请参阅为本地开发环境设置身份验证。
从数据存储区获取会话
以下命令展示了如何调用 get
方法并从数据存储区获取会话。
如需从数据存储区获取会话,请执行以下操作:
运行以下 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/engines/APP_ID /sessions/SESSION_ID "替换以下内容:
PROJECT_ID
:您的 Google Cloud 项目的 ID。APP_ID
:Vertex AI Search 应用的 ID。SESSION_ID
:您要获取的会话的 ID。
如需了解详情,请参阅 Vertex AI Agent Builder Python API 参考文档。
如需向 Vertex AI Agent Builder 进行身份验证,请设置应用默认凭据。 如需了解详情,请参阅为本地开发环境设置身份验证。
从应用中删除会话
以下命令展示了如何调用 delete
方法并从数据存储区中删除会话。
默认情况下,系统会自动删除保留时长超过 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/engines/APP_ID /sessions/SESSION_ID "替换以下内容:
PROJECT_ID
:您的 Google Cloud 项目的 ID。APP_ID
:Vertex AI Search 应用的 ID。SESSION_ID
:您要删除的会话的 ID。
命令和结果示例
curl -X DELETE -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json" "https://discoveryengine.googleapis.com/v1/projects/123456/locations/global/collections/default_collection/engines/my-app/sessions/16002628354770206943"
{}
如需了解详情,请参阅 Vertex AI Agent Builder Python API 参考文档。
如需向 Vertex AI Agent Builder 进行身份验证,请设置应用默认凭据。 如需了解详情,请参阅为本地开发环境设置身份验证。
更新会话
您可能因下列多种原因而需要更新会话。例如,执行以下任一操作:
- 将会话标记为已完成
- 将一个会话中的消息合并到另一个会话中
- 更改用户的伪 ID
以下命令展示了如何调用 patch
方法并更新数据存储区中的会话。
如需通过应用更新会话,请执行以下操作:
运行以下 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/engines/APP_ID /sessions/SESSION_ID ?updateMask=state" \ -d '{ "state": "NEW_STATE " }'替换以下内容:
PROJECT_ID
:您的 Google Cloud 项目的 ID。APP_ID
:Vertex AI Search 应用的 ID。SESSION_ID
:您要更新的会话的 ID。NEW_STATE
:状态的新值,例如IN_PROGRESS
。
命令和结果示例
curl -X PATCH -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json" "https://discoveryengine.googleapis.com/v1/projects/123456/locations/global/collections/default_collection/engines/my-app/sessions/16002628354770206943?updateMask=state" -d '{ "state": "IN_PROGRESS" }'
{ "name": "projects/123456/locations/global/collections/default_collection/engines/my-app/sessions/16002628354770206943", "state": "IN_PROGRESS", "userPseudoId": "test_user", "turns": [ { "query": { "queryId": "projects/123456/locations/global/questions/741830", "text": "Compare bigquery with spanner database?" }, "answer": "projects/123456/locations/global/collections/default_collection/engines/my-app/sessions/16002628354770206943/answers/4861507376861383072" } ], "startTime": "2024-09-13T18:47:10.465311Z", "endTime": "2024-09-13T18:49:41.579151Z" }此示例会将会话状态更改为“打开(进行中)”。按照类似的模式更新
userPseudoId
。
如需了解详情,请参阅 Vertex AI Agent Builder Python API 参考文档。
如需向 Vertex AI Agent Builder 进行身份验证,请设置应用默认凭据。 如需了解详情,请参阅为本地开发环境设置身份验证。
列出所有会话
以下命令展示了如何调用 list
方法并列出数据存储区中的会话。
如需列出应用的会话,请执行以下操作:
运行以下 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/engines/APP_ID /sessions"替换以下内容:
PROJECT_ID
:您的 Google Cloud 项目的 ID。APP_ID
:Vertex AI Search 应用的 ID。
命令和结果示例
curl -X GET -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json" "https://discoveryengine.googleapis.com/v1/projects/123456/locations/global/collections/default_collection/engines/my-app/sessions"
{ "sessions": [ { "name": "projects/123456/locations/global/collections/default_collection/engines/my-app/sessions/10000135306311111817", "state": "IN_PROGRESS", "turns": [ { "query": { "queryId": "projects/123456/locations/global/questions/10000135306311114276", "text": "bugs reported by tiktok on grounding" } } ], "startTime": "2024-09-03T00:38:40.338623Z", "endTime": "2024-09-03T00:38:40.338623Z" }, { "name": "projects/123456/locations/global/collections/default_collection/engines/my-app/sessions/10000827040519035859", "state": "IN_PROGRESS", "turns": [ { "query": { "queryId": "projects/123456/locations/global/questions/10000827040519033518", "text": "GDM models" } } ], "startTime": "2024-07-19T15:53:06.521775Z" }, { "name": "projects/123456/locations/global/collections/default_collection/engines/my-app/sessions/10003910515245149877", "state": "IN_PROGRESS", "turns": [ { "query": { "queryId": "projects/123456/locations/global/questions/10003910515245148378", "text": "gyorgyattila" }, "answer": "projects/123456/locations/global/collections/default_collection/engines/my-app/sessions/10003910515245149877/answers/17036357111873257990" } ], "startTime": "2024-08-08T11:40:04.632463Z", "endTime": "2024-08-08T11:40:04.632463Z" }, ... { "name": "projects/123456/locations/global/collections/default_collection/engines/my-app/sessions/10198752942940073431", "state": "IN_PROGRESS", "turns": [ { "query": { "queryId": "projects/123456/locations/global/questions/10198752942940071818", "text": "hello" }, "answer": "projects/123456/locations/global/collections/default_collection/engines/my-app/sessions/10198752942940073431/answers/13411441797796265380" } ], "startTime": "2024-08-14T17:30:21.203439Z", "endTime": "2024-08-14T17:30:21.203439Z" } ], "nextPageToken": "IDEDgIwL_vuieLC" }响应包含会话列表和 nextPageToken。如果未返回 nextPageToken,则表示没有更多会话可列出。默认页面大小为 50。
如需了解详情,请参阅 Vertex AI Agent Builder Python API 参考文档。
如需向 Vertex AI Agent Builder 进行身份验证,请设置应用默认凭据。 如需了解详情,请参阅为本地开发环境设置身份验证。
列出用户的会话
以下命令展示了如何调用 list
方法来列出与用户或访问者关联的会话。
如需列出与用户或访问者关联的会话,请执行以下操作:
运行以下 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/engines/APP_ID /sessions?filter=userPseudoId=USER_PSEUDO_ID "替换以下内容:
PROJECT_ID
:您的 Google Cloud 项目的 ID。APP_ID
:Vertex AI Search 应用的 ID。USER_PSEUDO_ID
:您要列出其会话的用户的伪 ID。
命令和结果示例
curl -X GET -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json" "https://discoveryengine.googleapis.com/v1/projects/123456/locations/global/collections/default_collection/engines/my-app/sessions?filter=userPseudoId=test_user"
{ "sessions": [ { "name": "projects/123456/locations/global/collections/default_collection/engines/my-app/sessions/16002628354770206943", "state": "IN_PROGRESS", "userPseudoId": "test_user", "turns": [ { "query": { "queryId": "projects/123456/locations/global/questions/741830", "text": "Compare bigquery with spanner database?" }, "answer": "projects/123456/locations/global/collections/default_collection/engines/my-app/sessions/16002628354770206943/answers/4861507376861383072" } ], "startTime": "2024-09-13T18:47:10.465311Z", "endTime": "2024-09-13T18:49:41.579151Z" } ] }在此示例中,与 test_user 相关联的会话有 1 个。系统会列出会话中的询问和回答。
如需了解详情,请参阅 Vertex AI Agent Builder Python API 参考文档。
如需向 Vertex AI Agent Builder 进行身份验证,请设置应用默认凭据。 如需了解详情,请参阅为本地开发环境设置身份验证。
列出用户和状态的会话
以下命令展示了如何调用 list
方法,以列出特定用户处于给定状态的会话。
如需列出与给定用户或访问者关联的处于打开或关闭状态的用户会话,请执行以下操作:
运行以下 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/engines/APP_ID /sessions?filter=userPseudoId=USER_PSEUDO_ID %20AND%20state=STATE "替换以下内容:
PROJECT_ID
:您的 Google Cloud 项目的 ID。APP_ID
:Vertex AI Search 应用的 ID。USER_PSEUDO_ID
:您要列出其会话的用户的伪 ID。STATE
:会话状态:STATE_UNSPECIFIED
(已关闭或未知)或IN_PROGRESS
(未结)。
命令和结果示例
curl -X GET -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json" "https://discoveryengine.googleapis.com/v1/projects/123456/locations/global/collections/default_collection/engines/my-app/sessions?filter=userPseudoId=test_user%20AND%20state=IN_PROGRESS"
{ "sessions": [ { "name": "projects/123456/locations/global/collections/default_collection/engines/my-app/sessions/16002628354770206943", "state": "IN_PROGRESS", "userPseudoId": "test_user", "turns": [ { "query": { "queryId": "projects/123456/locations/global/questions/741830", "text": "Compare bigquery with spanner database?" }, "answer": "projects/123456/locations/global/collections/default_collection/engines/my-app/sessions/16002628354770206943/answers/4861507376861383072" } ], "startTime": "2024-09-13T18:47:10.465311Z", "endTime": "2024-09-13T18:49:41.579151Z" } ] }预期结果为空响应。
如需了解详情,请参阅 Vertex AI Agent Builder Python API 参考文档。
如需向 Vertex AI Agent Builder 进行身份验证,请设置应用默认凭据。 如需了解详情,请参阅为本地开发环境设置身份验证。