En esta página, se presenta el método de respuesta de transmisión.
El método de respuesta de transmisión tiene muchas de las mismas funciones que el método de respuesta, además de una función adicional: transmisión. Cuando transmites una respuesta, la respuesta generada se divide en varias partes que se envían en secuencia.
La transmisión continua de respuestas es especialmente útil si las respuestas generadas son largas, de modo que enviar toda la respuesta a la vez causa una demora. La transmisión de respuestas reduce la apariencia de latencia.
Limitaciones
El método de respuesta continua tiene las mismas funciones que el método de respuesta, con las siguientes excepciones:
La respuesta continua solo se admite en inglés.
La cantidad de pasos de reformulación es uno. No puedes inhabilitar la reformulación ni cambiar la cantidad máxima de pasos.
No puedes obtener puntuaciones de fundamentación para las respuestas de transmisión ni puedes optar por mostrar solo respuestas bien fundamentadas.
Solo los modelos de Gemini se pueden usar con el método de respuesta de transmisión. Para obtener una lista de los modelos, consulta Modelos disponibles.
Cómo transmitir una respuesta
En el siguiente comando, se muestra cómo llamar al método de respuesta continua y mostrar una respuesta generada en forma de una serie de respuestas JSON. Por lo general, cada respuesta contiene una oración de la respuesta.
Este comando básico solo muestra la entrada requerida. Las opciones se dejan con sus valores predeterminados.
Para ver ejemplos de otras opciones, consulta Obtén respuestas y preguntas adicionales. Algunas opciones de respuesta no están disponibles para la transmisión de respuestas. Consulta las limitaciones en esta página.
REST
Para buscar y obtener resultados con una respuesta generada transmitida, haz lo siguiente:
Ejecuta el siguiente comando de 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:streamAnswer" \ -d '{ "query": { "text": "QUERY"} }'
Reemplaza lo siguiente:
PROJECT_ID
: El ID del proyecto de Google Cloud.APP_ID
: El ID de la app de Vertex AI Search que quieres consultar.QUERY
: Es una cadena de texto libre que contiene la pregunta o la búsqueda. Por ejemplo, "¿Qué base de datos es más rápida, BigQuery o Spanner?".
Ejemplo de comando y 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:streamAnswer" \ -d '{ "query":{"text":"Which database is faster, bigquery or spanner?"} }'
[{ "answer": { "state": "STREAMING", "steps": [ { "description": "Rephrase the query and search.", "actions": [ { "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/1a9f55e00c42c06ca97bf5a5868dbcdc", "uri": "https://cloud.google.com/generative-ai-app-builder/docs/answer", "title": "Get answers and follow-ups | Vertex AI Agent Builder | Google Cloud", "snippetInfo": [ { "snippet": "QUERY : a free-text string that contains the question or search query. For example, "Compare the BigQuery and \u003cb\u003eSpanner\u003c/b\u003e databases?". Example command and result.", "snippetStatus": "SUCCESS" } ] }, ... { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/b95bb201a0adb24f769627f56cf34405", "uri": "https://abc.xyz/assets/investor/static/pdf/2017_Q1_Earnings_Transcript.pdf", "title": "\u200b \u200b", "snippetInfo": [ { "snippet": "well as Hardware related costs, reflecting the continued strong \u003cb\u003eperformance\u003c/b\u003e of our new Made by ... We introduced dozens of new products, including \u003cb\u003eSpanner\u003c/b\u003e, a ...", "snippetStatus": "SUCCESS" } ] } ] } }, { "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/18bcc727bfd6a3d1be0aa4bd49fe2c50", "uri": "https://cloud.google.com/generative-ai-app-builder/docs/evaluate-search-quality", "title": "Evaluate search quality | Vertex AI Agent Builder | Google Cloud", "snippetInfo": [ { "snippet": "You can evaluate the \u003cb\u003eperformance\u003c/b\u003e of generic search apps that contain structured, unstructured, and website data. ... Import from \u003cb\u003eBigQuery\u003c/b\u003e: import \u003cb\u003eBigQuery\u003c/b\u003e data ...", "snippetStatus": "SUCCESS" } ] }, ... { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/1a9f55e00c42c06ca97bf5a5868dbcdc", "uri": "https://cloud.google.com/generative-ai-app-builder/docs/answer", "title": "Get answers and follow-ups | Vertex AI Agent Builder | Google Cloud", "snippetInfo": [ { "snippet": "QUERY : a free-text string that contains the question or search query. For example, "Compare the \u003cb\u003eBigQuery\u003c/b\u003e and Spanner databases?". Example command and result.", "snippetStatus": "SUCCESS" } ] } ] } } ] } ] } } , { "answer": { "state": "STREAMING", "references": [ { "chunkInfo": { "content": "Example command and partial result 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/dataStores/my-data-store/servingConfigs/default_search:answer\" -d '{ \"query\": { \"text\": \"Compare bigquery with spanner database?\"} \"queryUnderstandingSpec\": { \"queryRephraserSpec\": { \"disable\": true } } }' { \"answer\": { \"state\": \"SUCCEEDED\", \"answerText\": \"You can compare BigQuery and Spanner databases using the following criteria:\\n\\n* **Pricing:** BigQuery is priced per GB of data processed, while Spanner is priced per hour of compute time.\\n* **Performance:** BigQuery is designed for fast analytics, while Spanner is designed for high availability and scalability.\\n* **Features:** BigQuery supports a wide range of features, including SQL, machine learning, and streaming. ", "documentMetadata": { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/1a9f55e00c42c06ca97bf5a5868dbcdc", "uri": "https://cloud.google.com/generative-ai-app-builder/docs/answer", "title": "Get answers and follow-ups | Vertex AI Agent Builder | Google Cloud" } } }, ... { "chunkInfo": { "content": "Here is an example of a summary, with citations and citation metadata, returned at the end of a search response: See more code actions. Dismiss View Light code theme Dark code theme \"summary\": { \"summaryText\": \"BigQuery is Google Cloud's fully managed and completely serverless enterprise data warehouse [1]. BigQuery supports all data types, works across clouds, and has built-in machine learning and business intelligence, all within a unified platform [2, 3].\", \"summaryWithMetadata\": { \"summary\": \"BigQuery is Google Cloud's fully managed and completely serverless enterprise data warehouse. ", "documentMetadata": { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/f7ba2e8666f5514b5bc14f5e300d7678", "uri": "https://cloud.google.com/generative-ai-app-builder/docs/get-search-summaries", "title": "Get search summaries | Vertex AI Agent Builder | Google Cloud" } } } ] } } , { "answer": { "state": "STREAMING", "answerText": "Span" } } , { "answer": { "state": "STREAMING", "answerText": "ner is Google's large-scale database that scales 20 times better than" } } , ... { "answer": { "state": "STREAMING", "answerText": " Web Services, and on-premises data sources. " } } , { "answer": { "state": "STREAMING", "answerText": "Spanner is a distributed, strongly consistent, SQL database designed to scale to 10 million servers. \n" } } , { "answer": { "state": "SUCCEEDED", "answerText": "Spanner is Google's large-scale database that scales 20 times better than any competitor. Spanner is designed for high availability and scalability, while BigQuery is designed for fast analytics. BigQuery is a serverless, highly scalable, and cost-effective cloud data warehouse that enables businesses to analyze all their data very quickly. BigQuery is a very powerful tool that can be used to analyze data from many different sources, including Google Cloud Platform, Amazon Web Services, and on-premises data sources. Spanner is a distributed, strongly consistent, SQL database designed to scale to 10 million servers. \n", "references": [ { "chunkInfo": { "content": "Example command and partial result 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/dataStores/my-data-store/servingConfigs/default_search:answer\" -d '{ \"query\": { \"text\": \"Compare bigquery with spanner database?\"} \"queryUnderstandingSpec\": { \"queryRephraserSpec\": { \"disable\": true } } }' { \"answer\": { \"state\": \"SUCCEEDED\", \"answerText\": \"You can compare BigQuery and Spanner databases using the following criteria:\\n\\n* **Pricing:** BigQuery is priced per GB of data processed, while Spanner is priced per hour of compute time.\\n* **Performance:** BigQuery is designed for fast analytics, while Spanner is designed for high availability and scalability.\\n* **Features:** BigQuery supports a wide range of features, including SQL, machine learning, and streaming. ", "documentMetadata": { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/1a9f55e00c42c06ca97bf5a5868dbcdc", "uri": "https://cloud.google.com/generative-ai-app-builder/docs/answer", "title": "Get answers and follow-ups | Vertex AI Agent Builder | Google Cloud" } } }, { "chunkInfo": { "content": "Second, we also give them the ability to build applications using a set of technology that can run on any environment that they have. When we say on any environment - at their premise, on our cloud or on any other cloud. So, in other words, they can learn once, write once, deploy anywhere; and we make money no matter where they deploy. An example of that is a recent product we introduced called AlloyDB. It's the fastest-performing relational database in the market. We run it in all four environments: Our cloud, on-premise and on other clouds. And it's the only relational database that can run in any of those configurations. You see that in our adoption, both at the top end of the market where a system - for example, like Spanner, which is our large-scale database - scales 20 times better than the largest scalable system of any competitor. So for high-end, we work extremely well. And, also, because we made it so easy to use, startups and small businesses are growing very quickly in their adoption of our platform. When we introduced our AI systems, we introduced a platform called Vertex AI. ", "documentMetadata": { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/8ad08d0844d601733e135381512e2a16", "uri": "http://abc.xyz/thomas-kurian-ceo-google-cloud-at-the-goldman-sachs-2023-communacopia-technology-conference-on-september-7th-2023", "title": "Thomas Kurian, CEO, Google Cloud at the Goldman Sachs 2023 Communacopia + Technology Conference on September 7th, 2023 - Alphabet Investor Relations" } } }, ... { "chunkInfo": { "content": "BigQuery is also integrated with other Google Cloud services, such as Google Kubernetes Engine, Cloud Data Fusion, and Cloud Dataproc, making it easy to build and deploy data pipelines. Here are some of the benefits of using BigQuery: * **Fast and scalable:** BigQuery can process petabytes of data very quickly, and it can scale to handle even the most demanding workloads. * **Cost-effective:** BigQuery is a very cost-effective way to store and analyze data. You only pay for the data that you use, and there are no upfront costs or commitments. * **Secure:** BigQuery is a secure platform that meets the needs of even the most security-conscious organizations. * **Easy to use:** BigQuery is easy to use, even for non-technical users. It has a simple and intuitive user interface, and it supports a variety of data sources. * **Integrated with other Google Cloud services:** BigQuery is integrated with other Google Cloud services, making it easy to build and deploy data pipelines. If you are looking for a fast, scalable, and cost-effective way to analyze your data, then BigQuery is a great option. ", "documentMetadata": { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/f7ba2e8666f5514b5bc14f5e300d7678", "uri": "https://cloud.google.com/generative-ai-app-builder/docs/get-search-summaries", "title": "Get search summaries | Vertex AI Agent Builder | Google Cloud" } } }, { "chunkInfo": { "content": "Here is an example of a summary, with citations and citation metadata, returned at the end of a search response: See more code actions. Dismiss View Light code theme Dark code theme \"summary\": { \"summaryText\": \"BigQuery is Google Cloud's fully managed and completely serverless enterprise data warehouse [1]. BigQuery supports all data types, works across clouds, and has built-in machine learning and business intelligence, all within a unified platform [2, 3].\", \"summaryWithMetadata\": { \"summary\": \"BigQuery is Google Cloud's fully managed and completely serverless enterprise data warehouse. ", "documentMetadata": { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/f7ba2e8666f5514b5bc14f5e300d7678", "uri": "https://cloud.google.com/generative-ai-app-builder/docs/get-search-summaries", "title": "Get search summaries | Vertex AI Agent Builder | Google Cloud" } } } ], "steps": [ { "description": "Rephrase the query and search.", "actions": [ { "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/1a9f55e00c42c06ca97bf5a5868dbcdc", "uri": "https://cloud.google.com/generative-ai-app-builder/docs/answer", "title": "Get answers and follow-ups | Vertex AI Agent Builder | Google Cloud", "snippetInfo": [ { "snippet": "QUERY : a free-text string that contains the question or search query. For example, "Compare the BigQuery and \u003cb\u003eSpanner\u003c/b\u003e databases?". Example command and result.", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/9d022f7bdf24bac6714a9cf61a5458c7", "uri": "https://abc.xyz/assets/87/4c/162ca71d4178a3f4d39002467439/thomas-kurian-goldman-sachs-090723.pdf", "title": "Thomas Kurian Goldman Sachs 090723", "snippetInfo": [ { "snippet": "2X better training \u003cb\u003eperformance\u003c/b\u003e per dollar1 compared to a leading cloud alternative. More than 70% of gen AI unicorns are Google Cloud customers. Best ...", "snippetStatus": "SUCCESS" } ] }, ... { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/20641e370fa86c78f1c81f3dab22efe1", "uri": "https://cloud.google.com/generative-ai-app-builder/docs/release-notes", "title": "Vertex AI Agent Builder release notes | Google Cloud", "snippetInfo": [ { "snippet": "Generative answers have been updated with \u003cb\u003eperformance\u003c/b\u003e improvements. ... This lets you assess your search engine's \u003cb\u003eperformance\u003c/b\u003e ... Importing data from \u003cb\u003eSpanner\u003c/b\u003e, Cloud ...", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/b95bb201a0adb24f769627f56cf34405", "uri": "https://abc.xyz/assets/investor/static/pdf/2017_Q1_Earnings_Transcript.pdf", "title": "\u200b \u200b", "snippetInfo": [ { "snippet": "well as Hardware related costs, reflecting the continued strong \u003cb\u003eperformance\u003c/b\u003e of our new Made by ... We introduced dozens of new products, including \u003cb\u003eSpanner\u003c/b\u003e, a ...", "snippetStatus": "SUCCESS" } ] } ] } }, { "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/18bcc727bfd6a3d1be0aa4bd49fe2c50", "uri": "https://cloud.google.com/generative-ai-app-builder/docs/evaluate-search-quality", "title": "Evaluate search quality | Vertex AI Agent Builder | Google Cloud", "snippetInfo": [ { "snippet": "You can evaluate the \u003cb\u003eperformance\u003c/b\u003e of generic search apps that contain structured, unstructured, and website data. ... Import from \u003cb\u003eBigQuery\u003c/b\u003e: import \u003cb\u003eBigQuery\u003c/b\u003e data ...", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/2a3221d40533a4bdaf35778962a2a079", "uri": "https://cloud.google.com/generative-ai-app-builder/docs/check-media-data-quality", "title": "Check data quality for media recommendations | Vertex AI Agent Builder | Google Cloud", "snippetInfo": [ { "snippet": "... model that will result in \u003cb\u003eperformance\u003c/b\u003e issue if not met for all media recommendations models and all business objectives.", "condition": { "expression ...", "snippetStatus": "SUCCESS" } ] }, ... { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/18c258b9c770f4d762e6233d1a1bc81c", "uri": "https://cloud.google.com/generative-ai-app-builder/docs/user-events", "title": "About user events | Vertex AI Agent Builder | Google Cloud", "snippetInfo": [ { "snippet": "This section provides the data formats for each event type supported by media recommendations. Examples for JavaScript Pixel are provided. For \u003cb\u003eBigQuery\u003c/b\u003e, the ...", "snippetStatus": "SUCCESS" } ] }, { "document": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/1a9f55e00c42c06ca97bf5a5868dbcdc", "uri": "https://cloud.google.com/generative-ai-app-builder/docs/answer", "title": "Get answers and follow-ups | Vertex AI Agent Builder | Google Cloud", "snippetInfo": [ { "snippet": "QUERY : a free-text string that contains the question or search query. For example, "Compare the \u003cb\u003eBigQuery\u003c/b\u003e and Spanner databases?". Example command and result.", "snippetStatus": "SUCCESS" } ] } ] } } ] } ] } }En este ejemplo, la respuesta a la consulta "¿Qué base de datos es más rápida, BigQuery o Spanner?" aparece en una serie de resultados JSON. El resultado final tiene el estado
SUCCEEDED
y, además, incluye la respuesta completa.
Otros ejemplos
El comando básico que se muestra en Transmite una respuesta es el comando más simple sin opciones especificadas. Sin embargo, puedes aplicar las mismas opciones disponibles con el método answer, con la excepción de las limitaciones que se indican en esta página.
Las respuestas de transmisión también se pueden usar con sesiones de seguimiento.