Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions agentplatform/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@
"""The agentplatform module."""

import importlib
import sys

from google.cloud.aiplatform import init
from google.cloud.aiplatform import version as aiplatform_version

__version__ = aiplatform_version.__version__

_genai_client = None
_genai_types = None


def __getattr__(name): # type: ignore[no-untyped-def]
if name == "preview":
Expand All @@ -30,10 +35,26 @@ def __getattr__(name): # type: ignore[no-untyped-def]
# `import google.cloud.aiplatform.agentplatform.preview as`
# `agentplatform_preview`
return importlib.import_module(".preview", __name__)
if name == "Client":
global _genai_client
if _genai_client is None:
_genai_client = importlib.import_module("._genai.client", __name__)
return getattr(_genai_client, name)

if name == "types":
global _genai_types
if _genai_types is None:
_genai_types = importlib.import_module("._genai.types", __name__)
if "vertexai.types" not in sys.modules:
sys.modules["vertexai.types"] = _genai_types
return _genai_types

raise AttributeError(f"module '{__name__}' has no attribute '{name}'")


__all__ = [
"init",
"preview",
"Client",
"types",
]
43 changes: 43 additions & 0 deletions agentplatform/_genai/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""The agentplatform module."""

import importlib

from .client import Client

_evals = None


def __getattr__(name): # type: ignore[no-untyped-def]
if name == "evals":
global _evals
if _evals is None:
try:
_evals = importlib.import_module(".evals", __package__)
except ImportError as e:
raise ImportError(
"The 'evals' module requires additional dependencies. "
"Please install them using pip install "
"google-cloud-aiplatform[evaluation]"
) from e
return _evals
raise AttributeError(f"module '{__name__}' has no attribute '{name}'")


__all__ = [
"Client",
"evals",
]
Loading
Loading