Close httplib2 connections.
Gets an Assistant.
patch(name, body=None, updateMask=None, x__xgafv=None)
Updates an Assistant
streamAssist(name, body=None, x__xgafv=None)
Assists the user with a query in a streaming fashion.
close()
Close httplib2 connections.
get(name, x__xgafv=None)
Gets an Assistant. Args: name: string, Required. Resource name of Assistant. Format: `projects/{project}/locations/{location}/collections/{collection}/engines/{engine}/assistants/{assistant}` (required) x__xgafv: string, V1 error format. Allowed values 1 - v1 error format 2 - v2 error format Returns: An object of the form: { # Discovery Engine Assistant resource. "customerPolicy": { # Customer-defined policy for the assistant. # Optional. Customer policy for the assistant. "bannedPhrases": [ # Optional. List of banned phrases. { # Definition of a customer-defined banned phrase. A banned phrase is not allowed to appear in the user query or the LLM response, or else the answer will be refused. "ignoreDiacritics": True or False, # Optional. If true, diacritical marks (e.g., accents, umlauts) are ignored when matching banned phrases. For example, "cafe" would match "café". "matchType": "A String", # Optional. Match type for the banned phrase. "phrase": "A String", # Required. The raw string content to be banned. }, ], "modelArmorConfig": { # Configuration for customer defined Model Armor templates to be used for sanitizing user prompts and assistant responses. # Optional. Model Armor configuration to be used for sanitizing user prompts and assistant responses. "failureMode": "A String", # Optional. Defines the failure mode for Model Armor sanitization. "responseTemplate": "A String", # Optional. The resource name of the Model Armor template for sanitizing assistant responses. Format: `projects/{project}/locations/{location}/templates/{template_id}` If not specified, no sanitization will be applied to the assistant response. "userPromptTemplate": "A String", # Optional. The resource name of the Model Armor template for sanitizing user prompts. Format: `projects/{project}/locations/{location}/templates/{template_id}` If not specified, no sanitization will be applied to the user prompt. }, }, "enabledTools": { # Optional. Note: not implemented yet. Use enabled_actions instead. The enabled tools on this assistant. The keys are connector name, for example "projects/{projectId}/locations/{locationId}/collections/{collectionId}/dataconnector The values consist of admin enabled tools towards the connector instance. Admin can selectively enable multiple tools on any of the connector instances that they created in the project. For example {"jira1ConnectorName": [(toolId1, "createTicket"), (toolId2, "transferTicket")], "gmail1ConnectorName": [(toolId3, "sendEmail"),..] } "a_key": { # The enabled tools on a connector "toolInfo": [ # The list of tools with corresponding tool information. { # Information to identify a tool. "toolDisplayName": "A String", # The display name of the tool. "toolName": "A String", # The name of the tool as defined by DataConnectorService.QueryAvailableActions. Note: it's using `action` in the DataConnectorService apis, but they are the same as the `tool` here. }, ], }, }, "generationConfig": { # Configuration for the generation of the assistant response. # Optional. Configuration for the generation of the assistant response. "defaultLanguage": "A String", # The default language to use for the generation of the assistant response. Use an ISO 639-1 language code such as `en`. If not specified, the language will be automatically detected. "systemInstruction": { # System instruction, also known as the prompt preamble for LLM calls. # System instruction, also known as the prompt preamble for LLM calls. See also https://cloud.google.com/vertex-ai/generative-ai/docs/learn/prompts/system-instructions "additionalSystemInstruction": "A String", # Optional. Additional system instruction that will be added to the default system instruction. }, }, "name": "A String", # Immutable. Resource name of the assistant. Format: `projects/{project}/locations/{location}/collections/{collection}/engines/{engine}/assistants/{assistant}` It must be a UTF-8 encoded string with a length limit of 1024 characters. "webGroundingType": "A String", # Optional. The type of web grounding to use. }
patch(name, body=None, updateMask=None, x__xgafv=None)
Updates an Assistant Args: name: string, Immutable. Resource name of the assistant. Format: `projects/{project}/locations/{location}/collections/{collection}/engines/{engine}/assistants/{assistant}` It must be a UTF-8 encoded string with a length limit of 1024 characters. (required) body: object, The request body. The object takes the form of: { # Discovery Engine Assistant resource. "customerPolicy": { # Customer-defined policy for the assistant. # Optional. Customer policy for the assistant. "bannedPhrases": [ # Optional. List of banned phrases. { # Definition of a customer-defined banned phrase. A banned phrase is not allowed to appear in the user query or the LLM response, or else the answer will be refused. "ignoreDiacritics": True or False, # Optional. If true, diacritical marks (e.g., accents, umlauts) are ignored when matching banned phrases. For example, "cafe" would match "café". "matchType": "A String", # Optional. Match type for the banned phrase. "phrase": "A String", # Required. The raw string content to be banned. }, ], "modelArmorConfig": { # Configuration for customer defined Model Armor templates to be used for sanitizing user prompts and assistant responses. # Optional. Model Armor configuration to be used for sanitizing user prompts and assistant responses. "failureMode": "A String", # Optional. Defines the failure mode for Model Armor sanitization. "responseTemplate": "A String", # Optional. The resource name of the Model Armor template for sanitizing assistant responses. Format: `projects/{project}/locations/{location}/templates/{template_id}` If not specified, no sanitization will be applied to the assistant response. "userPromptTemplate": "A String", # Optional. The resource name of the Model Armor template for sanitizing user prompts. Format: `projects/{project}/locations/{location}/templates/{template_id}` If not specified, no sanitization will be applied to the user prompt. }, }, "enabledTools": { # Optional. Note: not implemented yet. Use enabled_actions instead. The enabled tools on this assistant. The keys are connector name, for example "projects/{projectId}/locations/{locationId}/collections/{collectionId}/dataconnector The values consist of admin enabled tools towards the connector instance. Admin can selectively enable multiple tools on any of the connector instances that they created in the project. For example {"jira1ConnectorName": [(toolId1, "createTicket"), (toolId2, "transferTicket")], "gmail1ConnectorName": [(toolId3, "sendEmail"),..] } "a_key": { # The enabled tools on a connector "toolInfo": [ # The list of tools with corresponding tool information. { # Information to identify a tool. "toolDisplayName": "A String", # The display name of the tool. "toolName": "A String", # The name of the tool as defined by DataConnectorService.QueryAvailableActions. Note: it's using `action` in the DataConnectorService apis, but they are the same as the `tool` here. }, ], }, }, "generationConfig": { # Configuration for the generation of the assistant response. # Optional. Configuration for the generation of the assistant response. "defaultLanguage": "A String", # The default language to use for the generation of the assistant response. Use an ISO 639-1 language code such as `en`. If not specified, the language will be automatically detected. "systemInstruction": { # System instruction, also known as the prompt preamble for LLM calls. # System instruction, also known as the prompt preamble for LLM calls. See also https://cloud.google.com/vertex-ai/generative-ai/docs/learn/prompts/system-instructions "additionalSystemInstruction": "A String", # Optional. Additional system instruction that will be added to the default system instruction. }, }, "name": "A String", # Immutable. Resource name of the assistant. Format: `projects/{project}/locations/{location}/collections/{collection}/engines/{engine}/assistants/{assistant}` It must be a UTF-8 encoded string with a length limit of 1024 characters. "webGroundingType": "A String", # Optional. The type of web grounding to use. } updateMask: string, The list of fields to update. x__xgafv: string, V1 error format. Allowed values 1 - v1 error format 2 - v2 error format Returns: An object of the form: { # Discovery Engine Assistant resource. "customerPolicy": { # Customer-defined policy for the assistant. # Optional. Customer policy for the assistant. "bannedPhrases": [ # Optional. List of banned phrases. { # Definition of a customer-defined banned phrase. A banned phrase is not allowed to appear in the user query or the LLM response, or else the answer will be refused. "ignoreDiacritics": True or False, # Optional. If true, diacritical marks (e.g., accents, umlauts) are ignored when matching banned phrases. For example, "cafe" would match "café". "matchType": "A String", # Optional. Match type for the banned phrase. "phrase": "A String", # Required. The raw string content to be banned. }, ], "modelArmorConfig": { # Configuration for customer defined Model Armor templates to be used for sanitizing user prompts and assistant responses. # Optional. Model Armor configuration to be used for sanitizing user prompts and assistant responses. "failureMode": "A String", # Optional. Defines the failure mode for Model Armor sanitization. "responseTemplate": "A String", # Optional. The resource name of the Model Armor template for sanitizing assistant responses. Format: `projects/{project}/locations/{location}/templates/{template_id}` If not specified, no sanitization will be applied to the assistant response. "userPromptTemplate": "A String", # Optional. The resource name of the Model Armor template for sanitizing user prompts. Format: `projects/{project}/locations/{location}/templates/{template_id}` If not specified, no sanitization will be applied to the user prompt. }, }, "enabledTools": { # Optional. Note: not implemented yet. Use enabled_actions instead. The enabled tools on this assistant. The keys are connector name, for example "projects/{projectId}/locations/{locationId}/collections/{collectionId}/dataconnector The values consist of admin enabled tools towards the connector instance. Admin can selectively enable multiple tools on any of the connector instances that they created in the project. For example {"jira1ConnectorName": [(toolId1, "createTicket"), (toolId2, "transferTicket")], "gmail1ConnectorName": [(toolId3, "sendEmail"),..] } "a_key": { # The enabled tools on a connector "toolInfo": [ # The list of tools with corresponding tool information. { # Information to identify a tool. "toolDisplayName": "A String", # The display name of the tool. "toolName": "A String", # The name of the tool as defined by DataConnectorService.QueryAvailableActions. Note: it's using `action` in the DataConnectorService apis, but they are the same as the `tool` here. }, ], }, }, "generationConfig": { # Configuration for the generation of the assistant response. # Optional. Configuration for the generation of the assistant response. "defaultLanguage": "A String", # The default language to use for the generation of the assistant response. Use an ISO 639-1 language code such as `en`. If not specified, the language will be automatically detected. "systemInstruction": { # System instruction, also known as the prompt preamble for LLM calls. # System instruction, also known as the prompt preamble for LLM calls. See also https://cloud.google.com/vertex-ai/generative-ai/docs/learn/prompts/system-instructions "additionalSystemInstruction": "A String", # Optional. Additional system instruction that will be added to the default system instruction. }, }, "name": "A String", # Immutable. Resource name of the assistant. Format: `projects/{project}/locations/{location}/collections/{collection}/engines/{engine}/assistants/{assistant}` It must be a UTF-8 encoded string with a length limit of 1024 characters. "webGroundingType": "A String", # Optional. The type of web grounding to use. }
streamAssist(name, body=None, x__xgafv=None)
Assists the user with a query in a streaming fashion. Args: name: string, Required. The resource name of the Assistant. Format: `projects/{project}/locations/{location}/collections/{collection}/engines/{engine}/assistants/{assistant}` (required) body: object, The request body. The object takes the form of: { # Request for the AssistantService.StreamAssist method. "generationSpec": { # Assistant generation specification for the request. This allows to override the default generation configuration at the engine level. # Optional. Specification of the generation configuration for the request. "modelId": "A String", # Optional. The Vertex AI model_id used for the generative model. If not set, the default Assistant model will be used. }, "query": { # Defines a user inputed query. # Optional. Current user query. Empty query is only supported if `file_ids` are provided. In this case, the answer will be generated based on those context files. "queryId": "A String", # Output only. Unique Id for the query. "text": "A String", # Plain text. }, "session": "A 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}` "toolsSpec": { # Specification of tools that are used to serve the request. # Optional. Specification of tools that are used to serve the request. "imageGenerationSpec": { # Specification of the image generation tool. # Optional. Specification of the image generation tool. }, "vertexAiSearchSpec": { # Specification of the Vertex AI Search tool. # Optional. Specification of the Vertex AI Search tool. "dataStoreSpecs": [ # 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. { # A struct to define data stores to filter on in a search call and configurations for those data stores. Otherwise, an `INVALID_ARGUMENT` error is returned. "boostSpec": { # Boost specification to boost certain documents. # Optional. Boost specification to boost certain documents. For more information on boosting, see [Boosting](https://cloud.google.com/generative-ai-app-builder/docs/boost-search-results) "conditionBoostSpecs": [ # Condition boost specifications. If a document matches multiple conditions in the specifications, boost scores from these specifications are all applied and combined in a non-linear way. Maximum number of specifications is 20. { # Boost applies to documents which match a condition. "boost": 3.14, # Strength of the condition boost, which should be in [-1, 1]. Negative boost means demotion. Default is 0.0. Setting to 1.0 gives the document a big promotion. However, it does not necessarily mean that the boosted document will be the top result at all times, nor that other documents will be excluded. Results could still be shown even when none of them matches the condition. And results that are significantly more relevant to the search query can still trump your heavily favored but irrelevant documents. Setting to -1.0 gives the document a big demotion. However, results that are deeply relevant might still be shown. The document will have an upstream battle to get a fairly high ranking, but it is not blocked out completely. Setting to 0.0 means no boost applied. The boosting condition is ignored. Only one of the (condition, boost) combination or the boost_control_spec below are set. If both are set then the global boost is ignored and the more fine-grained boost_control_spec is applied. "boostControlSpec": { # Specification for custom ranking based on customer specified attribute value. It provides more controls for customized ranking than the simple (condition, boost) combination above. # Complex specification for custom ranking based on customer defined attribute value. "attributeType": "A String", # The attribute type to be used to determine the boost amount. The attribute value can be derived from the field value of the specified field_name. In the case of numerical it is straightforward i.e. attribute_value = numerical_field_value. In the case of freshness however, attribute_value = (time.now() - datetime_field_value). "controlPoints": [ # The control points used to define the curve. The monotonic function (defined through the interpolation_type above) passes through the control points listed here. { # The control points used to define the curve. The curve defined through these control points can only be monotonically increasing or decreasing(constant values are acceptable). "attributeValue": "A String", # Can be one of: 1. The numerical field value. 2. The duration spec for freshness: The value must be formatted as an XSD `dayTimeDuration` value (a restricted subset of an ISO 8601 duration value). The pattern for this is: `nDnM]`. "boostAmount": 3.14, # The value between -1 to 1 by which to boost the score if the attribute_value evaluates to the value specified above. }, ], "fieldName": "A String", # The name of the field whose value will be used to determine the boost amount. "interpolationType": "A String", # The interpolation type to be applied to connect the control points listed below. }, "condition": "A String", # An expression which specifies a boost condition. The syntax and supported fields are the same as a filter expression. See SearchRequest.filter for detail syntax and limitations. Examples: * To boost documents with document ID "doc_1" or "doc_2", and color "Red" or "Blue": `(document_id: ANY("doc_1", "doc_2")) AND (color: ANY("Red", "Blue"))` }, ], }, "customSearchOperators": "A String", # Optional. Custom search operators which if specified will be used to filter results from workspace data stores. For more information on custom search operators, see [SearchOperators](https://support.google.com/cloudsearch/answer/6172299). "dataStore": "A String", # Required. Full resource name of DataStore, such as `projects/{project}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}`. The path must include the project number, project id is not supported for this field. "filter": "A String", # Optional. Filter specification to filter documents in the data store specified by data_store field. For more information on filtering, see [Filtering](https://cloud.google.com/generative-ai-app-builder/docs/filter-search-metadata) }, ], "filter": "A String", # Optional. The filter syntax consists of an expression language for constructing a predicate from one or more fields of the documents being filtered. Filter expression is case-sensitive. If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. Filtering in Vertex AI Search is done by mapping the LHS filter key to a key property defined in the Vertex AI Search backend -- this mapping is defined by the customer in their schema. For example a media customer might have a field 'name' in their schema. In this case the filter would look like this: filter --> name:'ANY("king kong")' For more information about filtering including syntax and filter operators, see [Filter](https://cloud.google.com/generative-ai-app-builder/docs/filter-search-metadata) }, "videoGenerationSpec": { # Specification of the video generation tool. # Optional. Specification of the video generation tool. }, "webGroundingSpec": { # Specification of the web grounding tool. # Optional. Specification of the web grounding tool. If field is present, 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. }, }, "userMetadata": { # User metadata of the request. # Optional. Information about the user initiating the query. "preferredLanguageCode": "A String", # Optional. Preferred 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. "timeZone": "A String", # Optional. IANA time zone, e.g. Europe/Budapest. }, } x__xgafv: string, V1 error format. Allowed values 1 - v1 error format 2 - v2 error format Returns: An object of the form: { # Response for the AssistantService.StreamAssist method. "answer": { # AssistAnswer resource, main part of AssistResponse. # 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. "assistSkippedReasons": [ # Reasons for not answering the assist call. "A String", ], "customerPolicyEnforcementResult": { # Customer policy enforcement results. Contains the results of the various policy checks, like the banned phrases or the Model Armor checks. # Optional. The field contains information about the various policy checks' results like the banned phrases or the Model Armor checks. This field is populated only if the assist call was skipped due to a policy violation. "policyResults": [ # Customer policy enforcement results. Populated only if the assist call was skipped due to a policy violation. It contains results from those filters that blocked the processing of the query. { # Customer policy enforcement result for a single policy type. "bannedPhraseEnforcementResult": { # Customer policy enforcement result for the banned phrase policy. # The policy enforcement result for the banned phrase policy. "bannedPhrases": [ # The banned phrases that were found in the query or the answer. "A String", ], }, "modelArmorEnforcementResult": { # Customer policy enforcement result for the Model Armor policy. # The policy enforcement result for the Model Armor policy. "error": { # The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors). # The error returned by Model Armor if the policy enforcement failed for some reason. "code": 42, # The status code, which should be an enum value of google.rpc.Code. "details": [ # A list of messages that carry the error details. There is a common set of message types for APIs to use. { "a_key": "", # Properties of the object. Contains field @type with type URL. }, ], "message": "A String", # A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client. }, "modelArmorViolation": "A String", # The Model Armor violation that was found. }, }, ], "verdict": "A String", # Final verdict of the customer policy enforcement. If only one policy blocked the processing, the verdict is BLOCK. }, "name": "A String", # Immutable. Identifier. Resource name of the `AssistAnswer`. Format: `projects/{project}/locations/{location}/collections/{collection}/engines/{engine}/sessions/{session}/assistAnswers/{assist_answer}` This field must be a UTF-8 encoded string with a length limit of 1024 characters. "replies": [ # Replies of the assistant. { # One part of the multi-part response of the assist call. "groundedContent": { # A piece of content and possibly its grounding information. Not all content needs grounding. Phrases like "Of course, I will gladly search it for you." do not need grounding. # Possibly grounded response text or media from the assistant. "content": { # Multi-modal content. # The content. "codeExecutionResult": { # Result of executing ExecutableCode. # Result of executing an ExecutableCode. "outcome": "A String", # Required. Outcome of the code execution. "output": "A String", # Optional. Contains stdout when code execution is successful, stderr or other description otherwise. }, "executableCode": { # Code generated by the model that is meant to be executed by the model. # Code generated by the model that is meant to be executed. "code": "A String", # Required. The code content. Currently only supports Python. }, "file": { # A file, e.g., an audio summary. # A file, e.g., an audio summary. "fileId": "A String", # Required. The file ID. "mimeType": "A String", # Required. The media type (MIME type) of the file. }, "inlineData": { # Inline blob. # Inline binary data. "data": "A String", # Required. Raw bytes. "mimeType": "A String", # Required. The media type (MIME type) of the generated data. }, "role": "A String", # The producer of the content. Can be "model" or "user". "text": "A String", # Inline text. "thought": True or False, # Optional. Indicates if the part is thought from the model. }, "textGroundingMetadata": { # Grounding details for text sources. # Metadata for grounding based on text sources. "references": [ # References for the grounded text. { # Referenced content and related document metadata. "content": "A String", # Referenced text content. "documentMetadata": { # Document metadata. # Document metadata. "document": "A String", # Document resource name. "domain": "A String", # Domain name from the document URI. Note that the `uri` field may contain a URL that redirects to the actual website, in which case this will contain the domain name of the target site. "mimeType": "A String", # The mime type of the document. https://www.iana.org/assignments/media-types/media-types.xhtml. "pageIdentifier": "A String", # Page identifier. "title": "A String", # Title. "uri": "A String", # URI for the document. It may contain a URL that redirects to the actual website. }, }, ], "segments": [ # Grounding information for parts of the text. { # Grounding information for a segment of the text. "endIndex": "A String", # End of the segment, exclusive. "groundingScore": 3.14, # Score for the segment. "referenceIndices": [ # References for the segment. 42, ], "startIndex": "A String", # Zero-based index indicating the start of the segment, measured in bytes of a UTF-8 string (i.e. characters encoded on multiple bytes have a length of more than one). "text": "A String", # The text segment itself. }, ], }, }, }, ], "state": "A String", # State of the answer generation. }, "assistToken": "A String", # A global unique ID that identifies the current pair of request and stream of responses. Used for feedback and support. "sessionInfo": { # Information about the session. # Session information. "session": "A String", # Name of the newly generated or continued session. Format: `projects/{project}/locations/{location}/collections/{collection}/engines/{engine}/sessions/{session}`. }, }