Skip to content

Commit bab5729

Browse files
xuanyang15copybara-github
authored andcommitted
chore: Migrate Google tools to use the new feature decorator
Co-authored-by: Xuan Yang <[email protected]> PiperOrigin-RevId: 842321126
1 parent 1ae944b commit bab5729

File tree

13 files changed

+86
-36
lines changed

13 files changed

+86
-36
lines changed

src/google/adk/features/_feature_registry.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,16 @@
2424
class FeatureName(str, Enum):
2525
"""Feature names."""
2626

27+
BIG_QUERY_TOOLSET = "BIG_QUERY_TOOLSET"
28+
BIG_QUERY_TOOL_CONFIG = "BIG_QUERY_TOOL_CONFIG"
29+
BIGTABLE_TOOL_SETTINGS = "BIGTABLE_TOOL_SETTINGS"
2730
COMPUTER_USE = "COMPUTER_USE"
31+
GOOGLE_CREDENTIALS_CONFIG = "GOOGLE_CREDENTIALS_CONFIG"
32+
GOOGLE_TOOL = "GOOGLE_TOOL"
2833
JSON_SCHEMA_FOR_FUNC_DECL = "JSON_SCHEMA_FOR_FUNC_DECL"
2934
PROGRESSIVE_SSE_STREAMING = "PROGRESSIVE_SSE_STREAMING"
35+
SPANNER_TOOLSET = "SPANNER_TOOLSET"
36+
SPANNER_TOOL_SETTINGS = "SPANNER_TOOL_SETTINGS"
3037

3138

3239
class FeatureStage(Enum):
@@ -59,15 +66,36 @@ class FeatureConfig:
5966

6067
# Central registry: FeatureName -> FeatureConfig
6168
_FEATURE_REGISTRY: dict[FeatureName, FeatureConfig] = {
69+
FeatureName.BIG_QUERY_TOOLSET: FeatureConfig(
70+
FeatureStage.EXPERIMENTAL, default_on=True
71+
),
72+
FeatureName.BIG_QUERY_TOOL_CONFIG: FeatureConfig(
73+
FeatureStage.EXPERIMENTAL, default_on=True
74+
),
75+
FeatureName.BIGTABLE_TOOL_SETTINGS: FeatureConfig(
76+
FeatureStage.EXPERIMENTAL, default_on=True
77+
),
6278
FeatureName.COMPUTER_USE: FeatureConfig(
6379
FeatureStage.EXPERIMENTAL, default_on=True
6480
),
81+
FeatureName.GOOGLE_CREDENTIALS_CONFIG: FeatureConfig(
82+
FeatureStage.EXPERIMENTAL, default_on=True
83+
),
84+
FeatureName.GOOGLE_TOOL: FeatureConfig(
85+
FeatureStage.EXPERIMENTAL, default_on=True
86+
),
6587
FeatureName.JSON_SCHEMA_FOR_FUNC_DECL: FeatureConfig(
6688
FeatureStage.WIP, default_on=False
6789
),
6890
FeatureName.PROGRESSIVE_SSE_STREAMING: FeatureConfig(
6991
FeatureStage.WIP, default_on=False
7092
),
93+
FeatureName.SPANNER_TOOLSET: FeatureConfig(
94+
FeatureStage.EXPERIMENTAL, default_on=True
95+
),
96+
FeatureName.SPANNER_TOOL_SETTINGS: FeatureConfig(
97+
FeatureStage.EXPERIMENTAL, default_on=True
98+
),
7199
}
72100

73101
# Track which experimental features have already warned (warn only once)

src/google/adk/tools/_google_credentials.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@
3333
from ..auth.auth_credential import AuthCredentialTypes
3434
from ..auth.auth_credential import OAuth2Auth
3535
from ..auth.auth_tool import AuthConfig
36-
from ..utils.feature_decorator import experimental
36+
from ..features import experimental
37+
from ..features import FeatureName
3738
from .tool_context import ToolContext
3839

3940

40-
@experimental
41+
@experimental(FeatureName.GOOGLE_CREDENTIALS_CONFIG)
4142
class BaseGoogleCredentialsConfig(BaseModel):
4243
"""Base Google Credentials Configuration for Google API tools (Experimental).
4344

src/google/adk/tools/bigquery/bigquery_credentials.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414

1515
from __future__ import annotations
1616

17-
from ...utils.feature_decorator import experimental
17+
from ...features import experimental
18+
from ...features import FeatureName
1819
from .._google_credentials import BaseGoogleCredentialsConfig
1920

2021
BIGQUERY_TOKEN_CACHE_KEY = "bigquery_token_cache"
2122
BIGQUERY_DEFAULT_SCOPE = ["https://www.googleapis.com/auth/bigquery"]
2223

2324

24-
@experimental
25+
@experimental(FeatureName.GOOGLE_CREDENTIALS_CONFIG)
2526
class BigQueryCredentialsConfig(BaseGoogleCredentialsConfig):
2627
"""BigQuery Credentials Configuration for Google API tools (Experimental).
2728

