Method: projects.locations.collections.engines.assistants.streamAssist

Assists the user with a query in a streaming fashion.

HTTP request

POST https://discoveryengine.googleapis.com/v1alpha/{name=projects/*/locations/*/collections/*/engines/*/assistants/*}:streamAssist

The URL uses gRPC Transcoding syntax.

Path parameters

Parameters
name

string

Required. The resource name of the Assistant. Format: projects/{project}/locations/{location}/collections/{collection}/engines/{engine}/assistants/{assistant}

Request body

The request body contains data with the following structure:

JSON representation
{
  "query": {
    object (Query)
  },
  "answerGenerationMode": enum (AnswerGenerationMode),
  "session": string,
  "assistSkippingMode": enum (AssistSkippingMode),
  "fileIds": [
    string
  ],
  "userMetadata": {
    object (UserMetadata)
  },
  "languageCode": string,
  "googleSearchGroundingEnabled": boolean,
  "webGroundingEnabled": boolean,
  "dataStoreSpecs": [
    {
      object (DataStoreSpec)
    }
  ],
  "agentsConfig": {
    object (AgentsConfig)
  },
  "cannedQuery": string
}
Fields
query

object (Query)

Optional. Current user query.

Empty query is only supported if fileIds are provided. In this case, the answer will be generated based on those context files.

answerGenerationMode

enum (AnswerGenerationMode)

Optional. The answer generation mode. If not specified, it defaults to NORMAL.

session

string

Optional. The session to use for the request. If specified, the assistant has access to the session history, and the query and the answer are stored there.

If - is specified as the session id, or it is left empty, then a new session is created with an automatically generated id.

Format: projects/{project}/locations/{location}/collections/{collection}/engines/{engine}/sessions/{session}

assistSkippingMode

enum (AssistSkippingMode)

Optional. Determines the cases in which the assistant will not answer the query. If the answer is skipped, the reasons will be listed in AssistAnswer.assist_skipped_reasons within AssistResponse.answer.

fileIds[]

string

Optional. The IDs of the files to be used for answering the request. When uploading a file, its id is returned in AddContextFileResponse.file_id.

userMetadata

object (UserMetadata)

Optional. Information about the user initiating the query.

languageCode

string

Optional. Language to be used for answering if language detection fails. Also used as the language of error messages created by actions, regardless of language detection results.

googleSearchGroundingEnabled
(deprecated)

boolean

Optional. Deprecated. Use webGroundingEnabled instead.

webGroundingEnabled

boolean

Optional. If set to true, enables grounding with web search. Works only if Assistant.web_grounding_type is [WEB_GROUNDING_TYPE_GOOGLE_SEARCH][] or [WEB_GROUNDING_TYPE_ENTERPRISE_WEB_SEARCH][].

dataStoreSpecs[]

object (DataStoreSpec)

Optional. Specs defining DataStores to filter on in a search call and configurations for those data stores. This is only considered for Engines with multiple data stores.

Not setting this field will result in using all data stores in the engine, except when ignoreDataStores is set to true.

agentsConfig

object (AgentsConfig)

Optional. Configuration of agents that are used to serve the request.

cannedQuery

string

Optional. The resource name of the CannedQuery for this request. This parameter can only be set if the session is new, otherwise an INVALID_ARGUMENT error is returned.

A session is considered new if there is a StreamAssistRequest.session provided and the corresponding Session does not have any turns in it, or if there is no StreamAssistRequest.session provided (and a new Session gets created).

If the cannedQuery parameter is given, the corresponding CannedQuery will be taken into account during processing. The exact behaviour is described and documented in the CannedQuery.

Format: projects/{project}/locations/{location}/collections/{collection}/engines/{engine}/assistants/{assistant}/cannedQueries/{cannedQuery}

Response body

Response for the AssistantService.StreamAssist method.

If successful, the response body contains data with the following structure:

JSON representation
{
  "answer": {
    object (AssistAnswer)
  },
  "sessionInfo": {
    object (SessionInfo)
  },
  "statusUpdates": [
    {
      object (StatusUpdate)
    }
  ],
  "assistToken": string,
  "toolResult": [
    {
      object (ToolResult)
    }
  ],
  "finalResultToolInvocationId": string
}
Fields
answer

object (AssistAnswer)

assistants.assist answer resource object containing parts of the assistant's final answer for the user's query.

Not present if the current response doesn't add anything to previously sent AssistAnswer.replies.

