bigframes.bigquery.ai.generate_int#

bigframes.bigquery.ai.generate_int(prompt: str | Series | Series | List[str | Series | Series] | Tuple[str | Series | Series, ...], *, connection_id: str | None = None, endpoint: str | None = None, request_type: Literal['dedicated', 'shared', 'unspecified'] = 'unspecified', model_params: Mapping[Any, Any] | None = None) Series[source]#

Returns the AI analysis based on the prompt, which can be any combination of text and unstructured data.

Examples:

>>> import bigframes.pandas as bpd
>>> import bigframes.bigquery as bbq
>>> animal = bpd.Series(["Kangaroo", "Rabbit", "Spider"])
>>> bbq.ai.generate_int(("How many legs does a ", animal, " have?"))
0    {'result': 2, 'full_response': '{"candidates":...
1    {'result': 4, 'full_response': '{"candidates":...
2    {'result': 8, 'full_response': '{"candidates":...
dtype: struct<result: int64, full_response: extension<dbjson<JSONArrowType>>, status: string>[pyarrow]
>>> bbq.ai.generate_int(("How many legs does a ", animal, " have?")).struct.field("result")
0    2
1    4
2    8
Name: result, dtype: Int64

Note

This product or feature is subject to the “Pre-GA Offerings Terms” in the General Service Terms section of the Service Specific Terms(https://cloud.google.com/terms/service-terms#1). Pre-GA products and features are available “as is” and might have limited support. For more information, see the launch stage descriptions (https://cloud.google.com/products#product-launch-stages).

Parameters:
  • prompt (str | Series | List[str|Series] | Tuple[str|Series, ...]) – A mixture of Series and string literals that specifies the prompt to send to the model. The Series can be BigFrames Series or pandas Series.

  • connection_id (str, optional) – Specifies the connection to use to communicate with the model. For example, myproject.us.myconnection. If not provided, the query uses your end-user credential.

  • endpoint (str, optional) – Specifies the Vertex AI endpoint to use for the model. For example “gemini-2.5-flash”. You can specify any generally available or preview Gemini model. If you specify the model name, BigQuery ML automatically identifies and uses the full endpoint of the model. If you don’t specify an ENDPOINT value, BigQuery ML selects a recent stable version of Gemini to use.

  • request_type (Literal["dedicated", "shared", "unspecified"]) – Specifies the type of inference request to send to the Gemini model. The request type determines what quota the request uses. * “dedicated”: function only uses Provisioned Throughput quota. The function returns the error Provisioned throughput is not purchased or is not active if Provisioned Throughput quota isn’t available. * “shared”: the function only uses dynamic shared quota (DSQ), even if you have purchased Provisioned Throughput quota. * “unspecified”: If you haven’t purchased Provisioned Throughput quota, the function uses DSQ quota. If you have purchased Provisioned Throughput quota, the function uses the Provisioned Throughput quota first. If requests exceed the Provisioned Throughput quota, the overflow traffic uses DSQ quota.

  • model_params (Mapping[Any, Any]) – Provides additional parameters to the model. The MODEL_PARAMS value must conform to the generateContent request body format.

Returns:

A new struct Series with the result data. The struct contains these fields: * “result”: an integer (INT64) value containing the model’s response to the prompt. The result is None if the request fails or is filtered by responsible AI. * “full_response”: a JSON value containing the response from the projects.locations.endpoints.generateContent call to the model. The generated text is in the text element. * “status”: a STRING value that contains the API response status for the corresponding row. This value is empty if the operation was successful.

Return type:

bigframes.series.Series