| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -745,7 +745,7 @@ def if_( | |||
| 745 | 745 | or pandas Series. | |
| 746 | 746 | connection_id (str, optional): | |
| 747 | 747 | Specifies the connection to use to communicate with the model. For example, `myproject.us.myconnection`. | |
| 748 | - If not provided, the connection from the current session will be used. | ||
| 748 | + If not provided, the query uses your end-user credential. | ||
| 749 | 749 | ||
| 750 | 750 | Returns: | |
| 751 | 751 | bigframes.series.Series: A new series of bools. | |
@@ -756,7 +756,7 @@ def if_( | |||
| 756 | 756 | ||
| 757 | 757 | operator = ai_ops.AIIf( | |
| 758 | 758 | prompt_context=tuple(prompt_context), | |
| 759 | - connection_id=_resolve_connection_id(series_list[0], connection_id), | ||
| 759 | + connection_id=connection_id, | ||
| 760 | 760 | ) | |
| 761 | 761 | ||
| 762 | 762 | return series_list[0]._apply_nary_op(operator, series_list[1:]) | |
@@ -800,7 +800,7 @@ def classify( | |||
| 800 | 800 | Categories to classify the input into. | |
| 801 | 801 | connection_id (str, optional): | |
| 802 | 802 | Specifies the connection to use to communicate with the model. For example, `myproject.us.myconnection`. | |
| 803 | - If not provided, the connection from the current session will be used. | ||
| 803 | + If not provided, the query uses your end-user credential. | ||
| 804 | 804 | ||
| 805 | 805 | Returns: | |
| 806 | 806 | bigframes.series.Series: A new series of strings. | |
@@ -812,7 +812,7 @@ def classify( | |||
| 812 | 812 | operator = ai_ops.AIClassify( | |
| 813 | 813 | prompt_context=tuple(prompt_context), | |
| 814 | 814 | categories=tuple(categories), | |
| 815 | - connection_id=_resolve_connection_id(series_list[0], connection_id), | ||
| 815 | + connection_id=connection_id, | ||
| 816 | 816 | ) | |
| 817 | 817 | ||
| 818 | 818 | return series_list[0]._apply_nary_op(operator, series_list[1:]) | |
@@ -853,7 +853,7 @@ def score( | |||
| 853 | 853 | or pandas Series. | |
| 854 | 854 | connection_id (str, optional): | |
| 855 | 855 | Specifies the connection to use to communicate with the model. For example, `myproject.us.myconnection`. | |
| 856 | - If not provided, the connection from the current session will be used. | ||
| 856 | + If not provided, the query uses your end-user credential. | ||
| 857 | 857 | ||
| 858 | 858 | Returns: | |
| 859 | 859 | bigframes.series.Series: A new series of double (float) values. | |
@@ -864,7 +864,7 @@ def score( | |||
| 864 | 864 | ||
| 865 | 865 | operator = ai_ops.AIScore( | |
| 866 | 866 | prompt_context=tuple(prompt_context), | |
| 867 | - connection_id=_resolve_connection_id(series_list[0], connection_id), | ||
| 867 | + connection_id=connection_id, | ||
| 868 | 868 | ) | |
| 869 | 869 | ||
| 870 | 870 | return series_list[0]._apply_nary_op(operator, series_list[1:]) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -113,9 +113,9 @@ def _construct_named_args(op: ops.NaryOp) -> list[sge.Kwarg]: | |||
| 113 | 113 | ) | |
| 114 | 114 | ) | |
| 115 | 115 | ||
| 116 | - endpoit = op_args.get("endpoint", None) | ||
| 117 | - if endpoit is not None: | ||
| 118 | - args.append(sge.Kwarg(this="endpoint", expression=sge.Literal.string(endpoit))) | ||
| 116 | + endpoint = op_args.get("endpoint", None) | ||
| 117 | + if endpoint is not None: | ||
| 118 | + args.append(sge.Kwarg(this="endpoint", expression=sge.Literal.string(endpoint))) | ||
| 119 | 119 | ||
| 120 | 120 | request_type = op_args.get("request_type", None) | |
| 121 | 121 | if request_type is not None: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -123,7 +123,7 @@ class AIIf(base_ops.NaryOp): | |||
| 123 | 123 | name: ClassVar[str] = "ai_if" | |
| 124 | 124 | ||
| 125 | 125 | prompt_context: Tuple[str | None, ...] | |
| 126 | - connection_id: str | ||
| 126 | + connection_id: str | None | ||
| 127 | 127 | ||
| 128 | 128 | def output_type(self, *input_types: dtypes.ExpressionType) -> dtypes.ExpressionType: | |
| 129 | 129 | return dtypes.BOOL_DTYPE | |
@@ -135,7 +135,7 @@ class AIClassify(base_ops.NaryOp): | |||
| 135 | 135 | ||
| 136 | 136 | prompt_context: Tuple[str | None, ...] | |
| 137 | 137 | categories: tuple[str, ...] | |
| 138 | - connection_id: str | ||
| 138 | + connection_id: str | None | ||
| 139 | 139 | ||
| 140 | 140 | def output_type(self, *input_types: dtypes.ExpressionType) -> dtypes.ExpressionType: | |
| 141 | 141 | return dtypes.STRING_DTYPE | |
@@ -146,7 +146,7 @@ class AIScore(base_ops.NaryOp): | |||
| 146 | 146 | name: ClassVar[str] = "ai_score" | |
| 147 | 147 | ||
| 148 | 148 | prompt_context: Tuple[str | None, ...] | |
| 149 | - connection_id: str | ||
| 149 | + connection_id: str | None | ||
| 150 | 150 | ||
| 151 | 151 | def output_type(self, *input_types: dtypes.ExpressionType) -> dtypes.ExpressionType: | |
| 152 | 152 | return dtypes.FLOAT_DTYPE | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + SELECT | ||
| 2 | + AI.CLASSIFY(input => (`string_col`), categories => ['greeting', 'rejection']) AS `result` | ||
| 3 | + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + SELECT | ||
| 2 | + AI.IF(prompt => (`string_col`, ' is the same as ', `string_col`)) AS `result` | ||
| 3 | + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + SELECT | ||
| 2 | + AI.SCORE(prompt => (`string_col`, ' is the same as ', `string_col`)) AS `result` | ||
| 3 | + FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0` | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -281,12 +281,13 @@ def test_ai_generate_double_with_model_param( | |||
| 281 | 281 | snapshot.assert_match(sql, "out.sql") | |
| 282 | 282 | ||
| 283 | 283 | ||
| 284 | - def test_ai_if(scalar_types_df: dataframe.DataFrame, snapshot): | ||
| 284 | + @pytest.mark.parametrize("connection_id", [None, CONNECTION_ID]) | ||
| 285 | + def test_ai_if(scalar_types_df: dataframe.DataFrame, snapshot, connection_id): | ||
| 285 | 286 | col_name = "string_col" | |
| 286 | 287 | ||
| 287 | 288 | op = ops.AIIf( | |
| 288 | 289 | prompt_context=(None, " is the same as ", None), | |
| 289 | - connection_id=CONNECTION_ID, | ||
| 290 | + connection_id=connection_id, | ||
| 290 | 291 | ) | |
| 291 | 292 | ||
| 292 | 293 | sql = utils._apply_ops_to_sql( | |
@@ -296,26 +297,28 @@ def test_ai_if(scalar_types_df: dataframe.DataFrame, snapshot): | |||
| 296 | 297 | snapshot.assert_match(sql, "out.sql") | |
| 297 | 298 | ||
| 298 | 299 | ||
| 299 | - def test_ai_classify(scalar_types_df: dataframe.DataFrame, snapshot): | ||
| 300 | + @pytest.mark.parametrize("connection_id", [None, CONNECTION_ID]) | ||
| 301 | + def test_ai_classify(scalar_types_df: dataframe.DataFrame, snapshot, connection_id): | ||
| 300 | 302 | col_name = "string_col" | |
| 301 | 303 | ||
| 302 | 304 | op = ops.AIClassify( | |
| 303 | 305 | prompt_context=(None,), | |
| 304 | 306 | categories=("greeting", "rejection"), | |
| 305 | - connection_id=CONNECTION_ID, | ||
| 307 | + connection_id=connection_id, | ||
| 306 | 308 | ) | |
| 307 | 309 | ||
| 308 | 310 | sql = utils._apply_ops_to_sql(scalar_types_df, [op.as_expr(col_name)], ["result"]) | |
| 309 | 311 | ||
| 310 | 312 | snapshot.assert_match(sql, "out.sql") | |
| 311 | 313 | ||
| 312 | 314 | ||
| 313 | - def test_ai_score(scalar_types_df: dataframe.DataFrame, snapshot): | ||
| 315 | + @pytest.mark.parametrize("connection_id", [None, CONNECTION_ID]) | ||
| 316 | + def test_ai_score(scalar_types_df: dataframe.DataFrame, snapshot, connection_id): | ||
| 314 | 317 | col_name = "string_col" | |
| 315 | 318 | ||
| 316 | 319 | op = ops.AIScore( | |
| 317 | 320 | prompt_context=(None, " is the same as ", None), | |
| 318 | - connection_id=CONNECTION_ID, | ||
| 321 | + connection_id=connection_id, | ||
| 319 | 322 | ) | |
| 320 | 323 | ||
| 321 | 324 | sql = utils._apply_ops_to_sql( | |
| Back | FazBrowse Home | New Git URL |
0 commit comments