Observe AssistAnswer.state to see if more parts are to be expected. While the state is IN_PROGRESS, the AssistAnswer.replies field in each response will contain replies (reply fragments) to be appended to the ones received in previous responses. AssistAnswer.name won't be filled.

If the state is SUCCEEDED, FAILED or SKIPPED, the response is the last response and AssistAnswer.name will have a value.

sessionInfo

object (SessionInfo)

Session information.

statusUpdates[]

object (StatusUpdate)

Optional progress updates.

assistToken

string

A global unique ID that identifies the current pair of request and stream of responses. Used for feedback and support.

toolResult[]

object (ToolResult)

Results of tool invocations.

finalResultToolInvocationId

string

If this field is present, it contains the id of the tool invocation whose result is used as the final answer.

Authorization scopes

Requires the following OAuth scope:

  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Authentication Overview.

IAM Permissions

Requires the following IAM permission on the name resource:

  • discoveryengine.assistants.assist

For more information, see the IAM documentation.

AnswerGenerationMode

Available answer generation modes.

Enums
ANSWER_GENERATION_MODE_UNSPECIFIED Unspecified answer generation mode.
NORMAL Normal answer generation mode. May trigger a few searches and call actions.
RESEARCH Research answer generation mode. Deep dives into the query, triggering many searches for a wide range of topics related to the query.
AGENT Agent answer generation mode. uses an agent defined in agentsConfig to generate the answer.

AssistSkippingMode

Available skipping behaviors for assist requests.

Enums
ASSIST_SKIPPING_MODE_UNSPECIFIED Default value. The answer can be skipped if the query isn't seeking assistance.
REQUEST_ASSIST Request Assistant answer. The answer may still be skipped if the query fails policy checks.

UserMetadata

Information about the user.

JSON representation
{
  "timeZone": string
}
Fields
timeZone

string

Optional. IANA time zone, e.g. Europe/Budapest.

AgentsConfig

Configuration of agents that are used to serve the request.

JSON representation
{

  // Union field config can be only one of the following:
  "noCodeAgentsConfig": {
    object (NoCodeAgentsConfig)
  },
  "assistantAgentConfigId": string,
  "agent": string,
  "inlineAgent": {
    object (Agent)
  },
  "vertexAiAgentId": string
  // End of list of possible types for union field config.
}
Fields
Union field config. Configuration of the different types of agents. config can be only one of the following:
noCodeAgentsConfig
(deprecated)

object (NoCodeAgentsConfig)

Optional. Deprecated: Configuration for No-code Agentspace agents. When set, the assistants.assist request will be served according to the configuration. Use agent instead.

assistantAgentConfigId

string

Optional. id of the agent from Assistant.agent_configs

agent

string

The name of the agent to use. Format: projects/{project}/locations/{location}/collections/{collection}/engines/{engine}/assistants/{assistant}/agents/{agent}

inlineAgent

object (Agent)

The inline definition of the Agent to use. If provided, an agent based on this definition will be used. This is a temporary representation of an agent, the Agent.name field will be ignored.

vertexAiAgentId

string

Optional. id of the agent from Assistant.vertex_ai_agent_configs The id can be either the full name registered in the config or the last part after the last slash.

NoCodeAgentsConfig

Deprecated: Configuration for No-code Agentspace agents. Use agent instead.

JSON representation
{
  "agent": string
}
Fields
agent

string

Optional. The name of the agent to use.

SessionInfo

Information about the session.

JSON representation
{
  "session": string,
  "queryId": string
}
Fields
session

string

name of the newly generated or continued session.

Format: projects/{project}/locations/{location}/collections/{collection}/engines/{engine}/sessions/{session}.

queryId

string

Query id that corresponds to this assist API call. One session can have multiple turns, each with a unique query id.

By specifying the session name and this query id in the assistants.assist API call, the assist request happens in the context of the search results from this search call.

StatusUpdate

Update about how the assist call is progressing.

JSON representation
{
  "updateText": string,
  "invocationId": string
}
Fields
updateText

string

Free text status status update, e.g., 'Starting internal search in HR docs for benefits', or 'Web search for "Moon landing" got 12 results'.

invocationId

string

Unique identifier of the invocation that generates the update.

ToolResult

(Partial) result of a tool invocation.

JSON representation
{
  "toolInvocationId": string,
  "result": {
    object (Reply)
  }
}
Fields
toolInvocationId

string

Unique identifier of the tool invocation that generates the result.

result

object (Reply)

Partial content of the result.