google-cloud-agentplatform 1.165.1.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agentplatform/__init__.py +72 -0
- agentplatform/_genai/__init__.py +43 -0
- agentplatform/_genai/_agent_engines_utils.py +2341 -0
- agentplatform/_genai/_bigquery_utils.py +49 -0
- agentplatform/_genai/_datasets_utils.py +344 -0
- agentplatform/_genai/_evals_builtin_tools.py +209 -0
- agentplatform/_genai/_evals_common.py +4268 -0
- agentplatform/_genai/_evals_constant.py +122 -0
- agentplatform/_genai/_evals_data_converters.py +926 -0
- agentplatform/_genai/_evals_metric_handlers.py +1783 -0
- agentplatform/_genai/_evals_metric_loaders.py +401 -0
- agentplatform/_genai/_evals_utils.py +1043 -0
- agentplatform/_genai/_evals_visualization.py +2070 -0
- agentplatform/_genai/_gcs_utils.py +262 -0
- agentplatform/_genai/_logging_utils.py +47 -0
- agentplatform/_genai/_memory_bank_utils.py +206 -0
- agentplatform/_genai/_observability_data_converter.py +186 -0
- agentplatform/_genai/_operations_utils.py +94 -0
- agentplatform/_genai/_prompt_management_utils.py +147 -0
- agentplatform/_genai/_prompt_optimizer_utils.py +215 -0
- agentplatform/_genai/_skills_utils.py +69 -0
- agentplatform/_genai/_transformers.py +628 -0
- agentplatform/_genai/a2a_task_events.py +509 -0
- agentplatform/_genai/a2a_tasks.py +861 -0
- agentplatform/_genai/agent_engines.py +3931 -0
- agentplatform/_genai/client.py +519 -0
- agentplatform/_genai/datasets.py +3045 -0
- agentplatform/_genai/endpoints.py +1149 -0
- agentplatform/_genai/evals.py +6883 -0
- agentplatform/_genai/example_stores.py +1445 -0
- agentplatform/_genai/feedback_contexts.py +700 -0
- agentplatform/_genai/feedback_entries.py +1644 -0
- agentplatform/_genai/live.py +64 -0
- agentplatform/_genai/live_agent_engines.py +179 -0
- agentplatform/_genai/memories.py +2962 -0
- agentplatform/_genai/memory_banks.py +1927 -0
- agentplatform/_genai/memory_revisions.py +465 -0
- agentplatform/_genai/model_garden.py +2638 -0
- agentplatform/_genai/prompt_optimizer.py +995 -0
- agentplatform/_genai/prompts.py +4515 -0
- agentplatform/_genai/rag.py +4961 -0
- agentplatform/_genai/runtime_revisions.py +1257 -0
- agentplatform/_genai/runtimes.py +78 -0
- agentplatform/_genai/sandbox_snapshots.py +1015 -0
- agentplatform/_genai/sandbox_templates.py +1088 -0
- agentplatform/_genai/sandboxes.py +1604 -0
- agentplatform/_genai/session_events.py +543 -0
- agentplatform/_genai/sessions.py +1449 -0
- agentplatform/_genai/skill_revisions.py +377 -0
- agentplatform/_genai/skills.py +1708 -0
- agentplatform/_genai/types/__init__.py +4695 -0
- agentplatform/_genai/types/agent_engines.py +16 -0
- agentplatform/_genai/types/common.py +32784 -0
- agentplatform/_genai/types/evals.py +1031 -0
- agentplatform/_genai/types/prompt_optimizer.py +107 -0
- agentplatform/_genai/types/prompts.py +107 -0
- agentplatform/version.py +17 -0
- google_cloud_agentplatform-1.165.1.dev0.dist-info/METADATA +79 -0
- google_cloud_agentplatform-1.165.1.dev0.dist-info/RECORD +62 -0
- google_cloud_agentplatform-1.165.1.dev0.dist-info/WHEEL +5 -0
- google_cloud_agentplatform-1.165.1.dev0.dist-info/licenses/LICENSE +202 -0
- google_cloud_agentplatform-1.165.1.dev0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
# Copyright 2025 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
#
|
|
15
|
+
|
|
16
|
+
import asyncio
|
|
17
|
+
import importlib
|
|
18
|
+
import sys
|
|
19
|
+
from types import ModuleType, TracebackType
|
|
20
|
+
from typing import Optional, TYPE_CHECKING, Union
|
|
21
|
+
|
|
22
|
+
import google.auth
|
|
23
|
+
from agentplatform import __version__
|
|
24
|
+
from google.genai import _api_client as genai_api_client
|
|
25
|
+
from google.genai import _common
|
|
26
|
+
from google.genai import client as genai_client
|
|
27
|
+
from google.genai import types
|
|
28
|
+
from google.genai import version as genai_version
|
|
29
|
+
|
|
30
|
+
from . import live
|
|
31
|
+
|
|
32
|
+
if TYPE_CHECKING:
|
|
33
|
+
from agentplatform._genai import (
|
|
34
|
+
agent_engines as agent_engines_module,
|
|
35
|
+
)
|
|
36
|
+
from agentplatform._genai import datasets as datasets_module
|
|
37
|
+
from agentplatform._genai import evals as evals_module
|
|
38
|
+
from agentplatform._genai import (
|
|
39
|
+
prompt_optimizer as prompt_optimizer_module,
|
|
40
|
+
)
|
|
41
|
+
from agentplatform._genai import prompts as prompts_module
|
|
42
|
+
from agentplatform._genai import skills as skills_module
|
|
43
|
+
from agentplatform._genai import (
|
|
44
|
+
model_garden as model_garden_module,
|
|
45
|
+
)
|
|
46
|
+
from agentplatform._genai import live as live_module
|
|
47
|
+
from agentplatform._genai import rag as rag_module
|
|
48
|
+
from agentplatform._genai import (
|
|
49
|
+
feedback_entries as feedback_entries_module,
|
|
50
|
+
)
|
|
51
|
+
from agentplatform._genai import (
|
|
52
|
+
endpoints as endpoints_module,
|
|
53
|
+
)
|
|
54
|
+
from agentplatform._genai import (
|
|
55
|
+
example_stores as example_stores_module,
|
|
56
|
+
)
|
|
57
|
+
from agentplatform._genai import (
|
|
58
|
+
memory_banks as memory_banks_module,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
_GENAI_MODULES_TELEMETRY_HEADER = "vertex-genai-modules"
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _custom_append_library_version_headers(headers: dict[str, str]) -> None:
|
|
65
|
+
"""Overridde GenAI SDK header injection to use custom vertex-genai-modules header."""
|
|
66
|
+
genai_sdk_version = genai_version.__version__
|
|
67
|
+
module_version = __version__
|
|
68
|
+
python_version = sys.version.split()[0]
|
|
69
|
+
|
|
70
|
+
combined_label = f"google-genai-sdk/{genai_sdk_version}+{_GENAI_MODULES_TELEMETRY_HEADER}/{module_version}"
|
|
71
|
+
full_header = f"{combined_label} gl-python/{python_version}"
|
|
72
|
+
|
|
73
|
+
if "user-agent" not in headers or combined_label not in headers["user-agent"]:
|
|
74
|
+
headers["user-agent"] = f"{full_header} " + headers.get("user-agent", "")
|
|
75
|
+
headers["user-agent"] = headers["user-agent"].strip()
|
|
76
|
+
|
|
77
|
+
if (
|
|
78
|
+
"x-goog-api-client" not in headers
|
|
79
|
+
or combined_label not in headers["x-goog-api-client"]
|
|
80
|
+
):
|
|
81
|
+
headers["x-goog-api-client"] = f"{full_header} " + headers.get(
|
|
82
|
+
"x-goog-api-client", ""
|
|
83
|
+
)
|
|
84
|
+
headers["x-goog-api-client"] = headers["x-goog-api-client"].strip()
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
genai_api_client.append_library_version_headers = _custom_append_library_version_headers
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class AsyncClient:
|
|
91
|
+
"""Async Gen AI Client for the Vertex SDK."""
|
|
92
|
+
|
|
93
|
+
def __init__(self, api_client: genai_client.BaseApiClient): # type: ignore[name-defined]
|
|
94
|
+
self._api_client = api_client
|
|
95
|
+
self._live = live.AsyncLive(self._api_client)
|
|
96
|
+
self._evals: Optional[ModuleType] = None
|
|
97
|
+
self._agent_engines: Optional[ModuleType] = None
|
|
98
|
+
self._prompt_optimizer: Optional[ModuleType] = None
|
|
99
|
+
self._prompts: Optional[ModuleType] = None
|
|
100
|
+
self._datasets: Optional[ModuleType] = None
|
|
101
|
+
self._skills: Optional[ModuleType] = None
|
|
102
|
+
self._rag: Optional[ModuleType] = None
|
|
103
|
+
self._model_garden: Optional[ModuleType] = None
|
|
104
|
+
self._feedback_entries: Optional[ModuleType] = None
|
|
105
|
+
self._endpoints: Optional[ModuleType] = None
|
|
106
|
+
self._example_stores: Optional[ModuleType] = None
|
|
107
|
+
self._memory_banks: Optional[ModuleType] = None
|
|
108
|
+
|
|
109
|
+
@property
|
|
110
|
+
@_common.experimental_warning(
|
|
111
|
+
"The Vertex SDK GenAI live module is experimental, and may change in future "
|
|
112
|
+
"versions."
|
|
113
|
+
)
|
|
114
|
+
def live(self) -> "live_module.AsyncLive":
|
|
115
|
+
return self._live
|
|
116
|
+
|
|
117
|
+
@property
|
|
118
|
+
def evals(self) -> "evals_module.AsyncEvals":
|
|
119
|
+
if self._evals is None:
|
|
120
|
+
try:
|
|
121
|
+
# We need to lazy load the evals module to avoid ImportError when
|
|
122
|
+
# pandas/tqdm are not installed.
|
|
123
|
+
self._evals = importlib.import_module(".evals", __package__)
|
|
124
|
+
except ImportError as e:
|
|
125
|
+
raise ImportError(
|
|
126
|
+
"The 'evals' module requires 'pandas' and 'tqdm'. "
|
|
127
|
+
"Please install them using pip install "
|
|
128
|
+
"google-cloud-aiplatform[evaluation]"
|
|
129
|
+
) from e
|
|
130
|
+
return self._evals.AsyncEvals(self._api_client) # type: ignore[no-any-return]
|
|
131
|
+
|
|
132
|
+
@property
|
|
133
|
+
def prompt_optimizer(self) -> "prompt_optimizer_module.AsyncPromptOptimizer":
|
|
134
|
+
if self._prompt_optimizer is None:
|
|
135
|
+
self._prompt_optimizer = importlib.import_module(
|
|
136
|
+
".prompt_optimizer", __package__
|
|
137
|
+
)
|
|
138
|
+
return self._prompt_optimizer.AsyncPromptOptimizer(self._api_client) # type: ignore[no-any-return]
|
|
139
|
+
|
|
140
|
+
@property
|
|
141
|
+
def agent_engines(self) -> "agent_engines_module.AsyncAgentEngines":
|
|
142
|
+
if self._agent_engines is None:
|
|
143
|
+
try:
|
|
144
|
+
# We need to lazy load the agent_engines module to handle the
|
|
145
|
+
# possibility of ImportError when dependencies are not installed.
|
|
146
|
+
self._agent_engines = importlib.import_module(
|
|
147
|
+
".agent_engines",
|
|
148
|
+
__package__,
|
|
149
|
+
)
|
|
150
|
+
except ImportError as e:
|
|
151
|
+
raise ImportError(
|
|
152
|
+
"The 'agent_engines' module requires 'additional packages'. "
|
|
153
|
+
"Please install them using pip install "
|
|
154
|
+
"google-cloud-aiplatform[agent_engines]"
|
|
155
|
+
) from e
|
|
156
|
+
return self._agent_engines.AsyncAgentEngines(self._api_client) # type: ignore[no-any-return]
|
|
157
|
+
|
|
158
|
+
@property
|
|
159
|
+
def prompts(self) -> "prompts_module.AsyncPrompts":
|
|
160
|
+
if self._prompts is None:
|
|
161
|
+
self._prompts = importlib.import_module(
|
|
162
|
+
".prompts",
|
|
163
|
+
__package__,
|
|
164
|
+
)
|
|
165
|
+
return self._prompts.AsyncPrompts(self._api_client) # type: ignore[no-any-return]
|
|
166
|
+
|
|
167
|
+
@property
|
|
168
|
+
@_common.experimental_warning(
|
|
169
|
+
"The Vertex SDK GenAI async datasets module is experimental, "
|
|
170
|
+
"and may change in future versions."
|
|
171
|
+
)
|
|
172
|
+
def datasets(self) -> "datasets_module.AsyncDatasets":
|
|
173
|
+
if self._datasets is None:
|
|
174
|
+
self._datasets = importlib.import_module(
|
|
175
|
+
".datasets",
|
|
176
|
+
__package__,
|
|
177
|
+
)
|
|
178
|
+
return self._datasets.AsyncDatasets(self._api_client) # type: ignore[no-any-return]
|
|
179
|
+
|
|
180
|
+
@property
|
|
181
|
+
def skills(self) -> "skills_module.AsyncSkills":
|
|
182
|
+
if self._skills is None:
|
|
183
|
+
self._skills = importlib.import_module(
|
|
184
|
+
".skills",
|
|
185
|
+
__package__,
|
|
186
|
+
)
|
|
187
|
+
return self._skills.AsyncSkills(self._api_client) # type: ignore[no-any-return]
|
|
188
|
+
|
|
189
|
+
@property
|
|
190
|
+
def feedback_entries(self) -> "feedback_entries_module.AsyncFeedbackEntries":
|
|
191
|
+
if self._feedback_entries is None:
|
|
192
|
+
self._feedback_entries = importlib.import_module(
|
|
193
|
+
".feedback_entries",
|
|
194
|
+
__package__,
|
|
195
|
+
)
|
|
196
|
+
return self._feedback_entries.AsyncFeedbackEntries(self._api_client) # type: ignore[no-any-return]
|
|
197
|
+
|
|
198
|
+
@property
|
|
199
|
+
def endpoints(self) -> "endpoints_module.AsyncEndpoints":
|
|
200
|
+
if self._endpoints is None:
|
|
201
|
+
self._endpoints = importlib.import_module(
|
|
202
|
+
".endpoints",
|
|
203
|
+
__package__,
|
|
204
|
+
)
|
|
205
|
+
return self._endpoints.AsyncEndpoints(self._api_client) # type: ignore[no-any-return]
|
|
206
|
+
|
|
207
|
+
@property
|
|
208
|
+
def example_stores(self) -> "example_stores_module.AsyncExampleStores":
|
|
209
|
+
if self._example_stores is None:
|
|
210
|
+
self._example_stores = importlib.import_module(
|
|
211
|
+
".example_stores",
|
|
212
|
+
__package__,
|
|
213
|
+
)
|
|
214
|
+
return self._example_stores.AsyncExampleStores(self._api_client) # type: ignore[no-any-return]
|
|
215
|
+
|
|
216
|
+
@property
|
|
217
|
+
@_common.experimental_warning(
|
|
218
|
+
"The Vertex SDK GenAI async rag module is experimental, "
|
|
219
|
+
"and may change in future versions."
|
|
220
|
+
)
|
|
221
|
+
def rag(self) -> "rag_module.AsyncRag":
|
|
222
|
+
if self._rag is None:
|
|
223
|
+
self._rag = importlib.import_module(
|
|
224
|
+
".rag",
|
|
225
|
+
__package__,
|
|
226
|
+
)
|
|
227
|
+
return self._rag.AsyncRag(self._api_client) # type: ignore[no-any-return]
|
|
228
|
+
|
|
229
|
+
@property
|
|
230
|
+
@_common.experimental_warning(
|
|
231
|
+
"The Model Garden module is experimental, and may change in future " "versions."
|
|
232
|
+
)
|
|
233
|
+
def model_garden(self) -> "model_garden_module.AsyncModelGarden":
|
|
234
|
+
if self._model_garden is None:
|
|
235
|
+
self._model_garden = importlib.import_module(
|
|
236
|
+
".model_garden",
|
|
237
|
+
__package__,
|
|
238
|
+
)
|
|
239
|
+
return self._model_garden.AsyncModelGarden(self._api_client) # type: ignore[no-any-return]
|
|
240
|
+
|
|
241
|
+
@property
|
|
242
|
+
def memory_banks(self) -> "memory_banks_module.AsyncMemoryBanks":
|
|
243
|
+
if self._memory_banks is None:
|
|
244
|
+
self._memory_banks = importlib.import_module(".memory_banks", __package__)
|
|
245
|
+
return self._memory_banks.AsyncMemoryBanks(self._api_client) # type: ignore[no-any-return]
|
|
246
|
+
|
|
247
|
+
async def aclose(self) -> None:
|
|
248
|
+
"""Closes the async client explicitly.
|
|
249
|
+
|
|
250
|
+
Example usage:
|
|
251
|
+
|
|
252
|
+
from agentplatform import Client
|
|
253
|
+
|
|
254
|
+
async_client = agentplatform.Client(
|
|
255
|
+
project='my-project-id', location='us-central1'
|
|
256
|
+
).aio
|
|
257
|
+
prompt_1 = await async_client.prompts.create(...)
|
|
258
|
+
prompt_2 = await async_client.prompts.create(...)
|
|
259
|
+
# Close the client to release resources.
|
|
260
|
+
await async_client.aclose()
|
|
261
|
+
"""
|
|
262
|
+
await self._api_client.aclose()
|
|
263
|
+
|
|
264
|
+
async def __aenter__(self) -> "AsyncClient":
|
|
265
|
+
return self
|
|
266
|
+
|
|
267
|
+
async def __aexit__(
|
|
268
|
+
self,
|
|
269
|
+
exc_type: Optional[Exception],
|
|
270
|
+
exc_value: Optional[Exception],
|
|
271
|
+
traceback: Optional[TracebackType],
|
|
272
|
+
) -> None:
|
|
273
|
+
await self.aclose()
|
|
274
|
+
|
|
275
|
+
def __del__(self) -> None:
|
|
276
|
+
try:
|
|
277
|
+
asyncio.get_running_loop().create_task(self.aclose())
|
|
278
|
+
except Exception:
|
|
279
|
+
pass
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
class Client:
|
|
283
|
+
"""Gen AI Client for the Vertex SDK.
|
|
284
|
+
|
|
285
|
+
Use this client to interact with Vertex-specific Gemini features.
|
|
286
|
+
"""
|
|
287
|
+
|
|
288
|
+
def __init__(
|
|
289
|
+
self,
|
|
290
|
+
*,
|
|
291
|
+
api_key: Optional[str] = None,
|
|
292
|
+
credentials: Optional[google.auth.credentials.Credentials] = None,
|
|
293
|
+
project: Optional[str] = None,
|
|
294
|
+
location: Optional[str] = None,
|
|
295
|
+
debug_config: Optional[genai_client.DebugConfig] = None,
|
|
296
|
+
http_options: Optional[Union[types.HttpOptions, types.HttpOptionsDict]] = None,
|
|
297
|
+
):
|
|
298
|
+
"""Initializes the client.
|
|
299
|
+
|
|
300
|
+
Args:
|
|
301
|
+
api_key (str): The `API key
|
|
302
|
+
<https://cloud.google.com/vertex-ai/generative-ai/docs/start/express-mode/overview#api-keys>`_
|
|
303
|
+
to use for authentication. Applies to Vertex AI in express mode only.
|
|
304
|
+
credentials (google.auth.credentials.Credentials): The credentials to use
|
|
305
|
+
for authentication when calling the Vertex AI APIs. Credentials can be
|
|
306
|
+
obtained from environment variables and default credentials. For more
|
|
307
|
+
information, see `Set up Application Default Credentials
|
|
308
|
+
<https://cloud.google.com/docs/authentication/provide-credentials-adc>`_.
|
|
309
|
+
project (str): The `Google Cloud project ID
|
|
310
|
+
<https://cloud.google.com/vertex-ai/docs/start/cloud-environment>`_ to
|
|
311
|
+
use for quota. Can be obtained from environment variables (for example,
|
|
312
|
+
``GOOGLE_CLOUD_PROJECT``).
|
|
313
|
+
location (str): The `location
|
|
314
|
+
<https://cloud.google.com/vertex-ai/generative-ai/docs/learn/locations>`_
|
|
315
|
+
to send API requests to (for example, ``us-central1``). Can be obtained
|
|
316
|
+
from environment variables.
|
|
317
|
+
debug_config (DebugConfig): Config settings that control network behavior
|
|
318
|
+
of the client. This is typically used when running test code.
|
|
319
|
+
http_options (Union[HttpOptions, HttpOptionsDict]): Http options to use
|
|
320
|
+
for the client.
|
|
321
|
+
"""
|
|
322
|
+
|
|
323
|
+
self._debug_config = debug_config or genai_client.DebugConfig()
|
|
324
|
+
if isinstance(http_options, dict):
|
|
325
|
+
http_options = types.HttpOptions(**http_options)
|
|
326
|
+
if http_options is None:
|
|
327
|
+
http_options = types.HttpOptions()
|
|
328
|
+
if http_options.headers is None:
|
|
329
|
+
http_options.headers = {}
|
|
330
|
+
|
|
331
|
+
# Set the base URL for MREP locations.
|
|
332
|
+
if location in ["us", "eu"] and not http_options.base_url:
|
|
333
|
+
http_options.base_url = f"https://aiplatform.{location}.rep.googleapis.com/"
|
|
334
|
+
|
|
335
|
+
self._api_client = genai_client.Client._get_api_client(
|
|
336
|
+
vertexai=True,
|
|
337
|
+
api_key=api_key,
|
|
338
|
+
credentials=credentials,
|
|
339
|
+
project=project,
|
|
340
|
+
location=location,
|
|
341
|
+
debug_config=self._debug_config,
|
|
342
|
+
http_options=http_options,
|
|
343
|
+
)
|
|
344
|
+
self._aio = AsyncClient(self._api_client)
|
|
345
|
+
self._evals: Optional[ModuleType] = None
|
|
346
|
+
self._prompt_optimizer: Optional[ModuleType] = None
|
|
347
|
+
self._agent_engines: Optional[ModuleType] = None
|
|
348
|
+
self._prompts: Optional[ModuleType] = None
|
|
349
|
+
self._datasets: Optional[ModuleType] = None
|
|
350
|
+
self._skills: Optional[ModuleType] = None
|
|
351
|
+
self._rag: Optional[ModuleType] = None
|
|
352
|
+
self._model_garden: Optional[ModuleType] = None
|
|
353
|
+
self._feedback_entries: Optional[ModuleType] = None
|
|
354
|
+
self._endpoints: Optional[ModuleType] = None
|
|
355
|
+
self._example_stores: Optional[ModuleType] = None
|
|
356
|
+
self._memory_banks: Optional[ModuleType] = None
|
|
357
|
+
|
|
358
|
+
@property
|
|
359
|
+
def evals(self) -> "evals_module.Evals":
|
|
360
|
+
if self._evals is None:
|
|
361
|
+
try:
|
|
362
|
+
# We need to lazy load the evals module to avoid ImportError when
|
|
363
|
+
# pandas/tqdm are not installed.
|
|
364
|
+
self._evals = importlib.import_module(".evals", __package__)
|
|
365
|
+
except ImportError as e:
|
|
366
|
+
raise ImportError(
|
|
367
|
+
"The 'evals' module requires additional dependencies. "
|
|
368
|
+
"Please install them using pip install "
|
|
369
|
+
"google-cloud-aiplatform[evaluation]"
|
|
370
|
+
) from e
|
|
371
|
+
return self._evals.Evals(self._api_client) # type: ignore[no-any-return]
|
|
372
|
+
|
|
373
|
+
@property
|
|
374
|
+
def prompt_optimizer(self) -> "prompt_optimizer_module.PromptOptimizer":
|
|
375
|
+
if self._prompt_optimizer is None:
|
|
376
|
+
self._prompt_optimizer = importlib.import_module(
|
|
377
|
+
".prompt_optimizer", __package__
|
|
378
|
+
)
|
|
379
|
+
return self._prompt_optimizer.PromptOptimizer(self._api_client) # type: ignore[no-any-return]
|
|
380
|
+
|
|
381
|
+
@property
|
|
382
|
+
def aio(self) -> "AsyncClient":
|
|
383
|
+
return self._aio
|
|
384
|
+
|
|
385
|
+
# This is only used for replay tests
|
|
386
|
+
@staticmethod
|
|
387
|
+
def _get_api_client(
|
|
388
|
+
api_key: Optional[str] = None,
|
|
389
|
+
credentials: Optional[google.auth.credentials.Credentials] = None,
|
|
390
|
+
project: Optional[str] = None,
|
|
391
|
+
location: Optional[str] = None,
|
|
392
|
+
debug_config: Optional[genai_client.DebugConfig] = None,
|
|
393
|
+
http_options: Optional[types.HttpOptions] = None,
|
|
394
|
+
) -> Optional[genai_client.BaseApiClient]: # type: ignore[name-defined]
|
|
395
|
+
if debug_config and debug_config.client_mode in [
|
|
396
|
+
"record",
|
|
397
|
+
"replay",
|
|
398
|
+
"auto",
|
|
399
|
+
]:
|
|
400
|
+
return genai_client.ReplayApiClient( # type: ignore[attr-defined]
|
|
401
|
+
mode=debug_config.client_mode,
|
|
402
|
+
replay_id=debug_config.replay_id,
|
|
403
|
+
replays_directory=debug_config.replays_directory,
|
|
404
|
+
vertexai=True,
|
|
405
|
+
api_key=api_key,
|
|
406
|
+
credentials=credentials,
|
|
407
|
+
project=project,
|
|
408
|
+
location=location,
|
|
409
|
+
http_options=http_options,
|
|
410
|
+
)
|
|
411
|
+
return None
|
|
412
|
+
|
|
413
|
+
@property
|
|
414
|
+
def agent_engines(self) -> "agent_engines_module.AgentEngines":
|
|
415
|
+
if self._agent_engines is None:
|
|
416
|
+
try:
|
|
417
|
+
# We need to lazy load the agent_engines module to handle the
|
|
418
|
+
# possibility of ImportError when dependencies are not installed.
|
|
419
|
+
self._agent_engines = importlib.import_module(
|
|
420
|
+
".agent_engines",
|
|
421
|
+
__package__,
|
|
422
|
+
)
|
|
423
|
+
except ImportError as e:
|
|
424
|
+
raise ImportError(
|
|
425
|
+
"The 'agent_engines' module requires 'additional packages'. "
|
|
426
|
+
"Please install them using pip install "
|
|
427
|
+
"google-cloud-aiplatform[agent_engines]"
|
|
428
|
+
) from e
|
|
429
|
+
return self._agent_engines.AgentEngines(self._api_client) # type: ignore[no-any-return]
|
|
430
|
+
|
|
431
|
+
@property
|
|
432
|
+
def prompts(self) -> "prompts_module.Prompts":
|
|
433
|
+
if self._prompts is None:
|
|
434
|
+
# Lazy loading the prompts module
|
|
435
|
+
self._prompts = importlib.import_module(
|
|
436
|
+
".prompts",
|
|
437
|
+
__package__,
|
|
438
|
+
)
|
|
439
|
+
return self._prompts.Prompts(self._api_client) # type: ignore[no-any-return]
|
|
440
|
+
|
|
441
|
+
@property
|
|
442
|
+
@_common.experimental_warning(
|
|
443
|
+
"The Vertex SDK GenAI datasets module is experimental, "
|
|
444
|
+
"and may change in future versions."
|
|
445
|
+
)
|
|
446
|
+
def datasets(self) -> "datasets_module.Datasets":
|
|
447
|
+
if self._datasets is None:
|
|
448
|
+
self._datasets = importlib.import_module(
|
|
449
|
+
".datasets",
|
|
450
|
+
__package__,
|
|
451
|
+
)
|
|
452
|
+
return self._datasets.Datasets(self._api_client) # type: ignore[no-any-return]
|
|
453
|
+
|
|
454
|
+
@property
|
|
455
|
+
def skills(self) -> "skills_module.Skills":
|
|
456
|
+
if self._skills is None:
|
|
457
|
+
self._skills = importlib.import_module(
|
|
458
|
+
".skills",
|
|
459
|
+
__package__,
|
|
460
|
+
)
|
|
461
|
+
return self._skills.Skills(self._api_client) # type: ignore[no-any-return]
|
|
462
|
+
|
|
463
|
+
@property
|
|
464
|
+
def feedback_entries(self) -> "feedback_entries_module.FeedbackEntries":
|
|
465
|
+
if self._feedback_entries is None:
|
|
466
|
+
self._feedback_entries = importlib.import_module(
|
|
467
|
+
".feedback_entries",
|
|
468
|
+
__package__,
|
|
469
|
+
)
|
|
470
|
+
return self._feedback_entries.FeedbackEntries(self._api_client) # type: ignore[no-any-return]
|
|
471
|
+
|
|
472
|
+
@property
|
|
473
|
+
def endpoints(self) -> "endpoints_module.Endpoints":
|
|
474
|
+
if self._endpoints is None:
|
|
475
|
+
self._endpoints = importlib.import_module(
|
|
476
|
+
".endpoints",
|
|
477
|
+
__package__,
|
|
478
|
+
)
|
|
479
|
+
return self._endpoints.Endpoints(self._api_client) # type: ignore[no-any-return]
|
|
480
|
+
|
|
481
|
+
@property
|
|
482
|
+
def example_stores(self) -> "example_stores_module.ExampleStores":
|
|
483
|
+
if self._example_stores is None:
|
|
484
|
+
self._example_stores = importlib.import_module(
|
|
485
|
+
".example_stores",
|
|
486
|
+
__package__,
|
|
487
|
+
)
|
|
488
|
+
return self._example_stores.ExampleStores(self._api_client) # type: ignore[no-any-return]
|
|
489
|
+
|
|
490
|
+
@property
|
|
491
|
+
@_common.experimental_warning(
|
|
492
|
+
"The Vertex SDK GenAI rag module is experimental, "
|
|
493
|
+
"and may change in future versions."
|
|
494
|
+
)
|
|
495
|
+
def rag(self) -> "rag_module.Rag":
|
|
496
|
+
if self._rag is None:
|
|
497
|
+
self._rag = importlib.import_module(
|
|
498
|
+
".rag",
|
|
499
|
+
__package__,
|
|
500
|
+
)
|
|
501
|
+
return self._rag.Rag(self._api_client) # type: ignore[no-any-return]
|
|
502
|
+
|
|
503
|
+
@property
|
|
504
|
+
@_common.experimental_warning(
|
|
505
|
+
"The Model Garden module is experimental, and may change in future " "versions."
|
|
506
|
+
)
|
|
507
|
+
def model_garden(self) -> "model_garden_module.ModelGarden":
|
|
508
|
+
if self._model_garden is None:
|
|
509
|
+
self._model_garden = importlib.import_module(
|
|
510
|
+
".model_garden",
|
|
511
|
+
__package__,
|
|
512
|
+
)
|
|
513
|
+
return self._model_garden.ModelGarden(self._api_client) # type: ignore[no-any-return]
|
|
514
|
+
|
|
515
|
+
@property
|
|
516
|
+
def memory_banks(self) -> "memory_banks_module.MemoryBanks":
|
|
517
|
+
if self._memory_banks is None:
|
|
518
|
+
self._memory_banks = importlib.import_module(".memory_banks", __package__)
|
|
519
|
+
return self._memory_banks.MemoryBanks(self._api_client) # type: ignore[no-any-return]
|