Discovery Engine API . projects . locations

Instance Methods

collections()

Returns the collections Resource.

dataStores()

Returns the dataStores Resource.

groundingConfigs()

Returns the groundingConfigs Resource.

identityMappingStores()

Returns the identityMappingStores Resource.

operations()

Returns the operations Resource.

rankingConfigs()

Returns the rankingConfigs Resource.

userEvents()

Returns the userEvents Resource.

close()

Close httplib2 connections.

generateGroundedContent(location, body=None, x__xgafv=None)

Generates grounded content.

Method Details

close()
Close httplib2 connections.
generateGroundedContent(location, body=None, x__xgafv=None)
Generates grounded content.

Args:
  location: string, Required. Location resource. Format: `projects/{project}/locations/{location}`. (required)
  body: object, The request body.
    The object takes the form of:

{ # Top-level message sent by the client for the `GenerateGroundedContent` method.
  "contents": [ # Content of the current conversation with the model. For single-turn queries, this is a single instance. For multi-turn queries, this is a repeated field that contains conversation history + latest request.
    { # Base structured datatype containing multi-part content of a message.
      "parts": [ # Ordered `Parts` that constitute a single message.
        { # Single part of content.
          "text": "A String", # Inline text.
        },
      ],
      "role": "A String", # Producer of the content. Must be either `user` or `model`. Intended to be used for multi-turn conversations. Otherwise, it can be left unset.
    },
  ],
  "generationSpec": { # Content generation specification. # Content generation specification.
    "frequencyPenalty": 3.14, # If specified, custom value for frequency penalty will be used.
    "languageCode": "A String", # Language code for content. Use language tags defined by [BCP47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt).
    "maxOutputTokens": 42, # If specified, custom value for max output tokens will be used.
    "modelId": "A String", # Specifies which Vertex model id to use for generation.
    "presencePenalty": 3.14, # If specified, custom value for presence penalty will be used.
    "seed": 42, # If specified, custom value for the seed will be used.
    "temperature": 3.14, # If specified, custom value for the temperature will be used.
    "topK": 42, # If specified, custom value for top-k sampling will be used.
    "topP": 3.14, # If specified, custom value for nucleus sampling will be used.
  },
  "groundingSpec": { # Grounding specification. # Grounding specification.
    "groundingSources": [ # Grounding sources.
      { # Grounding source.
        "googleSearchSource": { # Google Search config parameters. # If set, grounding is performed with Google Search.
          "dynamicRetrievalConfig": { # Describes the options to customize dynamic retrieval. # Optional. Specifies the dynamic retrieval configuration for the given source.
            "predictor": { # Describes the predictor settings for dynamic retrieval. # Specification for the predictor for dynamic retrieval.
              "threshold": 3.14, # The value of the threshold. If the predictor will predict a value smaller than this, it would suppress grounding in the source.
              "version": "A String", # The version of the predictor to be used in dynamic retrieval.
            },
          },
        },
        "inlineSource": { # Message to be used for grounding based on inline content. # If set, grounding is performed with inline content.
          "attributes": { # Attributes associated with the content. Common attributes include `source` (indicating where the content was sourced from) and `author` (indicating the author of the content).
            "a_key": "A String",
          },
          "groundingFacts": [ # List of facts to be used for grounding.
            { # Grounding Fact.
              "attributes": { # Attributes associated with the fact. Common attributes include `source` (indicating where the fact was sourced from), `author` (indicating the author of the fact), and so on.
                "a_key": "A String",
              },
              "factText": "A String", # Text content of the fact. Can be at most 10K characters long.
            },
          ],
        },
        "searchSource": { # Message to be used for grounding with Vertex AI Search. # If set, grounding is performed with Vertex AI Search.
          "filter": "A String", # Filter expression to be applied to the search. The syntax is the same as SearchRequest.filter.
          "maxResultCount": 42, # Number of search results to return. The default value is 10. The maximumm allowed value is 10.
          "safeSearch": True or False, # If set, safe search is enabled in Vertex AI Search requests.
          "servingConfig": "A String", # The resource name of the Engine to use. Format: `projects/{project}/locations/{location}/collections/{collection_id}/engines/{engine_id}/servingConfigs/{serving_config_id}`
        },
      },
    ],
  },
  "systemInstruction": { # Base structured datatype containing multi-part content of a message. # Content of the system instruction for the current API. These instructions will take priority over any other prompt instructions if the selected model is supporting them.
    "parts": [ # Ordered `Parts` that constitute a single message.
      { # Single part of content.
        "text": "A String", # Inline text.
      },
    ],
    "role": "A String", # Producer of the content. Must be either `user` or `model`. Intended to be used for multi-turn conversations. Otherwise, it can be left unset.
  },
  "userLabels": { # The user labels applied to a resource must meet the following requirements: * Each resource can have multiple labels, up to a maximum of 64. * Each label must be a key-value pair. * Keys have a minimum length of 1 character and a maximum length of 63 characters and cannot be empty. Values can be empty and have a maximum length of 63 characters. * Keys and values can contain only lowercase letters, numeric characters, underscores, and dashes. All characters must use UTF-8 encoding, and international characters are allowed. * The key portion of a label must be unique. However, you can use the same key with multiple resources. * Keys must start with a lowercase letter or international character. See [Google Cloud Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) for more details.
    "a_key": "A String",
  },
}

  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 `GenerateGroundedContent` method.
  "candidates": [ # Generated candidates.
    { # A response candidate generated from the model.
      "content": { # Base structured datatype containing multi-part content of a message. # Content of the candidate.
        "parts": [ # Ordered `Parts` that constitute a single message.
          { # Single part of content.
            "text": "A String", # Inline text.
          },
        ],
        "role": "A String", # Producer of the content. Must be either `user` or `model`. Intended to be used for multi-turn conversations. Otherwise, it can be left unset.
      },
      "groundingMetadata": { # Citation for the generated content. # Grounding metadata for the generated content.
        "groundingSupport": [ # GroundingSupport across all claims in the answer candidate. An support to a fact indicates that the claim is supported by the fact.
          { # Grounding info for a claim in the candidate and its support.
            "claimText": "A String", # Text for the claim in the candidate. Always provided when a support is found.
            "supportChunkIndices": [ # A list of indices (into 'support_chunks') specifying the citations associated with the claim. For instance [1,3,4] means that support_chunks[1], support_chunks[3], support_chunks[4] are the chunks attributed to the claim.
              42,
            ],
            "supportScore": 3.14, # A score in the range of [0, 1] describing how grounded is a specific claim in the support chunks indicated. Higher value means that the claim is better supported by the chunks.
          },
        ],
        "retrievalMetadata": [ # Retrieval metadata to provide an understanding in the retrieval steps performed by the model. There can be multiple such messages which can correspond to different parts of the retrieval. This is a mechanism used to ensure transparency to our users.
          { # Describes the metadata associated with a retrieval step.
            "dynamicRetrievalMetadata": { # Describes the metadata about dynamic retrieval. # Metadata for dynamic retrieval.
              "predictorMetadata": { # Describes the metadata about the dynamic retrieval predictor. # Metadata for the dynamic retrieval predictor.
                "prediction": 3.14, # The value of the predictor. This should be between [0, 1] where a value of 0 means that the query would not benefit from grounding, while a value of 1.0 means that the query would benefit the most. In between values allow to differentiate between different usefulness scores for grounding.
                "version": "A String", # The version of the predictor which was used in dynamic retrieval.
              },
            },
            "source": "A String", # Describes the source to which the metadata is referring to.
          },
        ],
        "searchEntryPoint": { # Google search entry point. # Google search entry for the following-up web searches.
          "renderedContent": "A String", # Web content snippet that can be embedded in a web page or an app webview.
          "sdkBlob": "A String", # Base64 encoded JSON representing array of tuple.
        },
        "supportChunks": [ # List of chunks to be attributed across all claims in the candidate. These are derived from the grounding sources supplied in the request.
          { # Fact Chunk.
            "chunkText": "A String", # Text content of the fact chunk. Can be at most 10K characters long.
            "index": 42, # The index of this chunk. Currently, only used for the streaming mode.
            "source": "A String", # Source from which this fact chunk was retrieved. If it was retrieved from the GroundingFacts provided in the request then this field will contain the index of the specific fact from which this chunk was retrieved.
            "sourceMetadata": { # More fine-grained information for the source reference.
              "a_key": "A String",
            },
          },
        ],
        "webSearchQueries": [ # Web search queries for the following-up web search.
          "A String",
        ],
      },
      "groundingScore": 3.14, # The overall grounding score for the candidate, in the range of [0, 1].
      "index": 42, # Index of the candidate.
    },
  ],
}