src/google/adk/tools/bigquery/bigquery_toolset.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,17 @@
2424
from . import data_insights_tool
2525
from . import metadata_tool
2626
from . import query_tool
27+
from ...features import experimental
28+
from ...features import FeatureName
2729
from ...tools.base_tool import BaseTool
2830
from ...tools.base_toolset import BaseToolset
2931
from ...tools.base_toolset import ToolPredicate
3032
from ...tools.google_tool import GoogleTool
31-
from ...utils.feature_decorator import experimental
3233
from .bigquery_credentials import BigQueryCredentialsConfig
3334
from .config import BigQueryToolConfig
3435

3536

36-
@experimental
37+
@experimental(FeatureName.BIG_QUERY_TOOLSET)
3738
class BigQueryToolset(BaseToolset):
3839
"""BigQuery Toolset contains tools for interacting with BigQuery data and metadata."""
3940

src/google/adk/tools/bigquery/config.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
from pydantic import ConfigDict
2222
from pydantic import field_validator
2323

24-
from ...utils.feature_decorator import experimental
24+
from ...features import experimental
25+
from ...features import FeatureName
2526

2627

2728
class WriteMode(Enum):
@@ -47,7 +48,7 @@ class WriteMode(Enum):
4748
"""All write operations are allowed."""
4849

4950

50-
@experimental('Config defaults may have breaking change in the future.')
51+
@experimental(FeatureName.BIG_QUERY_TOOL_CONFIG)
5152
class BigQueryToolConfig(BaseModel):
5253
"""Configuration for BigQuery tools."""
5354

src/google/adk/tools/bigtable/bigtable_credentials.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515
from __future__ import annotations
1616

17-
from ...utils.feature_decorator import experimental
17+
from ...features import experimental
18+
from ...features import FeatureName
1819
from .._google_credentials import BaseGoogleCredentialsConfig
1920

2021
BIGTABLE_TOKEN_CACHE_KEY = "bigtable_token_cache"
@@ -24,7 +25,7 @@
2425
]
2526

2627

27-
@experimental
28+
@experimental(FeatureName.GOOGLE_CREDENTIALS_CONFIG)
2829
class BigtableCredentialsConfig(BaseGoogleCredentialsConfig):
2930
"""Bigtable Credentials Configuration for Google API tools (Experimental).
3031

src/google/adk/tools/bigtable/settings.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616

1717
from pydantic import BaseModel
1818

19-
from ...utils.feature_decorator import experimental
19+
from ...features import experimental
20+
from ...features import FeatureName
2021

2122

22-
@experimental('Tool settings defaults may have breaking change in the future.')
23+
@experimental(FeatureName.BIGTABLE_TOOL_SETTINGS)
2324
class BigtableToolSettings(BaseModel):
2425
"""Settings for Bigtable tools."""
2526

src/google/adk/tools/google_tool.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@
2323
from pydantic import BaseModel
2424
from typing_extensions import override
2525

26-
from ..utils.feature_decorator import experimental
26+
from ..features import experimental
27+
from ..features import FeatureName
2728
from ._google_credentials import BaseGoogleCredentialsConfig
2829
from ._google_credentials import GoogleCredentialsManager
2930
from .function_tool import FunctionTool
3031
from .tool_context import ToolContext
3132

3233

33-
@experimental
34+
@experimental(FeatureName.GOOGLE_TOOL)
3435
class GoogleTool(FunctionTool):
3536
"""GoogleTool class for tools that call Google APIs.
3637

src/google/adk/tools/spanner/settings.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
from pydantic import BaseModel
2323
from pydantic import model_validator
2424

25-
from ...utils.feature_decorator import experimental
25+
from ...features import experimental
26+
from ...features import FeatureName
2627

2728
# Vector similarity search nearest neighbors search algorithms.
2829
EXACT_NEAREST_NEIGHBORS = "EXACT_NEAREST_NEIGHBORS"
@@ -138,7 +139,7 @@ def __post_init__(self):
138139
return self
139140

140141

141-
@experimental("Tool settings defaults may have breaking change in the future.")
142+
@experimental(FeatureName.SPANNER_TOOL_SETTINGS)
142143
class SpannerToolSettings(BaseModel):
143144
"""Settings for Spanner tools."""
144145

src/google/adk/tools/spanner/spanner_credentials.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515
from __future__ import annotations
1616

17-
from ...utils.feature_decorator import experimental
17+
from ...features import experimental
18+
from ...features import FeatureName
1819
from .._google_credentials import BaseGoogleCredentialsConfig
1920

2021
SPANNER_TOKEN_CACHE_KEY = "spanner_token_cache"
@@ -24,7 +25,7 @@
2425
]
2526

2627

27-
@experimental
28+
@experimental(FeatureName.GOOGLE_CREDENTIALS_CONFIG)
2829
class SpannerCredentialsConfig(BaseGoogleCredentialsConfig):
2930
"""Spanner Credentials Configuration for Google API tools (Experimental).
3031

0 commit comments

Comments
 (0)