Esta página apresenta a pesquisa com respostas e seguimentos para a Pesquisa do Vertex AI e mostra como a implementar para apps de pesquisa personalizadas através de chamadas de métodos.
Nota: as funcionalidades de resposta e seguimentos não podem ser aplicadas a lojas de dados de multimédia ou de cuidados de saúde.
A pesquisa com resposta e seguimentos baseia-se no método de resposta. O método de resposta
substitui as funcionalidades de resumo do método search mais antigo
e todas as funcionalidades do método converse descontinuado.
O método de resposta também tem algumas funcionalidades adicionais importantes, como a capacidade de processar consultas complexas.
Termo principal: nesta página, o termo resposta refere-se a uma resposta gerada pela IA que se baseia nos resultados da pesquisa de uma consulta. É essencialmente o mesmo que o
resumo , que pode ser gerado pelo método de pesquisa.
Funcionalidades do método de resposta
Seguem-se as principais funcionalidades do método de resposta:
A capacidade de gerar respostas a consultas complexas. Por exemplo, o método answer pode dividir consultas compostas, como as seguintes, em várias consultas mais pequenas para devolver melhores resultados que são usados para gerar melhores respostas:
"Qual é a receita respetiva do Google Cloud e do Google Ads em 2024?"
"Quantos anos após a sua fundação, a Google atingiu 1000 milhões de USD de receita?"
A capacidade de combinar a pesquisa e a geração de respostas numa conversa de várias interações chamando o método de resposta em cada interação.
A capacidade de sincronizar com o método de pesquisa para reduzir a latência de pesquisa. Pode chamar o método de pesquisa e o método de resposta separadamente e renderizar os resultados da pesquisa e as respostas em diferentes iFrames em momentos diferentes. Isto significa que pode apresentar aos seus utilizadores resultados da pesquisa (os 10 links azuis) em milissegundos. Não tem de esperar que as respostas sejam geradas antes de poder mostrar os resultados da pesquisa.
As funcionalidades de resposta e seguimentos podem ser divididas em três fases da consulta, pesquisa e resposta:
Quando usar a resposta e quando usar a pesquisa
O Vertex AI Search tem dois métodos que são usados para consultar apps. Têm funcionalidades diferentes, mas
sobrepostas.
Use o método answer quando:
Quer uma resposta (ou um resumo) gerada pela IA dos resultados da pesquisa.
Quer pesquisas com várias interações, ou seja, pesquisas que mantêm o contexto para permitir perguntas de seguimento.
Use o método search nos seguintes casos:
Só precisa de resultados da pesquisa e não de uma resposta gerada.
Tem qualquer um dos seguintes elementos:
Dados de comunicação social ou de cuidados de saúde
As suas próprias incorporações
Controlos de sinónimos ou redirecionamentos
Atributos
Códigos dos países dos utilizadores
Tem de procurar os dados no seu repositório de dados genérico.
Use os métodos de resposta e pesquisa em conjunto quando:
Quer devolver mais de dez resultados da pesquisa e quer uma resposta gerada.
Tem problemas de latência e quer devolver e apresentar rapidamente os resultados da pesquisa
antes de a resposta gerada ser devolvida.
Funcionalidades da fase de consulta
A funcionalidade de respostas e seguimentos suporta o processamento de consultas de linguagem natural.
Esta secção descreve e ilustra as várias opções de reformulação e classificação de consultas.
Reformulação de consultas
A reformulação de consultas está ativada por predefinição. Esta funcionalidade escolhe automaticamente a melhor forma de reformular as consultas para melhorar os resultados da pesquisa. Esta funcionalidade também pode processar consultas que não requerem reformulação.
Divida consultas complexas em várias consultas e execute subconsultas síncronas.
Por exemplo: uma consulta complexa é dividida em quatro consultas mais pequenas e simples.
Introdução do utilizador
Subconsultas criadas a partir da consulta complexa
Que empregos e hobbies têm Andie Ram e Arnaud
Clément em comum?
Profissão de Andie Ram
Ocupação de Arnaud Clément
Andie Ram hobby
Passatempo de Arnaud Clément
Sintetizar consultas de várias interações para tornar as perguntas de seguimento sensíveis ao contexto e com estado.
Por exemplo, as consultas sintetizadas a partir da introdução do utilizador em cada interação podem ter o seguinte aspeto:
Introdução do utilizador
Consulta sintetizada
Turn 1: portáteis para a escola
portáteis para a escola
Turn 2: not mac
portáteis para a escola que não sejam Mac
Turn 3: bigger screen and i also need wireless keyboard and
mouse
portáteis com ecrã maior para a escola, que não sejam Mac, com teclado e rato sem fios
Turn 4: and a backpack for it
portáteis com ecrã maior para a escola, que não sejam Macs, com teclado e rato sem fios e uma mochila para o portátil
Simplificar consultas longas para melhorar a obtenção (requer funcionalidades avançadas de MDG ).
Por exemplo: uma consulta longa é reduzida a uma consulta típica.
Introdução do utilizador
Consulta simplificada
Estou a tentar descobrir por que motivo o botão "Adicionar ao carrinho" no nosso Website não está a funcionar corretamente. Parece que, quando um utilizador clica no botão, o artigo não é adicionado ao carrinho e recebe uma mensagem de erro. Verifiquei o código e parece estar correto, por isso, não tenho a certeza de qual poderá ser o problema. Podes ajudar-me a
resolver este problema?
O botão "Adicionar ao carrinho" não funciona no Website.
Realizar raciocínio em vários passos
Termos principais: os passos (também denominados saltos ) são usados para responder a perguntas complexas. A pergunta é dividida em
vários passos de obtenção de informações e inferência.
O raciocínio em vários passos baseia-se no paradigma ReAct (reason + act), que permite aos MDLs resolver tarefas complexas através do raciocínio em linguagem natural.
Por predefinição, o número máximo de passos é cinco.
Por exemplo:
Introdução do utilizador
Dois passos para gerar a resposta
Quantos anos após a sua fundação, a Google atingiu 1000 milhões de USD de receita?
Passo 1:
[Thought]: I need to know when Google was founded, then I can query it is revenue since then.
[Act] Search: When was Google founded?[Observe Search Results]: "1998"
Passo 2:
[Thought]: Agora, preciso de saber a receita anual da Google desde 1998 e descobrir quando excedeu 1000 milhões pela primeira vez.
[Act] Pesquisar: receita da Google desde 1998
[Observe Search Results] Receita da Google em 1998, receita da Google em 1999…
[Resposta]: A Google alcançou uma receita de mais de 1000 milhões de USD em 2003 [1], 5 anos após a sua fundação em 1998 [2].
O raciocínio em vários passos requer funcionalidades avançadas de LLM .
Classificação de consultas
As opções de classificação de consultas destinam-se a identificar consultas adversariais e consultas que não procuram respostas. Por predefinição, as opções de classificação de consultas estão desativadas.
Para mais informações sobre consultas adversariais e que não procuram respostas, consulte os artigos Ignorar consultas
adversariais e Ignorar consultas que não procuram resumos .
Funcionalidades da fase de pesquisa
Para a pesquisa, o método de resposta tem as mesmas opções que o método de pesquisa. Por
exemplo:
Funcionalidades da fase de resposta
Durante a fase de resposta, quando as respostas são geradas a partir dos resultados da pesquisa, pode ativar as mesmas funcionalidades que no método de pesquisa. Por exemplo:
Funcionalidades adicionais da fase de resposta que não estão disponíveis no método de pesquisa:
Obter uma pontuação de apoio para cada afirmação (frase na resposta gerada).
Uma pontuação de apoio é um valor de ponto flutuante no intervalo [0,1] que indica o quão fundamentada está a reivindicação nos dados na base de dados. Para mais
informações, consulte o artigo Devolva classificações de apoio técnico de fundamentação .
Receber uma pontuação de apoio técnico agregada para a resposta. A pontuação de apoio técnico
indica o quão bem a resposta se baseia nos dados do armazenamento de dados. Para
mais informações, consulte a secção Devolver classificações de apoio
de fundamentação .
Devolver apenas respostas bem fundamentadas. Pode optar por devolver apenas as respostas que atingem um determinado limite de pontuação de apoio técnico. Para mais informações,
consulte o artigo Mostre apenas respostas bem fundamentadas .
Opte por devolver perguntas relacionadas. As perguntas relacionadas são sugestões que os seus utilizadores podem escolher em vez de introduzirem as suas próprias perguntas.
Adicionar informações de personalização às consultas para que as respostas possam ser
personalizadas para utilizadores individuais. Para mais informações, consulte o artigo Personalize as respostas .
Para receber respostas multimodais que incluem gráficos ou imagens, além de texto, estão disponíveis as seguintes opções:
Receber respostas que incluem tabelas e gráficos que representam os dados contidos nas respostas. Para mais informações, consulte o artigo Gere gráficos para respostas .
A obter imagens do repositório de dados. Se o repositório de dados contiver imagens,
o método de resposta pode devolver uma imagem na resposta. As imagens do armazenamento de dados também podem ser devolvidas em referências se forem pedidas citações. Para mais informações, consulte o artigo Recupere imagens existentes do arquivo de dados .
Antes de começar
Consoante o tipo de app que tiver, cumpra os seguintes requisitos:
Se tiver uma app de pesquisa estruturada, não estruturada ou de Website, ative as seguintes opções:
Funcionalidades da edição Enterprise : isto dá-lhe acesso às funcionalidades de respostas generativas essenciais. Isto inclui todas as funcionalidades de geração de respostas, exceto as funcionalidades de respostas generativas avançadas, como perguntas relacionadas, simplificação de consultas, consultas de várias interações e respostas multimodais que devolvem imagens e gráficos.
Funcionalidades avançadas de GML : isto dá-lhe acesso às funcionalidades de respostas generativas avançadas que requerem raciocínio de vários passos, simplificação de consultas, consultas multifacetadas, perguntas relacionadas e respostas multimodais que devolvem imagens e gráficos.
Além disso, se tiver um arquivo de dados de pesquisa no Website, ative a opção
Indexação avançada de Websites .
Pesquisar e responder (básico)
O comando seguinte mostra como chamar o método answer e devolver uma resposta gerada e uma lista de resultados da pesquisa, com links para as fontes.
Este comando mostra apenas a entrada necessária. As opções são mantidas como predefinições.
REST
Para pesquisar e receber resultados com uma resposta gerada, faça o seguinte:
Execute o seguinte comando 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 "}
}'
Substitua o seguinte:
PROJECT_ID
: o ID do seu projeto Google Cloud .
APP_ID
: o ID da app Vertex AI Search que quer consultar.
QUERY
: uma string de texto livre que contém a pergunta ou a consulta de pesquisa. Por exemplo, "Comparar as bases de dados do BigQuery e do Spanner?".
Comando de exemplo e resultado parcial
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"
}
Neste exemplo, a consulta é decomposta em partes: "Qual é o desempenho do Spanner?" e "Qual é o desempenho do BigQuery?"
Comandos da fase de consulta
Esta secção mostra como especificar opções para a fase de consulta da chamada do método answer .
Pesquise e responda (reformulação desativada)
O comando seguinte mostra como chamar o método answer e devolver uma resposta gerada e uma lista de resultados da pesquisa. A resposta pode ser diferente da resposta anterior porque a opção de reformulação está desativada.
REST
Para pesquisar e receber resultados com uma resposta gerada sem aplicar a reformulação da consulta, faça o seguinte:
Execute o seguinte comando 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
}
}
}'
Substitua o seguinte:
PROJECT_ID
: o ID do seu projeto Google Cloud .
APP_ID
: o ID da app Vertex AI Search.
QUERY
: uma string de texto livre que contém a pergunta ou a consulta de pesquisa. Por exemplo, "Comparar as bases de dados do BigQuery e do Spanner?".
Comando de exemplo e resultado parcial
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"
}
Pesquisar e responder (especificar o número máximo de passos)
O comando seguinte mostra como chamar o método answer e devolver uma resposta gerada e uma lista de resultados da pesquisa. A resposta é diferente das respostas anteriores porque o número de passos de reformulação foi aumentado.
REST
Para pesquisar e obter resultados com uma resposta gerada que permite até cinco passos de reformulação, faça o seguinte:
Execute o seguinte comando 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
}
}
}'
Substitua o seguinte:
PROJECT_ID
: o ID do seu projeto Google Cloud .
APP_ID
: o ID da app Vertex AI Search que quer consultar.
QUERY
: uma string de texto livre que contém a pergunta ou a consulta de pesquisa. Por exemplo, "Comparar as bases de dados do BigQuery e do Spanner?".
MAX_REPHRASE
: o número máximo de passos de reformulação. O valor máximo permitido é 5
.
Se não for definido ou se for definido para um valor inferior a 1
, o valor é o predefinido,
1
.
Exemplo de comando
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
}
}
}'
Pesquise e responda com a classificação de consultas
O comando seguinte mostra como chamar o método answer para saber se uma consulta é adversária, não procura respostas ou nenhuma das opções.
A resposta inclui o tipo de classificação da consulta, mas a resposta em si não é afetada pela classificação.
Se quiser alterar o comportamento da resposta de acordo com o tipo de consulta, pode fazê-lo na fase de resposta. Consulte Ignorar consultas
adversariais e Ignorar consultas que não procuram
resumos .
REST
Para determinar se uma consulta é adversária ou não procura uma resposta, faça o seguinte:
Execute o seguinte comando 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 "]
}
}
}'
Substitua o seguinte:
PROJECT_ID
: o ID do seu projeto Google Cloud .
APP_ID
: o ID da app Vertex AI Search que quer consultar.
QUERY
: uma string de texto livre que contém a pergunta ou a consulta de pesquisa. Por exemplo, "olá".
QUERY_CLASSIFICATION_TYPE
: os tipos de consultas
que quer identificar: ADVERSARIAL_QUERY
,
NON_ANSWER_SEEKING_QUERY
ou ambos.
Comando de exemplo e resultado parcial
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"
}
Neste exemplo, a consulta "olá" não é hostil, mas é classificada como não relacionada com a procura de respostas.
Comandos da fase de pesquisa: pesquisar e responder com opções de resultados da pesquisa
Esta secção mostra como especificar opções para a parte da fase de pesquisa da chamada do método answer , como definir o número máximo de documentos devolvidos, o aumento e a filtragem, e como obter uma resposta quando fornece os seus próprios resultados da pesquisa.
O comando seguinte mostra como chamar o método answer e especificar várias opções sobre como o resultado da pesquisa é devolvido. (Os resultados da pesquisa são independentes da resposta.)
REST
Para definir várias opções relacionadas com os resultados de pesquisa devolvidos e a forma como são devolvidos, faça o seguinte:
Execute o seguinte comando 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
}
}
}'
Substitua o seguinte:
PROJECT_ID
: o ID do seu projeto Google Cloud .
APP_ID
: o ID da app Vertex AI Search que quer consultar.
QUERY
: uma string de texto livre que contém a pergunta ou a consulta de pesquisa. Por exemplo, "Comparar as bases de dados do BigQuery e do Spanner?"
MAX_RETURN_RESULTS
: o número de resultados da pesquisa a devolver. O valor predefinido é 10
. O valor máximo é 25
.
FILTER
: o filtro especifica os documentos
que são consultados. Se os metadados de um documento cumprirem a especificação do filtro, o documento é consultado. Para mais informações, incluindo a sintaxe
dos filtros, consulte o artigo Filtre
a pesquisa personalizada para dados estruturados ou não estruturados .
BOOST_SPEC
: a especificação de aumento permite-lhe
aumentar determinados documentos nos resultados da pesquisa, o que pode afetar a resposta.
Para mais informações, incluindo a sintaxe da especificação de aumento, consulte o artigo
Aumente os resultados da pesquisa .
ORDER_BY
: a ordem em que os documentos são devolvidos. Os documentos podem ser ordenados por um campo num objeto Document . A expressão orderBy
é sensível a maiúsculas e minúsculas.
Se este campo for irreconhecível, é devolvido um INVALID_ARGUMENT
.
SEARCH_RESULT_MODE
: especifica o modo de resultado da pesquisa: DOCUMENTS
ou CHUNKS
. Para mais
informações, consulte
Analise e
divida documentos em partes e ContentSearchSpec .
Este campo só está disponível na versão v1alpha da API.
Exemplo de comando e resultado
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"
}
Neste exemplo, o número de documentos devolvidos está limitado a três.
Comandos da fase de resposta
Esta secção mostra como personalizar a chamada do método answer
.
Pode combinar as seguintes opções conforme necessário.
Ignore consultas adversariais e consultas que não procuram respostas
O comando seguinte mostra como evitar responder a consultas adversariais e
consultas que não procuram respostas quando chama o método answer .
REST
Para ignorar respostas a consultas hostis ou que não procuram respostas, faça o seguinte:
Execute o seguinte comando 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
}
}'
Substitua o seguinte:
PROJECT_ID
: o ID do seu projeto Google Cloud .
APP_ID
: o ID da app Vertex AI Search que quer consultar.
QUERY
: uma string de texto livre que contém a pergunta ou a consulta de pesquisa.
Comando de exemplo e resultado parcial
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"
}
Neste exemplo, a consulta é considerada não relacionada com a procura de respostas e, por isso, não é gerada nenhuma resposta.
Mostrar apenas respostas relevantes
O Vertex AI Search pode avaliar a relevância dos resultados para uma consulta. Se não forem determinados resultados suficientemente relevantes, em vez de gerar uma resposta a partir de resultados não relevantes ou minimamente relevantes, pode optar por devolver uma resposta alternativa: "We do not have a summary for your query.
"
O comando seguinte mostra como devolver a resposta alternativa no caso de resultados irrelevantes quando chama o método answer .
REST
Para devolver uma resposta alternativa se não forem encontrados resultados relevantes, faça o seguinte:
Execute o seguinte comando 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
}
}'
Substitua o seguinte:
PROJECT_ID
: o ID do seu projeto Google Cloud .
APP_ID
: o ID da app Vertex AI Search que quer consultar.
QUERY
: uma string de texto livre que contém a pergunta ou a consulta de pesquisa.
Exemplo de comando e resultado
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"
}
Neste exemplo, determinou-se que os resultados não eram suficientemente relevantes para a consulta e, por isso, foi devolvida a resposta alternativa em vez de uma resposta e resultados gerados.
Devolva pontuações de apoio técnico de verificação
O comando seguinte mostra como devolver classificações de apoio de fundamentação para respostas e reivindicações.
Para obter informações gerais sobre a fundamentação no Vertex AI, consulte o artigo Verifique a fundamentação com a RAG . O método
groundingConfigs.check
é chamado pelo método
answer.
REST
Para devolver uma pontuação de apoio para cada reivindicação (frase na resposta) e uma pontuação de apoio agregada para a resposta, faça o seguinte:
Execute o seguinte comando 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,
}
}'
Substitua o seguinte:
PROJECT_ID
: o ID do seu projeto Google Cloud .
APP_ID
: o ID da app Vertex AI Search que quer consultar.
QUERY
: uma string de texto livre que contém a pergunta ou a consulta de pesquisa.
Comando de exemplo e resultado parcial
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."
}
]
}
]
}
}
]
}
]
}
}
Neste exemplo, é devolvida uma classificação de apoio (`groundingScore`) para cada citação.
Mostrar apenas respostas bem fundamentadas
O comando seguinte mostra como devolver apenas as respostas consideradas
bem fundamentadas no corpus , as informações no armazenamento de dados.
As respostas com fundamentos fracos são filtradas.
Escolhe um limite de nível baixo ou elevado para a pontuação de apoio técnico de fundamentação. Em seguida, a resposta
só é devolvida se atingir ou exceder esse nível. Pode fazer experiências com os dois limites dos filtros e sem limite para determinar que nível de filtro é provável que ofereça os melhores resultados aos seus utilizadores.
Para obter informações gerais sobre a fundamentação no Vertex AI, consulte o artigo Verifique a fundamentação com a RAG . O método
groundingConfigs.check
é chamado pelo método
answer.
REST
Para devolver uma resposta apenas se esta atingir um limite de pontuação de apoio técnico, faça o seguinte:
Execute o seguinte comando 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 "
}
}'
Substitua o seguinte:
PROJECT_ID
: o ID do seu projeto Google Cloud .
APP_ID
: o ID da app Vertex AI Search que quer consultar.
QUERY
: uma string de texto livre que contém a pergunta ou a consulta de pesquisa.
FILTER_LEVEL
: uma enumeração para filtrar respostas com base na pontuação de apoio técnico. As opções são:
FILTERING_LEVEL_LOW
e FILTERING_LEVEL_HIGH
. Se
filteringLevel
não estiver incluído, não é aplicado nenhum filtro de pontuação de apoio técnico à resposta.
Comando de exemplo e resultado parcial
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
}
Neste exemplo, não é devolvida nenhuma resposta porque o limite elevado não foi atingido.
Especificar o modelo de resposta
O comando seguinte mostra como alterar a versão do modelo usada para gerar
respostas.
Para informações sobre os modelos suportados, consulte o artigo Versões e ciclo de vida do modelo de geração de respostas .
REST
Para gerar uma resposta com um modelo diferente do modelo predefinido, faça o seguinte:
Execute o seguinte comando 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 ",
}
}
}'
Substitua o seguinte:
PROJECT_ID
: o ID do seu projeto Google Cloud .
APP_ID
: o ID da app Vertex AI Search que quer consultar.
QUERY
: uma string de texto livre que contém a pergunta ou a consulta de pesquisa.
MODEL_VERSION
: a versão do modelo que quer usar para gerar a resposta. Para mais
informações, consulte o artigo Ciclo de vida e versões do modelo de geração de respostas .
Comando de exemplo e resultado parcial
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"
}
Neste exemplo, é usada a versão de pré-visualização do modelo em vez do modelo predefinido.
Especifique um preâmbulo personalizado
O comando seguinte mostra como definir um preâmbulo para a resposta gerada. Um preâmbulo contém instruções de linguagem natural para personalizar a resposta. Pode pedir personalizações como a duração, o nível de detalhe, o estilo do resultado (como "simples"), o idioma do resultado, o foco da resposta e o formato (como tabelas, marcadores e XML). Por exemplo, um preâmbulo pode ser "Explica como se tivesses 10 anos".
O preâmbulo pode ter um efeito significativo na qualidade da resposta gerada. Para ver informações sobre o que escrever nos preâmbulos e exemplos de bons preâmbulos, consulte o artigo Acerca dos preâmbulos personalizados .
REST
Para gerar uma resposta com um modelo diferente do modelo predefinido, faça o seguinte:
Execute o seguinte comando 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 ",
}
}
}'
Substitua o seguinte:
PROJECT_ID
: o ID do seu projeto Google Cloud .
APP_ID
: o ID da app Vertex AI Search que quer consultar.
QUERY
: uma string de texto livre que contém a pergunta ou a consulta de pesquisa.
PREAMBLE
: uma instrução em linguagem natural para personalizar a resposta. Por exemplo, experimente show the answer format in
an ordered list
ou give a very detailed answer
.
Exemplo de comando e resultado
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"
}
Neste exemplo, o preâmbulo pede uma resposta mais simples do que a resposta predefinida.
O método de resposta pode sugerir perguntas relacionadas que os utilizadores podem escolher em vez de introduzirem as suas próprias perguntas. Por exemplo, quando pergunta "Qual é a melhor altura do ano para passar férias no México?", além de responder à sua pergunta, o método de resposta pode sugerir outras perguntas que pode fazer, como "Qual é o mês mais barato para passar férias no México?" e "Quais são os meses turísticos no México?".
Para receber perguntas relacionadas, tem de especificar a respetiva inclusão em cada consulta,
e estas são devolvidas como uma matriz de strings na resposta.
Antes de começar
Certifique-se de que ativou as funcionalidades avançadas do MDG
para a app.
Procedimento
O comando seguinte mostra como pedir que sejam incluídas perguntas relacionadas com a resposta.
REST
Para obter perguntas relacionadas com uma resposta gerada:
Execute o seguinte comando 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 "},
"relatedQuestionsSpec": { "enable": true }
}'
Substitua o seguinte:
PROJECT_ID
: o ID do seu projeto Google Cloud .
APP_ID
: o ID da app Vertex AI Search que quer consultar.
QUERY
: uma string de texto livre que contém a pergunta ou a consulta de pesquisa. Por exemplo, "que tipos de dados posso importar
para a Pesquisa do Vertex AI?".
Comando de exemplo e resultado parcial
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 kinds of data can I import into Vertex AI Search?"},
"session": "projects/123456/locations/global/collections/default_collection/engines/my-app/sessions/10291252835232308789",
"searchSpec":{ "searchParams": {"filter": ""} },
"relatedQuestionsSpec": { "enable": true }
}'
{
"answer": {
"state": "SUCCEEDED",
"answerText": "You can import various kinds of data into Vertex AI Search, depending on the type of data store you create. Each data store can contain one type of data. The types of data stores include website data, structured data, structured data for media, unstructured data, and healthcare data. ... You can import FHIR R4 data into a data store in the following ways: Batch import (a one-time import).\n",
"relatedQuestions": [
"Can you provide examples of structured data formats?",
"What file types are supported for unstructured data?",
"How does website data ingestion work?",
"What are the limitations of healthcare data import?",
"Is there a size limit for importing data?"
],
...
}
}
Neste exemplo, o campo enabled
no objeto relatedQuestionsSpec
está definido como true
e a resposta contém perguntas relacionadas na matriz relatedQuestions
.
Inclua citações
O comando seguinte mostra como pedir que sejam incluídas citações na resposta.
Nota: os valores startIndex
e endIndex
para metadados de citações,
devolvidos na resposta, são medidos em bytes Unicode UTF-8 e não em carateres.
Se existirem carateres multibyte, a medição do índice é superior ao comprimento da string.
REST
Para gerar uma resposta com um modelo diferente do modelo predefinido, faça o seguinte:
Execute o seguinte comando 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
}
}'
Substitua o seguinte:
PROJECT_ID
: o ID do seu projeto Google Cloud .
APP_ID
: o ID da app Vertex AI Search que quer consultar.
QUERY
: uma string de texto livre que contém a pergunta ou a consulta de pesquisa.
INCLUDE_CITATIONS
: especifica se deve incluir metadados de citações na resposta. O valor predefinido é false
.
Comando de exemplo e resultado parcial
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"
}
Defina o código do idioma de resposta
O comando seguinte mostra como definir o código do idioma para as respostas.
REST
Para gerar uma resposta com um modelo diferente do modelo predefinido, faça o seguinte:
Execute o seguinte comando 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 "
}
}'
Substitua o seguinte:
PROJECT_ID
: o ID do seu projeto Google Cloud .
APP_ID
: o ID da app Vertex AI Search que quer consultar.
QUERY
: uma string de texto livre que contém a pergunta ou a consulta de pesquisa.
ANSWER_LANGUAGE_CODE
: um código de idioma para a resposta. Use etiquetas de idioma definidas pela norma BCP47: Etiquetas para
identificar idiomas .
Exemplo de comando e resultado
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"
}
Neste exemplo, embora os documentos de origem estejam em inglês, a resposta é fornecida em espanhol.
Personalize respostas
Se existirem informações específicas sobre o utilizador disponíveis, por exemplo, dados num perfil, pode especificar essas informações no objeto endUserMetadata
para que os resultados da consulta possam ser personalizados para o utilizador.
Por exemplo, se um utilizador com sessão iniciada estiver a pesquisar informações sobre a atualização de um telemóvel, as informações do respetivo perfil, como o modelo do telemóvel atual e o plano de rede móvel, fornecem informações que podem personalizar a resposta gerada.
Para adicionar informações pessoais sobre o utilizador que está a fazer uma consulta e gerar uma resposta que tenha em conta as informações pessoais, faça o seguinte:
Execute o seguinte comando 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 "},
"endUserSpec": {
"endUserMetadata": [
{
"chunkInfo": {
"content": "PERSONALIZED_INFO ",
"documentMetadata": { "title": "INFO_DESCRIPTION "}
}
}
]
}
}'
Substitua o seguinte:
PROJECT_ID
: o ID do seu projeto Google Cloud .
APP_ID
: o ID da app Vertex AI Search que quer consultar.
QUERY
: uma string de texto livre que contém a pergunta ou a consulta de pesquisa.
PERSONALIZATION_INFO
: uma string que contém informações específicas do utilizador que está a fazer a consulta. Por exemplo,
This customer has a Pixel 6 Pro purchased over a period of
24-months starting 2023-01-15 . This customer is on the
Business Plus International plan. No payment is due at this
time.
O limite de comprimento desta string é de 8000 carateres.
INFO_DESCRIPTION
: uma string que descreve brevemente as informações de personalização, por exemplo, Customer
profile data, including model, plan, and billing status.
O modelo usa esta descrição e as informações de personalização quando gera uma resposta personalizada à consulta.
Exemplo de comando e resultado
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": "Can I upgrade my phone now?"},
"answerGenerationSpec": { "includeCitations": true }
"endUserSpec": {
"endUserMetadata": [
{
"chunkInfo": {
"content": "This customer has a Pixel 6 Pro purchased over a period of 24-months starting 2023-01-15. This customer is on the Business Plus International plan. No payment is due at this time.",
"documentMetadata": { "title": "Customer profile data, including model, plan, and billing status."}
}
}
]
}
}'
{
"answer": {
"state": "SUCCEEDED",
"answerText": "Yes, you qualify for the yearly device upgrade because you've completed your 24-month payment plan.[1,3] Since your account is fully paid you will not need to pay any additional monthly fees… \n",
"citations": [
{
"end_index": 99
"sources": [
{
"reference_id": "0"
}
]
},
{
"start_index": "100"
"end_index": "240"
"sources": [
{
"reference_id": "0"
}
]
},
...
]
"references": [
{
"chunk_info": {
"content":
"+ "This customer has a Pixel 6 Pro purchased over a period of 24-months starting 2023-01-15. This customer is on the Business Plus International plan. No payment is due at this time.",
"relevance_score": 0.3
"documentMetadata": {
"title": "Customer profile data, including model, plan, and billing status."
}
{
"chunk_info": {
"content":
"+ "For Cymbal Mobile upgrades, you can upgrade when you've paid off at least half of your current device's cost and have had it for 8 months…",
"relevance_score": 0.8
"documentMetadata": {
"document":
"projects/123456/locations/us/collections/default_collection/dataStores/my-data-store/branches/0/documents/abcd1234567890"
"uri": "https://www.example.com/help/device-upgrade"
"title": "Upgrade eligibility"
}
}
}
...
Neste exemplo, o modelo usa o endUserMetadata
para personalizar a resposta. Para ilustração, este exemplo inclui citações para que possa ver a importância do endUserMetadata
; é sempre a primeira referência citada.
Gere gráficos para respostas
Pré-visualização
Esta funcionalidade está sujeita aos "Termos de ofertas de pré-disponibilidade geral" na secção de Termos de Utilização Gerais
dos Termos Específicos do Serviço .
As funcionalidades de pré-DG estão disponíveis "tal como estão" e podem ter apoio técnico limitado.
Para mais informações, consulte as
descrições das fases de lançamento .
O método answer pode gerar gráficos e devolvê-los como parte da resposta a uma consulta.
Pode pedir especificamente que uma resposta inclua um gráfico, por exemplo, "Representa graficamente a taxa de crescimento anual dos pagamentos de pequenas empresas ao longo dos anos com dados disponíveis". Se o sistema determinar que existem dados suficientes, é devolvido um gráfico. Normalmente, é devolvido algum texto de resposta juntamente com o gráfico.
Além disso, se existirem dados suficientes para criar um gráfico, o método de resposta pode devolver um gráfico, mesmo que a consulta não tenha pedido explicitamente um gráfico. Por exemplo, "Qual foi a melhoria nas pontuações do IDH associada a um maior acesso a água potável limpa na década entre 2010 e 2020?"
Só é gerado um gráfico por resposta. No entanto, o gráfico pode ser um gráfico composto, que contém outros gráficos mais pequenos. Um exemplo de um gráfico composto:
Limitação
As consultas têm de estar em inglês.
Cenários de falha comuns
Nem sempre recebe uma imagem com a resposta. Se não existirem dados suficientes, não é possível gerar uma figura.
Outros cenários de falha incluem falhas de execução de código e limites de tempo. Se ocorrer alguma destas situações, reformule a consulta e tente novamente.
Antes de começar
Antes de executar uma consulta que peça gráficos gerados, faça o seguinte:
Procedimento
REST
Chame o método answer da seguinte forma para devolver uma resposta que pode incluir um gráfico gerado a partir dos dados no arquivo de dados:
Execute o seguinte comando curl:
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://discoveryengine.googleapis.com/v1beta/projects/PROJECT_ID /locations/global/collections/default_collection/engines/APP_ID /servingConfigs/default_search:answer" \
-d '{
"query": { "text": "QUERY "},
"answerGenerationSpec": {
"model_spec": {
"model_version": "MODEL_VERSION "
},
"multimodalSpec": {
"imageSource": "IMAGE_SOURCE "
}
}
}'
Substitua o seguinte:
PROJECT_ID
: o ID do seu projeto Google Cloud .
APP_ID
: o ID da app Vertex AI Search que quer consultar.
QUERY
: uma string de texto livre em inglês que
contém a pergunta ou a consulta de pesquisa.
MODEL_VERSION
: versão do modelo gemini-2.0-flash-001/answer_gen/v1
ou posterior. Para mais
informações, consulte o artigo Ciclo de vida e versões do modelo de geração de respostas .
IMAGE_SOURCE
: uma enumeração para pedir que
a resposta inclua um gráfico gerado, FIGURE_GENERATION_ONLY
,
ou que a resposta possa incluir um gráfico gerado ou uma imagem existente
das bases de dados , ALL_AVAILABLE_SOURCES
.
Comando de exemplo e resultado parcial
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://discoveryengine.googleapis.com/v1beta/projects/my-project-123/locations/global/collections/default_collection/engines/my-app/servingConfigs/default_search:answer" \
-d '{
"query": { "text": "Plot composition of net cash used in investing activities"},
"answerGenerationSpec": {
"model_spec": {
"model_version": "gemini-2.0-flash-001/answer_gen/v1"
},
"multimodalSpec": {
"image_source": "FIGURE_GENERATION_ONLY"
}
}
}'
{
"answer": {
"state": "SUCCEEDED",
"answerText": "The composition of net cash used in investing activities for the nine months ended September 30, 2020 and 2019 includes several categories. These categories are purchases of property and equipment, purchases of marketable securities, maturities and sales of marketable securities, purchases of non-marketable investments, maturities and sales of non-marketable investments, acquisitions net of cash acquired and purchases of intangible assets, and other investing activities. For the nine months ended September 30, 2020, the net cash used in investing activities totaled $(25,492). For the nine months ended September 30, 2019, the net cash used in investing activities totaled $(24,788).\n\nHere's a breakdown of the specific cash flows for investing activities (in millions):\n\n* **Purchases of property and equipment:** $(16,802) in 2020 and $(17,496) in 2019\n* **Purchases of marketable securities:** $(104,932) in 2020 and $(80,968) in 2019\n* **Maturities and sales of marketable securities:** $97,751 in 2020 and $74,783 in 2019\n* **Purchases of non-marketable investments:** $(1,864) in 2020 and $(1,499) in 2019\n* **Maturities and sales of non-marketable investments:** $598 in 2020 and $297 in 2019\n* **Acquisitions, net of cash acquired, and purchases of intangible assets:** $(368) in 2020 and $(373) in 2019\n* **Other investing activities:** $125 in 2020 and $468 in 2019",
"steps": [
{
"state": "SUCCEEDED",
"description": "Rephrase the query and search.",
"actions": [
{
"searchAction": {
"query": "Plot composition of net cash used in investing activities"
},
"observation": {
"searchResults": [
{
"document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/b3133a895e0404984959736488992b53",
"uri": "gs://yipeiw_multimodal_0827/rzilleruelo_multimodal_datasets/20240806/Document Understanding Evaluation Dataset/boa-tabular/Testing_20201030-alphabet-cash flow statement.pdf",
"title": "Testing_20201030-alphabet-cash flow statement",
"snippetInfo": [
{
"snippet": "... \u003cb\u003eNet cash provided by operating activities\u003c/b\u003e 42,447 | 40,093 | | \u003cb\u003eInvesting activities\u003c/b\u003e | | | (16,802) Purchases of property and equipment | (17,496) ...",
"snippetStatus": "SUCCESS"
}
]
}
]
}
}
]
}
],
"blobAttachments": [
{
"data": {
"mimeType": "image/png",
"data": "iVBORw0KGgoAAAANSUhEUgAACvAAZd8AEZFKHDp0CE5OTgCAZcuWYfr06QonIqIMXIGXiIhUITY2Vq4tLCxyNdbMzEyuk5OTtZaJiEgfZd5aMj4+Xq4zr1rztm3SMs/fXIGXiOjDGRgYyLWpqalcJyUlyfW/V7rJULVqVbl++PChDtIREemXr7766oPHPnr0CK1bt9ZeGCIiPXXlypWPGr9lyxYtJSEi0k9ly5bFzZs30bNnT0iSBEmS8PLlS1y6dAlHjhzBpUuX8PLlS/lcjx49cOPGDZQtW1bp6EREquHv7w9JkgAALVq0UDgNEWXGBl4iIlIFc3NzuY6MjMzV2ICAALkuVqyY1jIREemjzDdVb926JdeWlpZynXlr98z8/f3lunDhwtoPR0SkJzLPuYGBgXKd+bOun5/fG8dmXjE9PT1dB+mIiPTL8uXLP2hVm19++QV169aFt7e3DlIREemXDh06wMfHJ9fjwsLC0K1bN4wePVoHqYiI9EuRIkXwxx9/4MSJE3BycoKFhYXcsCtJEiwsLNC/f38cP34chw4dyrJQBBERfbxChQrJde...PrTn86//Mu/5Jhjjql1NACAAeP/AX0CwI314+qiAAAAAElFTkSuQmCC"
},
"attributionType": "GENERATED"
}
]
},
"answerQueryToken": "NMwKDAjEjOe-BhD-meX6ARIkNjdkNjBhM2QtMDAwMC0yYzU4LTgxYjctMDg5ZTA4MmNhZDgw"
Neste exemplo, é incluído um gráfico gerado na resposta porque a consulta pediu um gráfico e existiam dados suficientes para o gerar.
As imagens dos gráficos são devolvidas no resultado com o attributionType
de GENERATED
.blobAttachments
Obtenha imagens existentes do repositório de dados
Pré-visualização
Esta funcionalidade está sujeita aos "Termos de ofertas de pré-disponibilidade geral" na secção de Termos de Utilização Gerais
dos Termos Específicos do Serviço .
As funcionalidades de pré-DG estão disponíveis "tal como estão" e podem ter apoio técnico limitado.
Para mais informações, consulte as
descrições das fases de lançamento .
Pode optar por que as imagens do repositório de dados sejam devolvidas com a resposta e
em referências de citação . O repositório de dados tem de ser um repositório de dados não estruturados com o analisador de esquemas ativado.
Para receber gráficos nas respostas devolvidas, tem de ativar as funcionalidades avançadas do MDG .
Quando imageSource
é CORPUS_IMAGE_ONLY
ou ALL_AVAILABLE_SOURCES
, o método
answer pode obter imagens do repositório de dados conforme
adequado. No entanto, a ativação desta opção não significa que as imagens sejam sempre devolvidas.
Recebe uma imagem (no máximo) por resposta. As citações podem conter várias imagens.
Limitações
A app que está a usar tem de estar ligada a um repositório de dados não estruturados.
Não é possível devolver imagens de Websites nem de armazenamentos de dados estruturados.
As consultas têm de estar em inglês.
A anotação de imagens através da análise sintática de esquemas tem de ser aplicada ao repositório de dados.
Para obter informações sobre o analisador de esquemas, consulte o artigo Analise e divida documentos em partes .
Procedimento
REST
Chame o método answer da seguinte forma para devolver uma resposta que pode incluir uma imagem do arquivo de dados na resposta:
Execute o seguinte comando curl:
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://discoveryengine.googleapis.com/v1beta/projects/PROJECT_ID /locations/global/collections/default_collection/engines/APP_ID /servingConfigs/default_search:answer" \
-d '{
"query": { "text": "QUERY "},
"answerGenerationSpec": {
"model_spec": {
"model_version": "MODEL_VERSION "
},
includeCitations: true,
"multimodalSpec": {
"imageSource": "IMAGE_SOURCE "
}
}
}'
Substitua o seguinte:
PROJECT_ID
: o ID do seu projeto Google Cloud .
APP_ID
: o ID da app Vertex AI Search que quer consultar.
QUERY
: uma string de texto livre em inglês que
contém a pergunta ou a consulta de pesquisa.
MODEL_VERSION
: versão do modelo gemini-2.0-flash-001/answer_gen/v1
ou posterior. Para mais
informações, consulte o artigo Ciclo de vida e versões do modelo de geração de respostas .
IMAGE_SOURCE
: uma enumeração para pedir que a resposta inclua uma imagem do repositório de dados, CORPUS_IMAGE_ONLY
, ou que a resposta possa incluir uma imagem do repositório de dados ou um gráfico gerado , ALL_AVAILABLE_SOURCES
.
Comando de exemplo e resultado parcial
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://discoveryengine.googleapis.com/v1beta/projects/my-project-123//locations/global/collections/default_collection/engines/my-app/servingConfigs/default_search:answer" -d '{
"query": { "text": "Display the ranking of generations from highest to lowest based on their spending on holiday items using cards."},
"answerGenerationSpec": {"includeCitations": true,
"model_spec": {
"model_version": "gemini-2.0-flash-001/answer_gen/v1"
},
"multimodalSpec": {
"imageSource": "CORPUS_IMAGE_ONLY"
}
},
"searchSpec": {
"searchParams": {
"maxReturnResults": 5
}
}
}'
{
"answer": {
"state": "SUCCEEDED",
"answerText": "Holiday spending over November-December was weakest among Gen Xers, followed by Millennials, while Baby Boomer spending was relatively more solid. In November, Baby Boomers saw solid spending growth. Both Millennials and Gen X consumers had lower holiday spending than in the same 30-day period last year. Baby Boomers' holiday spending started to pick up from the start of November and continued to rise throughout the month. Meanwhile, Millennials started to ramp up their holiday spending much later in the month. Gen X consumers consistently outspent other generations from late October through the end of November.\n",
"citations": [
{
"endIndex": "146",
"sources": [
{
"referenceId": "3"
}
]
},
{
"startIndex": "147",
"endIndex": "199",
"sources": [
{
"referenceId": "2"
}
]
},
{
"startIndex": "200",
"endIndex": "305",
"sources": [
{
"referenceId": "2"
}
]
},
{
"startIndex": "306",
"endIndex": "426",
"sources": [
{
"referenceId": "2"
}
]
},
{
"startIndex": "427",
"endIndex": "516",
"sources": [
{
"referenceId": "2"
}
]
},
{
"startIndex": "517",
"endIndex": "619",
"sources": [
{
"referenceId": "2"
}
]
}
],
"references": [
{
"chunkInfo": {
"content": "Bank of America aggregated credit/debit card spending per household includes spending from active US households only. Only.., Consumer and Small Business Mel Roasa Vice President, Digital and MarketingBANK OF AMERICA INSTITUTE09 November 20237",
"relevanceScore": 0.5,
"documentMetadata": {
"document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/f8d7887862167c5daf6c7a30e1d464e0",
"uri": "gs://yipeiw_multimodal_0827/rzilleruelo_multimodal_datasets/20240806/Document Understanding Evaluation Dataset/Bank of America/1WkoquhDpqHphSnqIVKX45iers7kvmGjZ.pdf",
"title": "1WkoquhDpqHphSnqIVKX45iers7kvmGjZ",
"pageIdentifier": "6"
}
}
},
{
"chunkInfo": {
"content": "Bank of America aggregated credit/debit card spending per household includes spending from active US households only. Only... Digital and Marketing Riley Fillius Vice President, Digital and MarketingBANK OF AMERICA INSTITUTE08 February 2024 7",
"relevanceScore": 0.4,
"documentMetadata": {
"document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/c4308d8610bcae3b3d2bb916090ef28b",
"uri": "gs://yipeiw_multimodal_0827/rzilleruelo_multimodal_datasets/20240806/Document Understanding Evaluation Dataset/Bank of America/1B3MJqELqk_S26aWb-KnLdSWwmpuB32os.pdf",
"title": "1B3MJqELqk_S26aWb-KnLdSWwmpuB32os",
"pageIdentifier": "6"
}
}
},
...
{
"chunkInfo": {
"content": "Bank of America aggregated credit/debit card spending per household includes spending from active US households only. Only consumer card holders making a minimum of five transactions a month are included in the dataset. Spending from corporate cards are excluded. Data regarding merchants who receive payments are identified and classified by the Merchant Categorization Code (MCC) defined by financial services companies. The data are mapped using proprietary methods from the MCCs to the North American Industry Classification System (NAICS), which is also used by the Census Bureau, in order to classify spending data by subsector. Spending data may also be classified by other proprietary methods not using MCCs. Generations, if discussed, are defined as follows: 1. Gen Z, born after 1995 2. Younger Millennials: born between 1989-1995 3. Older Millennials: born between 1978-19886 11 March 2024BANK OF AMERICA INSTITUTE4. Gen Xers: born between 1965-1977 5. Baby Boomer: 1946-1964 6. Traditionalists: pre-1946 Any reference to card spending per household on gasoline includes all purchases at gasoline stations and might include purchases of non-gas items. Additional information about the methodology used to aggregate the data is available upon request.\n\n## Contributors\n\nDavid Michael Tinsley Senior Economist, Bank of America Institute Joe Wadford Economist, Bank of America Institute Taylor Bowley Economist, Bank of America Institute Liz Everett Krisberg Head of Bank of America Institute\n\n## Sources\n\nLi Wei Director, Global Risk Analytics Kimberly Warren Director, Global Risk Analytics Ana Maxim Senior Vice President, Consumer and Small Business Mel Roasa Vice President, Digital and MarketingBANK OF AMERICA INSTITUTE11 March 2024 7",
"relevanceScore": 0.3,
"documentMetadata": {
"document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/719bfb7c1c0cde3888debd43542aabfe",
"uri": "gs://yipeiw_multimodal_0827/rzilleruelo_multimodal_datasets/20240806/Document Understanding Evaluation Dataset/Bank of America/1odEo6QRllsURLZRDwHNruCXK9bsWmhtR.pdf",
"title": "1odEo6QRllsURLZRDwHNruCXK9bsWmhtR",
"pageIdentifier": "6"
}
}
}
],
"steps": [
{
"state": "SUCCEEDED",
"description": "Rephrase the query and search.",
"actions": [
{
"searchAction": {
"query": "Rank generations from highest to lowest based on their spending on holiday items using cards."
},
"observation": {
"searchResults": [
{
"document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/935c4e1f18ccff2b5fa51d6d00e40dc4",
"uri": "gs://yipeiw_multimodal_0827/rzilleruelo_multimodal_datasets/20240806/Document Understanding Evaluation Dataset/Bank of America/1baMNJuizoK7u3P2-gYRwpVz_46-uOhn4.pdf",
"title": "1baMNJuizoK7u3P2-gYRwpVz_46-uOhn4",
"snippetInfo": [
{
"snippet": "## Exhibit 6: Credit and debit \u003cb\u003ecard spending\u003c/b\u003e per household on \u003cb\u003eholiday items\u003c/b\u003e by \u003cb\u003egeneration\u003c/b\u003e (index, Aug-Sep average=100 for each year, 7- day moving average) ...",
"snippetStatus": "SUCCESS"
}
]
},
{
"document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/0b4c8cfb6f5ed9ef0df70ffcd79fe2c0",
"uri": "gs://yipeiw_multimodal_0827/rzilleruelo_multimodal_datasets/20240806/Document Understanding Evaluation Dataset/Bank of America/1pVkzcMDNAy-p7AlrE0LRlhpbbDzCNndJ.pdf",
"title": "1pVkzcMDNAy-p7AlrE0LRlhpbbDzCNndJ",
"snippetInfo": [
{
"snippet": "Consumer \u003cb\u003espending\u003c/b\u003e finished solidly in 2023, \u003cb\u003ewith\u003c/b\u003e total \u003cb\u003ecard spending\u003c/b\u003e per household increasing by 0.2% year-over-year (YoY) in December, according to Bank of ...",
"snippetStatus": "SUCCESS"
}
]
},
{
"document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/f8d7887862167c5daf6c7a30e1d464e0",
"uri": "gs://yipeiw_multimodal_0827/rzilleruelo_multimodal_datasets/20240806/Document Understanding Evaluation Dataset/Bank of America/1WkoquhDpqHphSnqIVKX45iers7kvmGjZ.pdf",
"title": "1WkoquhDpqHphSnqIVKX45iers7kvmGjZ",
"snippetInfo": [
{
"snippet": "This could be due to an increasing customer \u003cb\u003ebase\u003c/b\u003e or inactive customers \u003cb\u003eusing their cards\u003c/b\u003e more frequently. Per household \u003cb\u003ecard spending\u003c/b\u003e growth only looks at ...",
"snippetStatus": "SUCCESS"
}
]
},
{
"document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/719bfb7c1c0cde3888debd43542aabfe",
"uri": "gs://yipeiw_multimodal_0827/rzilleruelo_multimodal_datasets/20240806/Document Understanding Evaluation Dataset/Bank of America/1odEo6QRllsURLZRDwHNruCXK9bsWmhtR.pdf",
"title": "1odEo6QRllsURLZRDwHNruCXK9bsWmhtR",
"snippetInfo": [
{
"snippet": "This could be due to an increasing customer \u003cb\u003ebase\u003c/b\u003e or inactive customers \u003cb\u003eusing their cards\u003c/b\u003e more frequently. Per household \u003cb\u003ecard spending\u003c/b\u003e growth only looks at ...",
"snippetStatus": "SUCCESS"
}
]
},
{
"document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/c4308d8610bcae3b3d2bb916090ef28b",
"uri": "gs://yipeiw_multimodal_0827/rzilleruelo_multimodal_datasets/20240806/Document Understanding Evaluation Dataset/Bank of America/1B3MJqELqk_S26aWb-KnLdSWwmpuB32os.pdf",
"title": "1B3MJqELqk_S26aWb-KnLdSWwmpuB32os",
"snippetInfo": [
{
"snippet": "This could be due to an increasing customer \u003cb\u003ebase\u003c/b\u003e or inactive customers \u003cb\u003eusing their cards\u003c/b\u003e more frequently. Per household \u003cb\u003ecard spending\u003c/b\u003e growth only looks at ...",
"snippetStatus": "SUCCESS"
}
]
}
]
}
}
]
}
],
"blobAttachments": [
{
"data": {
"mimeType": "image/png",
"data": "iVBORw0KGgoAAAANSUhEUgAABcwAAAIjCAIAAACxms+ZAAAgAElEQVR42uzdd1xTV/...Vv/F0NDQ4NOp3+waz94PJ5Op7+/ibro6fRiWPX/AaZ6/dAGW00gAAAAAElFTkSuQmCC"
},
"attributionType": "CORPUS"
}
]
},
"answerQueryToken": "M8gKCwiPuOe-BhDyhpgIEiQ2N2Q2MWI0Mi0wMDAwLTJjNTgtODFiNy0wODllMDgyY2FkODA"
}
As imagens são devolvidas na parte blobAttachments
da saída. A imagem devolvida com a resposta está sempre no primeiro
blobAttachments
. Se estiver presente, o elemento blobAttachments
conteria imagens devolvidas em referências de citações. A imagem devolvida com a resposta também pode ser (e, na verdade, é frequentemente) devolvida com uma citação. O
blobAttachmentIndexes
é o índice que associa o
blobAttachment
ao texto da resposta ou da citação.
O valor attributionType
para as imagens devolvidas é sempre CORPUS
para indicar que a imagem é da loja de dados.
Comandos para perguntas de seguimento
Os seguimentos são consultas de várias interações. Após a primeira consulta numa sessão de seguimento, as "interações" subsequentes têm em conta as interações anteriores. Com os seguimentos, o método de resposta também pode sugerir perguntas relacionadas, que os utilizadores podem escolher em vez de introduzir as suas próprias perguntas de seguimento. Para receber sugestões de perguntas relacionadas, tem de ativar as funcionalidades avançadas do MDG .
Todas as funcionalidades de resposta e seguimentos descritas nas secções anteriores, como citações, filtros, Pesquisa Segura, ignorar determinados tipos de consultas e usar um preâmbulo para personalizar as respostas, podem ser aplicadas juntamente com os seguimentos.
Exemplo de uma sessão de seguimento
Segue-se um exemplo de uma sessão com seguimentos. Suponhamos que quer saber mais sobre passar férias no México:
Turno 1:
Eu: qual é a melhor altura do ano para passar férias no México?
Responder com seguimentos: a melhor altura para passar férias no México é durante a estação seca, que decorre de novembro a abril.
Turn 2:
Eu: qual é a taxa de câmbio?
Responder com seguimentos: 1 USD é igual a aproximadamente 17,65 pesos mexicanos.
Turn 3:
Sem seguimentos, a pergunta "Qual é a taxa de câmbio?" não teria resposta, porque a pesquisa normal não saberia que queria a taxa de câmbio mexicana. Da mesma forma, sem seguimentos, não haveria o contexto necessário para lhe dar temperaturas especificamente para o México.
Acerca das sessões
Para compreender como funcionam os seguimentos na Vertex AI Search, tem de saber mais sobre as sessões.
Uma sessão é composta por consultas de texto fornecidas por um utilizador e respostas fornecidas pelo Vertex AI Search.
Por vezes, estes pares de consultas e respostas são denominados interações . No exemplo anterior, a segunda interação é composta por "Qual é a taxa de câmbio?" e "1 USD é igual a aproximadamente 17,65 pesos mexicanos."
As sessões são armazenadas com a app.
Na app, uma sessão é representada pelo recurso
session .
Além de conter as mensagens de consulta e resposta, o recurso de sessão tem:
Um nome exclusivo (o ID da sessão).
Um estado (em curso ou concluído).
Um pseudo ID de utilizador, que é um ID de visitante que acompanha o utilizador. Pode ser
atribuído de forma programática. Quando mapeado para o ID pseudonimizado do utilizador nos eventos do utilizador da sua app, o modelo pode ajudar a publicar resultados personalizados para o utilizador.
Uma hora de início e uma hora de fim.
Uma interação, que é um par de resposta a uma consulta.
Antes de começar
Antes de executar uma consulta que peça perguntas de seguimento, certifique-se de que
ativou as funcionalidades avançadas de MDIs para a app.
Armazenar informações da sessão e receber respostas
Pode usar a linha de comandos para gerar respostas e respostas de pesquisa e armazená-las, juntamente com cada consulta numa sessão.
REST
Para usar a linha de comandos para criar uma sessão e gerar respostas a partir da entrada do utilizador, siga estes passos:
Especifique a app onde quer armazenar a sessão:
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 "
}'
Substitua o seguinte:
PROJECT_ID
: o ID do seu projeto Google Cloud .
APP_ID
: o ID da app Vertex AI Search.
USER_PSEUDO_ID
: uma string codificada em UTF-8 que funciona como um identificador pseudonimizado exclusivo que acompanha os utilizadores. Pode ter um comprimento máximo de 128 carateres.
A Google recomenda vivamente a utilização deste campo porque melhora o desempenho do modelo e a qualidade da personalização. Pode usar um cookie HTTP para este campo, que identifica de forma exclusiva um visitante num único dispositivo. Seguem-se algumas considerações importantes:
Este identificador não se altera quando o visitante inicia ou termina sessão num Website.
Este campo não pode ser definido com o mesmo identificador para vários utilizadores.
Caso contrário, o mesmo ID do utilizador pode combinar os históricos de eventos de diferentes utilizadores e
degradar a qualidade do modelo.
Este campo não pode incluir informações de identificação pessoal (PII).
Para um determinado pedido de pesquisa ou navegação, este campo tem de ser mapeado para o campo userPseudoId
correspondente nos eventos do utilizador.
Para mais informações, consulte
userPseudoId
.
Exemplo de comando e resultado
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"
}
Anote o ID da sessão, os números no final do campo name:
na resposta JSON. No resultado de exemplo, o ID é 5386462384953257772
.
Precisa deste ID no passo seguinte.
Gerar uma resposta e adicioná-la a uma sessão na sua app:
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 "} }
}'
Substitua o seguinte:
PROJECT_ID
: o ID do seu projeto Google Cloud .
APP_ID
: o ID da app Vertex AI Search.
QUERY
: uma string de texto livre que contém a pergunta ou a consulta de pesquisa.
SESSION_ID
: o ID da sessão que criou no passo 1. Estes são os dígitos no final do campo name:
, indicados no passo 2. Para uma sessão, use o mesmo ID de sessão em cada interação.
FILTER
: um campo de texto para filtrar a pesquisa
através de uma expressão de filtro. O valor predefinido é uma string vazia. A forma como cria o filtro varia consoante tenha dados não estruturados com metadados, dados estruturados ou dados de Websites. Para mais informações,
consulte Filtrar
a pesquisa personalizada para dados estruturados ou não estruturados e Filtrar
a pesquisa de Websites .
Exemplo de comando e resultado
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 \u 003cb\u 003eSpanner\u 003c/b\u 003e 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"
}
Repita o passo 3 para cada nova consulta na sessão.
Obtenha uma sessão a partir do arquivo de dados
O comando seguinte mostra como chamar o método get
e obter uma sessão da loja de dados.
REST
Para obter uma sessão de um arquivo de dados, faça o seguinte:
Execute o seguinte comando 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 "
Substitua o seguinte:
PROJECT_ID
: o ID do seu projeto Google Cloud .
APP_ID
: o ID da app Vertex AI Search.
SESSION_ID
: o ID da sessão que quer obter.
Elimine uma sessão da app
O comando seguinte mostra como chamar o método delete
e
eliminar uma sessão da loja de dados.
Por predefinição, as sessões com mais de 60 dias são eliminadas automaticamente.
No entanto, se quiser eliminar uma sessão específica, por exemplo, se contiver conteúdo sensível, use esta chamada API para a eliminar.
REST
Para eliminar uma sessão de uma app, faça o seguinte:
Execute o seguinte comando 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 "
Substitua o seguinte:
PROJECT_ID
: o ID do seu projeto Google Cloud .
APP_ID
: o ID da app Vertex AI Search.
SESSION_ID
: o ID da sessão que quer eliminar.
Exemplo de comando e resultado
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"
{}
Atualize uma sessão
Existem vários motivos pelos quais pode querer atualizar uma sessão. Por exemplo, para fazer uma das seguintes ações:
Marque uma sessão como concluída
Unir as mensagens de uma sessão noutra
Altere o ID pseudonimizado de um utilizador
O comando seguinte mostra como chamar o método patch
e atualizar uma sessão no repositório de dados.
REST
Para atualizar uma sessão a partir de uma app, faça o seguinte:
Execute o seguinte comando 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 "
}'
Substitua o seguinte:
PROJECT_ID
: o ID do seu projeto Google Cloud .
APP_ID
: o ID da app Vertex AI Search.
SESSION_ID
: o ID da sessão que quer atualizar.
NEW_STATE
: o novo valor do estado, por exemplo, IN_PROGRESS
.
Exemplo de comando e resultado
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"
}
Este exemplo altera o estado da sessão para aberto (em curso). Siga um padrão semelhante para atualizar o userPseudoId
.
Apresentar todas as sessões
O comando seguinte mostra como chamar o método list
e
listar as sessões no arquivo de dados.
REST
Para listar as sessões de uma app, faça o seguinte:
Execute o seguinte comando 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"
Substitua o seguinte:
PROJECT_ID
: o ID do seu projeto Google Cloud .
APP_ID
: o ID da app Vertex AI Search.
Exemplo de comando e resultado
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"
}
A resposta contém uma lista de sessões e o nextPageToken. Se não for devolvido nenhum
nextPageToken, não existem mais sessões para listar. O tamanho da página
predefinido é 50.
Liste as sessões de um utilizador
O comando seguinte mostra como chamar o método list
para
listar as sessões associadas a um utilizador ou um visitante.
REST
Para listar as sessões associadas a um utilizador ou um visitante, faça o seguinte:
Execute o seguinte comando 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 "
Substitua o seguinte:
PROJECT_ID
: o ID do seu projeto Google Cloud .
APP_ID
: o ID da app Vertex AI Search.
USER_PSEUDO_ID
: o ID pseudonimizado do utilizador cujas sessões quer listar.
Exemplo de comando e resultado
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"
}
]
}
Neste exemplo, existe uma sessão associada ao test_user. As
consultas e as respostas na sessão são apresentadas.
Liste as sessões de um utilizador e um estado
O comando seguinte mostra como chamar o método list
para
listar sessões num determinado estado para um utilizador específico.
REST
Para listar as sessões de um utilizador que estão abertas ou fechadas e associadas a um determinado utilizador ou visitante, faça o seguinte:
Execute o seguinte comando 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 "
Substitua o seguinte:
PROJECT_ID
: o ID do seu projeto Google Cloud .
APP_ID
: o ID da app Vertex AI Search.
USER_PSEUDO_ID
: o ID pseudonimizado do utilizador cujas sessões quer listar.
STATE
: o estado da sessão:
STATE_UNSPECIFIED
(fechada ou desconhecida) ou
IN_PROGRESS
(aberta).
Exemplo de comando e resultado
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"
}
]
}