Cómo obtener resultados de la búsqueda de StreamAssist
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
En tu app web, puedes obtener respuestas a tus preguntas en forma de respuestas transmitidas. En este documento, se muestra cómo usar la API de REST para obtener respuestas. Si quieres usar la app web de Gemini Enterprise, consulta Cómo chatear con el asistente.
Descripción general de StreamAssist
StreamAssist proporciona una forma interactiva y potente de controlar las preguntas de los usuarios. Funciona de forma continua, lo que permite interacciones en tiempo real.
Las capacidades clave de la API incluyen las siguientes:
Mantiene el contexto de la conversación: Usa sesiones para mantener el contexto de la conversación, lo que garantiza que comprenda las preguntas de seguimiento dentro del alcance de las interacciones anteriores.
Incorpora los archivos proporcionados: Incluye los archivos adjuntos como contexto para brindar respuestas más fundamentadas y pertinentes.
Integración fluida: Se integra con varios agentes y herramientas para satisfacer una amplia variedad de solicitudes de los usuarios.
Antes de comenzar
Asegúrate de tener lo siguiente:
La API de Discovery Engine habilitada para tu Google Cloud.
Puedes habilitarla en la página API de Discovery Engine de la consola deGoogle Cloud .
Una app de Gemini Enterprise existente. Para crear una app, consulta Cómo crear una app.
Cómo obtener resultados de búsqueda
Puedes usar el método streamAssist para consultar y obtener respuestas de Gemini Enterprise. El siguiente comando curl enumera los campos obligatorios.
PROJECT_ID: Es el ID de tu proyecto de Google Cloud .
APP_ID: Es el identificador único de la app de Gemini Enterprise.
LOCATION: Es la multirregión de tu almacén de datos: global, us o eu.
QUERY_TEXT_1: Es el texto de la búsqueda.
Ejemplo de comando y resultado
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://global-discoveryengine.googleapis.com/v1alpha/projects/my-project-123/locations/global/collections/default_collection/engines/my-app/assistants/default_assistant:streamAssist" \
-d '
{
"query": {
"text": "By when do corporations need to file taxes?"
}
}'
{
"answer": {
"name": "projects/my-project-123/locations/global/collections/default_collection/engines/my-app/sessions/123456789013/assistAnswers/123456789019",
"state": "SUCCEEDED",
"replies": [
{
"groundedContent": {},
"replyId": "123456789050"
},
{
"groundedContent": {},
"replyId": "123456789050"
}
],
"diagnosticInfo": {
"plannerSteps": [
{
"createTime": "2025-11-24T22:21:13.958569117Z",
"queryStep": {
"parts": [
{
"text": "By when do corporations need to file taxes?"
}
]
}
},
{
"createTime": "2025-11-24T22:21:17.218914056Z",
"planStep": {
"parts": [
{
"text": "**Formulating the Query**\n"
}
],
"planStepId": "123456789050",
"role": "MODEL"
}
},
{
"planStep": {
"parts": [
{
"text": "**Refining the Response**\n"
}
],
"role": "MODEL",
"planStepId": "123456789050"
},
"createTime": "2025-11-24T22:21:19.734447578Z"
},
{
"createTime": "2025-11-24T22:21:21.940682307Z",
"planStep": {
"planStepId": "123456789050",
"role": "MODEL",
"parts": [
{
"text": "**Processing the Results**\n"
}
]
}
},
{
"planStep": {
"role": "MODEL",
"parts": [
{
"text": "**Querying and Analyzing**\n**Structuring the Answer**\n"
}
],
"planStepId": "123456789050"
},
"createTime": "2025-11-24T22:21:25.058155923Z"
},
{
"createTime": "2025-11-24T22:21:25.955761161Z",
"planStep": {
"planStepId": "123456789050",
"role": "MODEL",
"parts": [
{
"text": "**Refining the Details**\n"
}
]
}
},
{
"createTime": "2025-11-24T22:21:25.967576803Z",
"planStep": {
"role": "MODEL",
"parts": [
{
"text": "Of course, I can help with that. The deadline for corporations to file their federal income tax returns depends on the type of corporation.\n\n### **Corporate Tax Filing Deadlines**\n\n| Corporation Type | Deadline | For Calendar Year-End (Dec. 31) |\n| :--- | :--- | :--- |"
}
],
"planStepId": "123456789050"
}
},
{
"createTime": "2025-11-24T22:21:25.988820408Z",
"planStep": {
"planStepId": "123456789050",
"role": "MODEL",
"parts": [
{
"text": "\n| **C Corporations** | 15th day of the fourth month after the end of their fiscal year. | April 15 |\n| **S Corporations** | 15th day of the third month after the end of their fiscal year. | March 15 |\n\n---\n\n###"
}
]
}
},
{
"createTime": "2025-11-24T22:21:26.016095651Z",
"planStep": {
"planStepId": "123456789050",
"role": "MODEL",
"parts": [
{
"text": " **Extensions**\n\nIf a corporation needs more time to file, it can request a six-month extension by filing the appropriate form with the IRS. It's important to note that an extension to file is not an extension to pay. Taxes are still due by the original deadline.\n\nWould you like to know about"
}
]
}
},
{
"planStep": {
"parts": [
{
"text": " the deadlines for any other types of business entities?"
}
],
"planStepId": "123456789050",
"role": "MODEL"
},
"createTime": "2025-11-24T22:21:26.070810455Z"
}
]
}
},
"sessionInfo": {
"session": "projects/my-project-123/locations/global/collections/default_collection/engines/my-app/sessions/123456789013",
"queryId": "123456789078",
"turnId": "123456789013_123456789029"
},
"assistToken": "1234567890123456789012345678901234567890"
}
Para obtener más información sobre los campos y lo que se devuelve, consulta Cuerpo de la respuesta.
Obtén resultados de la búsqueda con la misma sesión
Para continuar una conversación y obtener respuestas de Gemini Enterprise en una sesión existente, usa el método streamAssist. En el siguiente muestra de código, se muestran los campos obligatorios:
PROJECT_ID: Es el ID de tu proyecto de Google Cloud .
APP_ID: Es el identificador único de la app de Gemini Enterprise.
LOCATION: Es la multirregión de tu almacén de datos: global, us o eu.
QUERY_TEXT_2: Es el texto de la búsqueda.
SESSION_ID: Es el ID de una sesión de una conversación o consulta anterior.
Ejemplo de comando y resultado
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://global-discoveryengine.googleapis.com/v1alpha/projects/my-project-123/locations/global/collections/default_collection/engines/my-app/assistants/default_assistant:streamAssist" \
-d '
{
"session": "projects/my-project-123/locations/global/collections/default_collection/engines/my-app/sessions/123456789013",
"query": {
"text": "what are the documents you need to file taxes?"
}
}'
{
"answer": {
"name": "projects/my-project-123/locations/global/collections/default_collection/engines/my-app/sessions/123456789013/assistAnswers/15195007515750046778",
"state": "SUCCEEDED",
"replies": [
{
"groundedContent": {},
"replyId": "123456789051"
},
{
"groundedContent": {},
"replyId": "123456789051"
}
],
"diagnosticInfo": {
"plannerSteps": [
{
"queryStep": {
"parts": [
{
"text": "what are the documents you need to file taxes?"
}
]
},
"createTime": "2025-11-24T23:06:45.101296577Z"
},
{
"planStep": {
"role": "MODEL",
"parts": [
{
"text": "**Identifying Tax Documents**\n"
}
],
"planStepId": "123456789051"
},
"createTime": "2025-11-24T23:06:48.201642404Z"
},
{
"planStep": {
"parts": [
{
"text": "**Formulating the Search Strategy**\n"
}
],
"role": "MODEL",
"planStepId": "123456789051"
},
"createTime": "2025-11-24T23:06:51.081693248Z"
},
{
"createTime": "2025-11-24T23:06:53.884827627Z",
"planStep": {
"parts": [
{
"text": "**Searching for Information**\n"
}
],
"role": "MODEL",
"planStepId": "123456789051"
}
},
{
"createTime": "2025-11-24T23:06:55.663545003Z",
"planStep": {
"role": "MODEL",
"parts": [
{
"text": "**Planning the Response Structure**\n"
}
],
"planStepId": "123456789051"
}
},
{
"planStep": {
"planStepId": "123456789051",
"parts": [
{
"text": "Of course, I can provide a list of the common documents and information you'll need to file your personal income taxes. Having these ready can make the process much smoother.\n\n### **Documents for Filing Personal Taxes**\n\n| Category | Document/Information | Purpose |\n| :--- | :--- | :--- |"
}
],
"role": "MODEL"
},
"createTime": "2025-11-24T23:06:55.687661122Z"
},
{
"planStep": {
"planStepId": "123456789051",
"parts": [
{
"text": "\n| **Personal Information** | \u003cul\u003e\u003cli\u003eYour Social Security Number (SSN) or Individual Taxpayer Identification Number (ITIN)\u003c/li\u003e\u003cli\u003eSSNs or ITINs for your spouse and any dependents\u003c/li\u003e\u003c/ul\u003e | To identify you and your family members to the IRS. |\n| **Income Information** | \u003cul\u003e\u003cli\u003e**"
}
],
"role": "MODEL"
},
"createTime": "2025-11-24T23:06:55.713426005Z"
},
{
"planStep": {
"role": "MODEL",
"parts": [
{
"text": "W-2 forms** from all employers.\u003c/li\u003e\u003cli\u003e**1099 forms** such as 1099-NEC, 1099-DIV, 1099-INT, 1099-G.\u003c/li\u003e\u003cli\u003eRecords of any other income (business, rental, etc.).\u003c/li\u003e\u003c/ul\u003e | To"
}
],
"planStepId": "123456789051"
},
"createTime": "2025-11-24T23:06:56.158732383Z"
},
{
"createTime": "2025-11-24T23:06:56.700143436Z",
"planStep": {
"role": "MODEL",
"parts": [
{
"text": " report all of your income from various sources. |\n| **Deductions & Credits** | \u003cul\u003e\u003cli\u003eReceipts for charitable donations.\u003c/li\u003e\u003cli\u003eMedical expense records.\u003c/li\u003e\u003cli\u003e**Form 1098** (mortgage interest) & **1098-T** (tuition).\u003c/li\u003e\u003cli\u003eChild"
}
],
"planStepId": "123456789051"
}
},
{
"planStep": {
"planStepId": "123456789051",
"role": "MODEL",
"parts": [
{
"text": "care expense records.\u003c/li\u003e\u003c/ul\u003e | To reduce your taxable income and take advantage of tax credits. |\n| **Other Documents** | \u003cul\u003e\u003cli\u003eLast year's tax return.\u003c/li\u003e\u003cli\u003eBank account and routing numbers.\u003c/li\u003e\u003c/ul\u003e | For reference and to receive a direct deposit refund or make a payment. |\n\n---\n\nThis"
}
]
},
"createTime": "2025-11-24T23:06:57.410549380Z"
},
{
"planStep": {
"planStepId": "123456789051",
"parts": [
{
"text": " list covers the most common items, but your specific needs may vary depending on your financial situation. It's always a good idea to keep your tax-related documents organized throughout the year.\n\nIs there a specific type of income or deduction you would like to know more about?"
}
],
"role": "MODEL"
},
"createTime": "2025-11-24T23:06:57.960883085Z"
}
]
}
},
"sessionInfo": {
"session": "projects/my-project-123/locations/global/collections/default_collection/engines/my-app/sessions/123456789013",
"queryId": "123456789057",
"turnId": "123456789013_123456789072"
},
"assistToken": "1234567890123456789012345678901234567890"
}
Para obtener más información sobre los campos y lo que se devuelve, consulta Cuerpo de la respuesta.
Sube un archivo y obtén resultados de la búsqueda (versión preliminar)
Para darle más contexto al asistente, sube un archivo a una sesión y, luego, consulta su contenido. Lleva a cabo los pasos siguientes:
Sube un archivo a una sesión con el método addContextFile.
PROJECT_ID: Es el ID de tu proyecto de Google Cloud .
LOCATION: Es la multirregión de tu almacén de datos: global, us o eu.
APP_ID: Es el identificador único de la app de Gemini Enterprise.
SESSION_ID: Es el ID de una sesión de una conversación o consulta anterior.
FILE_NAME: Es el nombre del archivo.
MIME_TYPE: Es el tipo de MIME del archivo, por ejemplo, text/plain o application/pdf. Para obtener más información sobre los diferentes tipos de medios, consulta Tipos de medios.
BASE64_ENCODED_FILE: Es la representación del archivo codificada en Base64.
Ejemplo de comando y resultado
# Create a sample file to upload
export FILE_NAME="my_test_file.txt"
export FILE_PATH="/tmp/${FILE_NAME}"
echo "This is a sample text file to upload for the Gemini Enterprise assistant." > "${FILE_PATH}"
echo "It contains a few lines of text." >> "${FILE_PATH}"
# Base64 encode the file content
export BASE64_ENCODED_FILE=$(base64 -w 0 "${FILE_PATH}")
#Upload the file to the session using the curl command
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://global-discoveryengine.googleapis.com/v1alpha/projects/my-project-123/locations/global/collections/default_collection/engines/my-app/sessions/123456789013:addContextFile" \
-d '
{
"fileName": "my_test_file.txt",
"mimeType": "text/plain",
"fileContents": "'"$BASE64_ENCODED_FILE"'"
}'
# Response
{
"session": "projects/my-project-123/locations/global/collections/default_collection/engines/my-app/sessions/123456789013",
"fileId": "123456789012345",
"tokenCount": "24"
}
Para obtener más información sobre los campos y lo que se devuelve, consulta Cuerpo de la respuesta.
Usa la misma sesión para hacer una pregunta sobre el archivo que subiste con el método streamAssist.
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-12-15 (UTC)"],[],[]]