-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: introduce ai operator namespace and deprecated semantics #1511
base: main
Are you sure you want to change the base?
Conversation
@@ -41,6 +42,20 @@ def semantic_operators(self, value: bool): | |||
warnings.warn(msg, category=bfe.PreviewWarning) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the experiment_options for semantic_operators
be marked as deprecated
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -84,6 +84,9 @@ class ComputeOptions: | |||
semantic_ops_confirmation_threshold: Optional[int] = 0 | |||
semantic_ops_threshold_autofail = False | |||
|
|||
ai_ops_confirmation_threshold: Optional[int] = 0 | |||
ai_ops_threshold_autofail = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also update the docstring as the semantic ops here. Also, mark semantic_ops as deprecated in the docstring too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
bigframes/operations/ai.py
Outdated
>>> import bigframes.pandas as bpd | ||
>>> bpd.options.display.progress_bar = None | ||
>>> bpd.options.experiments.semantic_operators = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the options should be updated into ai_operators
too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
bigframes/operations/ai.py
Outdated
bigframes.pandas.DataFrame: DataFrame filtered by the instruction. | ||
Raises: | ||
NotImplementedError: when the semantic operator experiment is off. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: ai operator experiment
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
bigframes/operations/ai.py
Outdated
score_column: Optional[str] = None, | ||
): | ||
""" | ||
Performs semantic search on the DataFrame. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe call it AI semantic search
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
THRESHOLD_OPTION, | ||
1, | ||
"compute.semantic_ops_threshold_autofail", | ||
True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be ai_ops_threshold_autofail
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Done
bigframes/dataframe.py
Outdated
@@ -4574,4 +4575,12 @@ def _throw_if_null_index(self, opname: str): | |||
|
|||
@property | |||
def semantics(self): | |||
warnings.warn( | |||
"The 'semantic' property will be removed. Please use 'ai' instead.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo.
"The 'semantic' property will be removed. Please use 'ai' instead.", | |
"The 'semantics' property will be removed. Please use 'ai' instead.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
return bigframes.operations.semantics.Semantics(self) | ||
|
||
@property | ||
def ai(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need a docstring? Also, please add the AI
class to the accessors section in the docs:
as well as thhe table of contents
- name: PlotAccessor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bigframes/operations/ai.py
Outdated
|
||
|
||
@log_adapter.class_logger | ||
class Ai: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Python style says this should be AI not Ai.
https://peps.python.org/pep-0008/#descriptive-naming-styles
When using acronyms in CapWords, capitalize all the letters of the acronym. Thus HTTPServerError is better than HttpServerError.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Don't merge this until #1531 is merged, and copy over the change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall with leaving few nit comments.
bigframes/_config/compute_options.py
Outdated
Guards against unexepcted processing of large amount of rows by semantic operators. | ||
semantic_ops_confirmation_threshold (int, optional): | ||
Semantics operators are deprecated. Please use AI operators instead. | ||
[Deprecated] Guards against unexepcted processing of large amount of rows by semantic operators. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo for unexepcted
.
Also use deprecated
doc format, similar to
https://cloud.google.com/python/docs/reference/bigframes/latest/bigframes._config.bigquery_options.BigQueryOptions#bigframes__config_bigquery_options_BigQueryOptions_use_regional_endpoints
.. deprecated:: 1.42.0
Guards against unexpected processing of large amount of rows by semantic operators.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
bigframes/dataframe.py
Outdated
@@ -4574,4 +4575,13 @@ def _throw_if_null_index(self, opname: str): | |||
|
|||
@property | |||
def semantics(self): | |||
warnings.warn( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please format the warning message as below:
msg = bfe.format_message("The 'semantics' property will be removed. Please use 'ai' instead.")
warnings.warn(msg, category=bfe.PreviewWarning)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tswast for suggestions too.
Should we use @typing_extensions.deprecated
as other LLM methods does?
@typing_extensions.deprecated
(
"PaLM2TextGenerator is going to be deprecated. Use GeminiTextGenerator instead. ",
category=exceptions.ApiDeprecationWarning,
)
bigframes/operations/ai.py
Outdated
|
||
|
||
@log_adapter.class_logger | ||
class AI: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed it as AIAccessor
to keep consistency with other accessors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Semantic operator contents are copied over except for aggregate and cluster_by