@@ -817,6 +817,11 @@ def if_(
817817 prompt : PROMPT_TYPE ,
818818 * ,
819819 connection_id : str | None = None ,
820+ endpoint : str | None = None ,
821+ optimization_mode : Literal [
822+ "minimize_cost" , "maximize_performance"
823+ ] = "minimize_cost" ,
824+ max_error_ratio : float = 1.0 ,
820825) -> series .Series :
821826 """
822827 Evaluates the prompt to True or False. Compared to `ai.generate_bool()`, this function
@@ -838,20 +843,26 @@ def if_(
838843 1 Illinois
839844 dtype: string
840845
841- .. note::
842-
843- This product or feature is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the
844- Service Specific Terms(https://cloud.google.com/terms/service-terms#1). Pre-GA products and features are available "as is"
845- and might have limited support. For more information, see the launch stage descriptions
846- (https://cloud.google.com/products#product-launch-stages).
847-
848846 Args:
849847 prompt (str | Series | List[str|Series] | Tuple[str|Series, ...]):
850848 A mixture of Series and string literals that specifies the prompt to send to the model. The Series can be BigFrames Series
851849 or pandas Series.
852850 connection_id (str, optional):
853851 Specifies the connection to use to communicate with the model. For example, `myproject.us.myconnection`.
854852 If not provided, the query uses your end-user credential.
853+ endpoint (str, optional):
854+ Specifies the Vertex AI endpoint to use for the model. For example `"gemini-2.5-flash"`. You can specify any
855+ generally available or preview Gemini model. If you specify the model name, BigQuery ML automatically identifies and
856+ uses the full endpoint of the model. If you don't specify an ENDPOINT value, BigQuery ML dynamically chooses a model based on your query to have the
857+ best cost to quality tradeoff for the task.
858+ optimization_mode (Literal["minimize_cost", "maximize_performance"]):
859+ Specifies the optimization strategy to use. Supported values are:
860+ * "minimize_cost" (default): uses a local, distilled model to process the majority of rows, reducing latency and cost.
861+ * "maximize_performance": always uses the remote LLM for inference.
862+ max_error_ratio (float):
863+ A float value between 0.0 and 1.0 that contains the maximum acceptable ratio of row-level inference failures to
864+ rows processed on this function. If this value is exceeded, then the query fails. The default value is 1.0.
865+ This argument isn't supported when `optimization_mode` is set to "minimize_cost".
855866
856867 Returns:
857868 bigframes.series.Series: A new series of bools.
@@ -863,6 +874,9 @@ def if_(
863874 operator = ai_ops .AIIf (
864875 prompt_context = tuple (prompt_context ),
865876 connection_id = connection_id ,
877+ endpoint = endpoint ,
878+ optimization_mode = optimization_mode ,
879+ max_error_ratio = max_error_ratio ,
866880 )
867881
868882 return series_list [0 ]._apply_nary_op (operator , series_list [1 :])
0 commit comments