google-cloud-agentplatform 2.1.0__tar.gz → 2.2.0__tar.gz

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.
Files changed (73) hide show
  1. {google_cloud_agentplatform-2.1.0/google_cloud_agentplatform.egg-info → google_cloud_agentplatform-2.2.0}/PKG-INFO +1 -1
  2. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/__init__.py +11 -2
  3. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/_evals_common.py +23 -30
  4. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/_gcs_utils.py +12 -2
  5. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/evals.py +14 -0
  6. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/sandboxes.py +63 -13
  7. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/types/common.py +69 -25
  8. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/version.py +1 -1
  9. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0/google_cloud_agentplatform.egg-info}/PKG-INFO +1 -1
  10. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/LICENSE +0 -0
  11. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/README.md +0 -0
  12. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/__init__.py +0 -0
  13. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/_bigquery_utils.py +0 -0
  14. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/_datasets_utils.py +0 -0
  15. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/_evals_builtin_tools.py +0 -0
  16. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/_evals_constant.py +0 -0
  17. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/_evals_data_converters.py +0 -0
  18. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/_evals_metric_handlers.py +0 -0
  19. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/_evals_metric_loaders.py +0 -0
  20. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/_evals_utils.py +0 -0
  21. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/_evals_visualization.py +0 -0
  22. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/_logging_utils.py +0 -0
  23. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/_memory_bank_utils.py +0 -0
  24. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/_observability_data_converter.py +0 -0
  25. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/_operations_utils.py +0 -0
  26. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/_prompt_management_utils.py +0 -0
  27. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/_prompt_optimizer_utils.py +0 -0
  28. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/_runtimes_utils.py +0 -0
  29. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/_skills_utils.py +0 -0
  30. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/_transformers.py +0 -0
  31. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/a2a_task_events.py +0 -0
  32. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/a2a_tasks.py +0 -0
  33. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/client.py +0 -0
  34. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/datasets.py +0 -0
  35. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/endpoints.py +0 -0
  36. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/example_stores.py +0 -0
  37. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/feedback_contexts.py +0 -0
  38. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/feedback_entries.py +0 -0
  39. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/live.py +0 -0
  40. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/live_runtimes.py +0 -0
  41. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/memories.py +0 -0
  42. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/memory_banks.py +0 -0
  43. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/memory_revisions.py +0 -0
  44. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/model_garden.py +0 -0
  45. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/prompt_optimizer.py +0 -0
  46. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/prompts.py +0 -0
  47. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/rag.py +0 -0
  48. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/runtime_revisions.py +0 -0
  49. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/runtimes.py +0 -0
  50. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/sandbox_snapshots.py +0 -0
  51. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/sandbox_templates.py +0 -0
  52. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/session_events.py +0 -0
  53. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/sessions.py +0 -0
  54. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/skill_revisions.py +0 -0
  55. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/skills.py +0 -0
  56. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/types/__init__.py +0 -0
  57. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/types/agent_engines.py +0 -0
  58. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/types/evals.py +0 -0
  59. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/types/prompt_optimizer.py +0 -0
  60. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/_genai/types/prompts.py +0 -0
  61. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/frameworks/__init__.py +0 -0
  62. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/frameworks/a2a.py +0 -0
  63. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/frameworks/adk.py +0 -0
  64. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/frameworks/ag2.py +0 -0
  65. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/frameworks/langchain.py +0 -0
  66. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/frameworks/langgraph.py +0 -0
  67. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/agentplatform/frameworks/llama_index.py +0 -0
  68. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/google_cloud_agentplatform.egg-info/SOURCES.txt +0 -0
  69. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/google_cloud_agentplatform.egg-info/dependency_links.txt +0 -0
  70. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/google_cloud_agentplatform.egg-info/requires.txt +0 -0
  71. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/google_cloud_agentplatform.egg-info/top_level.txt +0 -0
  72. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/pyproject.toml +0 -0
  73. {google_cloud_agentplatform-2.1.0 → google_cloud_agentplatform-2.2.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: google-cloud-agentplatform
3
- Version: 2.1.0
3
+ Version: 2.2.0
4
4
  Summary: Google Cloud Agent Platform Client Library
5
5
  Author-email: Google LLC <googleapis-packages@google.com>
6
6
  License: Apache-2.0
@@ -54,8 +54,17 @@ def __getattr__(name): # type: ignore[no-untyped-def]
54
54
  global _genai_types
55
55
  if _genai_types is None:
56
56
  _genai_types = importlib.import_module("._genai.types", __name__)
57
- if "vertexai.types" not in sys.modules:
58
- sys.modules["vertexai.types"] = _genai_types
57
+ # `types` is an alias for `._genai.types` rather than a real submodule,
58
+ # so register it to keep
59
+ # `from agentplatform.types import TypeName`
60
+ # working without a prior attribute access. Spell it the google3 way:
61
+ # Copybara rewrites that prefix in both directions, and the external
62
+ # spelling fails its reversibility check. This key was `vertexai.types`,
63
+ # which both misnamed this package's own alias and shadowed the real
64
+ # `vertexai.types` module.
65
+ types_module_name = f"{__name__}.types"
66
+ if types_module_name not in sys.modules:
67
+ sys.modules[types_module_name] = _genai_types
59
68
  return _genai_types
60
69
 
61
70
  raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
@@ -15,7 +15,6 @@
15
15
  """Common utilities for evals."""
16
16
 
17
17
  import asyncio
18
- import base64
19
18
  import collections
20
19
  import concurrent.futures
21
20
  import contextlib
@@ -38,6 +37,11 @@ from google.genai._gaos.types.interactions import functioncallstep
38
37
  from google.genai._gaos.types.interactions import functionresultstep
39
38
  from google.genai._gaos.types.interactions import modeloutputstep
40
39
  from google.genai._gaos.types.interactions import userinputstep
40
+
41
+ try:
42
+ from google.genai._gaos.utils.serializers import ALLOW_UNKNOWN_UNION_VARIANTS
43
+ except (ImportError, AttributeError):
44
+ ALLOW_UNKNOWN_UNION_VARIANTS = "speakeasy_allow_unknown_union_variants"
41
45
  from google.genai.models import Models
42
46
  import pandas as pd
43
47
  from tqdm import tqdm
@@ -776,7 +780,16 @@ def _interaction_dict_to_agent_data(
776
780
  Returns:
777
781
  An AgentData object with one or more ConversationTurns.
778
782
  """
779
- typed_interaction = interaction_types.Interaction.model_validate(interaction)
783
+ # A server response, so unknown step types must degrade rather than raise.
784
+ # `Step` is an open discriminated union: parse_open_union only falls back to
785
+ # the Unknown variant when the validation context carries
786
+ # ALLOW_UNKNOWN_UNION_VARIANTS, and raises without it so that a
787
+ # user-constructed request payload surfaces its mistakes locally. This
788
+ # payload comes off the Interactions API, so it is on the tolerant side of
789
+ # that line. _interaction_steps_to_events already drops steps it cannot map.
790
+ typed_interaction = interaction_types.Interaction.model_validate(
791
+ interaction, context={ALLOW_UNKNOWN_UNION_VARIANTS: True}
792
+ )
780
793
  all_events = _interaction_steps_to_events(typed_interaction.steps or [])
781
794
 
782
795
  # Group events into turns. Each UserInputStep starts a new turn.
@@ -1690,8 +1703,12 @@ def _resolve_interactions_to_eval_cases(
1690
1703
  break
1691
1704
  interaction_dict = json.loads(response.body)
1692
1705
  try:
1706
+ # Also a server response -- see _interaction_dict_to_agent_data.
1707
+ # Without the context a single step type this client does not
1708
+ # know about raised, and the except below turned that into a
1709
+ # `break`, silently truncating the interaction history.
1693
1710
  typed_interaction = interaction_types.Interaction.model_validate(
1694
- interaction_dict
1711
+ interaction_dict, context={ALLOW_UNKNOWN_UNION_VARIANTS: True}
1695
1712
  )
1696
1713
  except Exception as e:
1697
1714
  logger.warning("Failed to validate interaction model: %s", e)
@@ -4078,32 +4095,6 @@ async def _convert_evaluation_run_results_async(
4078
4095
  return eval_result, eval_item_map
4079
4096
 
4080
4097
 
4081
- def _object_to_dict(obj: Any) -> Union[dict[str, Any], Any]:
4082
- """Converts an object to a dictionary."""
4083
- if obj is None:
4084
- return obj
4085
- if isinstance(obj, (int, float, str, bool)):
4086
- return obj
4087
- if isinstance(obj, datetime.datetime):
4088
- return obj.isoformat()
4089
- if isinstance(obj, bytes):
4090
- return base64.b64encode(obj).decode("utf-8")
4091
- if isinstance(obj, (list, tuple)):
4092
- return [_object_to_dict(item) for item in obj]
4093
- if isinstance(obj, dict):
4094
- return {k: _object_to_dict(v) for k, v in obj.items()}
4095
-
4096
- if not hasattr(obj, "__dict__"):
4097
- return obj # Not an object with attributes, return as is (e.g., set)
4098
-
4099
- result: dict[str, Any] = {}
4100
- for key, value in obj.__dict__.items():
4101
- if value is None:
4102
- continue
4103
- result[key] = _object_to_dict(value)
4104
- return result
4105
-
4106
-
4107
4098
  def _get_content(row: dict[str, Any], column: str) -> Optional[genai_types.Content]:
4108
4099
  if isinstance(row[column], str):
4109
4100
  return genai_types.Content(
@@ -4248,7 +4239,9 @@ def _create_evaluation_set_from_dataframe(
4248
4239
  eval_items = []
4249
4240
  for eval_item_request in eval_item_requests:
4250
4241
  gcs_uri = gcs_utils.upload_json_to_prefix(
4251
- data=_object_to_dict(eval_item_request),
4242
+ data=eval_item_request.model_dump(
4243
+ mode="json", by_alias=True, exclude_none=True
4244
+ ),
4252
4245
  gcs_dest_prefix=gcs_dest_prefix,
4253
4246
  filename_prefix="request",
4254
4247
  )
@@ -17,13 +17,15 @@ from importlib.metadata import version as get_version
17
17
  import io
18
18
  import json
19
19
  import logging
20
- from typing import Any, Union
20
+ from typing import Any, TYPE_CHECKING, Union
21
21
  import uuid
22
22
 
23
23
  from google.cloud import storage # type: ignore[attr-defined]
24
24
  from google.genai._api_client import BaseApiClient
25
25
  from packaging.version import Version
26
- import pandas as pd
26
+
27
+ if TYPE_CHECKING:
28
+ import pandas as pd
27
29
 
28
30
 
29
31
  logger = logging.getLogger(__name__)
@@ -211,6 +213,14 @@ class GcsUtils:
211
213
  self, gcs_filepath: str, file_type: str
212
214
  ) -> "pd.DataFrame":
213
215
  """Reads a file from Google Cloud Storage into a Pandas DataFrame."""
216
+ try:
217
+ import pandas as pd # pylint: disable=g-import-not-at-top
218
+ except ImportError as e:
219
+ raise ImportError(
220
+ "Reading a Cloud Storage file into a DataFrame requires 'pandas'. "
221
+ "Please install it using pip install "
222
+ "google-cloud-aiplatform[evaluation]"
223
+ ) from e
214
224
  file_contents = self.read_file_contents(gcs_filepath)
215
225
  if file_type == "csv":
216
226
  return pd.read_csv(io.StringIO(file_contents), encoding="utf-8")
@@ -215,6 +215,13 @@ def _CustomCodeExecutionSpec_from_vertex(
215
215
  getv(from_object, ["evaluation_function"]),
216
216
  )
217
217
 
218
+ if getv(from_object, ["codeExecutionRegion"]) is not None:
219
+ setv(
220
+ to_object,
221
+ ["code_execution_region"],
222
+ getv(from_object, ["codeExecutionRegion"]),
223
+ )
224
+
218
225
  return to_object
219
226
 
220
227
 
@@ -237,6 +244,13 @@ def _CustomCodeExecutionSpec_to_vertex(
237
244
  getv(from_object, ["remote_custom_function"]),
238
245
  )
239
246
 
247
+ if getv(from_object, ["code_execution_region"]) is not None:
248
+ setv(
249
+ to_object,
250
+ ["codeExecutionRegion"],
251
+ getv(from_object, ["code_execution_region"]),
252
+ )
253
+
240
254
  return to_object
241
255
 
242
256
 
@@ -26,7 +26,6 @@ from typing import Any, Iterator, Optional, Union
26
26
  from urllib.parse import urlencode
27
27
 
28
28
  from google import auth as google_auth
29
- from google import genai
30
29
  from google.auth.transport import requests as google_auth_requests
31
30
  from google.genai import _api_module
32
31
  from google.genai import _common
@@ -34,6 +33,7 @@ from google.genai import types as genai_types
34
33
  from google.genai._common import get_value_by_path as getv
35
34
  from google.genai._common import set_value_by_path as setv
36
35
  from google.genai.pagers import Pager
36
+ import requests
37
37
 
38
38
  from . import _runtimes_utils
39
39
  from . import types
@@ -1362,6 +1362,7 @@ class Sandboxes(_api_module.BaseModule):
1362
1362
  query_params: Optional[dict[str, object]] = None,
1363
1363
  headers: Optional[dict[str, str]] = None,
1364
1364
  request_dict: Optional[dict[str, object]] = None,
1365
+ psc_endpoint: Optional[str] = None,
1365
1366
  ) -> genai_types.HttpResponse:
1366
1367
  """Sends a command to the sandbox.
1367
1368
 
@@ -1382,6 +1383,16 @@ class Sandboxes(_api_module.BaseModule):
1382
1383
  Optional. The headers to include in the command.
1383
1384
  request_dict (dict[str, object]):
1384
1385
  Optional. The request body to include in the command.
1386
+ psc_endpoint (str):
1387
+ Optional. Host (RFC1918 IP or resolvable internal hostname) of the
1388
+ customer-side PSC endpoint forwarding rule that targets
1389
+ ``connection_info.service_attachment``. Needed for VPC-SC sandboxes
1390
+ (``ingressControlConfig.enablePrivateServiceConnect=true``) where
1391
+ ``connection_info.load_balancer_hostname`` and ``load_balancer_ip``
1392
+ are both unset because ingress goes through PSC in the customer's
1393
+ VPC rather than a Google-managed load balancer. When provided, it
1394
+ is used as the data-plane host in place of the load balancer
1395
+ address.
1385
1396
 
1386
1397
  Returns:
1387
1398
  genai_types.HttpResponse: The response from the sandbox.
@@ -1391,12 +1402,21 @@ class Sandboxes(_api_module.BaseModule):
1391
1402
  connection_info = sandbox_environment.connection_info
1392
1403
  if not connection_info:
1393
1404
  raise ValueError("Connection info is not available.")
1394
- if connection_info.load_balancer_hostname:
1405
+ if psc_endpoint:
1406
+ # VPC-SC path: caller has provisioned a PSC endpoint against
1407
+ # connection_info.service_attachment and passes its host here.
1408
+ endpoint = "https://" + psc_endpoint
1409
+ elif connection_info.load_balancer_hostname:
1395
1410
  endpoint = "https://" + connection_info.load_balancer_hostname
1396
1411
  elif connection_info.load_balancer_ip:
1397
1412
  endpoint = "http://" + connection_info.load_balancer_ip
1398
1413
  else:
1399
- raise ValueError("Load balancer hostname or ip is not available.")
1414
+ raise ValueError(
1415
+ "No data-plane endpoint available. Non-VPC-SC sandboxes populate"
1416
+ " connection_info.load_balancer_hostname; VPC-SC sandboxes require"
1417
+ " the caller to pass psc_endpoint (the host of the forwarding"
1418
+ " rule targeting connection_info.service_attachment)."
1419
+ )
1400
1420
 
1401
1421
  routing_token = connection_info.routing_token
1402
1422
  if not routing_token:
@@ -1408,15 +1428,27 @@ class Sandboxes(_api_module.BaseModule):
1408
1428
  headers["Authorization"] = f"Bearer {access_token}"
1409
1429
  headers["X-Sandbox-Routing-Token"] = routing_token
1410
1430
  headers["X-Sandbox-Port"] = port
1411
- endpoint = endpoint + path if path.startswith("/") else endpoint + "/" + path
1412
- http_options = genai_types.HttpOptions(headers=headers, base_url=endpoint)
1413
- http_client = genai.Client(vertexai=True, http_options=http_options)
1414
- # Full path is constructed in this function. The passed in path into request
1415
- # function will not be used.
1416
- response = http_client._api_client.request(http_method, path, request_dict)
1431
+ url = endpoint + path if path.startswith("/") else endpoint + "/" + path
1432
+ # The sandbox data plane authenticates via the Authorization,
1433
+ # X-Sandbox-Routing-Token and X-Sandbox-Port headers set above, not via
1434
+ # ADC. Routing this through genai.Client(vertexai=True) builds an
1435
+ # authorized session with no credentials, whose request() then fails with
1436
+ # "'NoneType' object has no attribute 'before_request'". Issue the request
1437
+ # directly instead, mirroring generate_access_token above which also talks
1438
+ # to a non-aiplatform endpoint with plain requests.
1439
+ body = None
1440
+ if request_dict:
1441
+ body = json.dumps(request_dict)
1442
+ headers.setdefault("Content-Type", "application/json")
1443
+ response = requests.request(
1444
+ http_method,
1445
+ url,
1446
+ headers=headers,
1447
+ data=body,
1448
+ )
1417
1449
  return genai_types.HttpResponse(
1418
- headers=response.headers,
1419
- body=response.body,
1450
+ headers=dict(response.headers),
1451
+ body=response.text,
1420
1452
  )
1421
1453
 
1422
1454
  def generate_browser_ws_headers(
@@ -1425,6 +1457,7 @@ class Sandboxes(_api_module.BaseModule):
1425
1457
  service_account_email: str,
1426
1458
  port: str = "8080",
1427
1459
  timeout: int = 3600,
1460
+ psc_endpoint: Optional[str] = None,
1428
1461
  ) -> tuple[str, dict[str, str]]:
1429
1462
  """Generates the websocket upgrade headers for the browser.
1430
1463
 
@@ -1438,6 +1471,15 @@ class Sandboxes(_api_module.BaseModule):
1438
1471
  Defaults to "8080". This should be one of the ports specified during template creation.
1439
1472
  timeout (int):
1440
1473
  Optional. The timeout in seconds for the token. Defaults to 3600.
1474
+ psc_endpoint (str):
1475
+ Optional. Host (RFC1918 IP or resolvable internal hostname) of the
1476
+ customer-side PSC endpoint forwarding rule that targets
1477
+ ``connection_info.service_attachment``. Needed for VPC-SC
1478
+ sandboxes; see ``send_command`` for details. When provided, it is
1479
+ used as the websocket host in place of the load balancer address,
1480
+ and is propagated to the internal ``send_command`` call that
1481
+ fetches the CDP endpoint.
1482
+
1441
1483
  Returns:
1442
1484
  tuple[str, dict[str, str]]: A tuple containing the websocket URL and
1443
1485
  the headers for websocket upgrade.
@@ -1446,12 +1488,19 @@ class Sandboxes(_api_module.BaseModule):
1446
1488
  raise ValueError("Connection info is not available.")
1447
1489
 
1448
1490
  connection_info = sandbox_environment.connection_info
1449
- if connection_info.load_balancer_hostname:
1491
+ if psc_endpoint:
1492
+ ws_base_url = "wss://" + psc_endpoint
1493
+ elif connection_info.load_balancer_hostname:
1450
1494
  ws_base_url = "wss://" + connection_info.load_balancer_hostname
1451
1495
  elif connection_info.load_balancer_ip:
1452
1496
  ws_base_url = "ws://" + connection_info.load_balancer_ip
1453
1497
  else:
1454
- raise ValueError("Load balancer hostname or ip is not available.")
1498
+ raise ValueError(
1499
+ "No data-plane endpoint available. Non-VPC-SC sandboxes populate"
1500
+ " connection_info.load_balancer_hostname; VPC-SC sandboxes require"
1501
+ " the caller to pass psc_endpoint (the host of the forwarding"
1502
+ " rule targeting connection_info.service_attachment)."
1503
+ )
1455
1504
 
1456
1505
  http_access_token = self.generate_access_token(service_account_email, timeout)
1457
1506
  response = self.send_command(
@@ -1460,6 +1509,7 @@ class Sandboxes(_api_module.BaseModule):
1460
1509
  sandbox_environment=sandbox_environment,
1461
1510
  port=port,
1462
1511
  path="/cdp_ws_endpoint",
1512
+ psc_endpoint=psc_endpoint,
1463
1513
  )
1464
1514
  if not response:
1465
1515
  raise ValueError("Failed to get the websocket endpoint.")
@@ -328,6 +328,8 @@ class SandboxState(_common.CaseInSensitiveEnum):
328
328
  """Sandbox runtime is pausing."""
329
329
  STATE_RESUMING = "STATE_RESUMING"
330
330
  """Sandbox runtime is resuming."""
331
+ STATE_STOPPING = "STATE_STOPPING"
332
+ """Sandbox runtime is stopping."""
331
333
 
332
334
 
333
335
  class Protocol(_common.CaseInSensitiveEnum):
@@ -1705,6 +1707,10 @@ class CustomCodeExecutionSpec(_common.BaseModel):
1705
1707
  Instance is the evaluation instance, any fields populated in the instance
1706
1708
  are available to the function as instance[field_name].""",
1707
1709
  )
1710
+ code_execution_region: Optional[str] = Field(
1711
+ default=None,
1712
+ description="""Optional. The region to use for code execution. If set, the Code Execution Sandbox will be invoked in the specified region regardless of the request's originating region. Must be a region where the Code Execution Sandbox is available. Supported regions: northamerica-northeast1, southamerica-east1, us-central1, us-east1, us-east4, us-west1, us-west4, europe-central2, europe-north1, europe-southwest1, europe-west1, europe-west2, europe-west3, europe-west4, europe-west6, europe-west8, europe-west9, me-west1, asia-east1, asia-east2, asia-northeast1, asia-northeast3, asia-south1, asia-south2, asia-southeast1, australia-southeast2. If unset, the request's originating region is used; requests from regions where the sandbox is unavailable will fail with UNIMPLEMENTED.""",
1713
+ )
1708
1714
 
1709
1715
 
1710
1716
  class CustomCodeExecutionSpecDict(TypedDict, total=False):
@@ -1724,6 +1730,9 @@ class CustomCodeExecutionSpecDict(TypedDict, total=False):
1724
1730
  Instance is the evaluation instance, any fields populated in the instance
1725
1731
  are available to the function as instance[field_name]."""
1726
1732
 
1733
+ code_execution_region: Optional[str]
1734
+ """Optional. The region to use for code execution. If set, the Code Execution Sandbox will be invoked in the specified region regardless of the request's originating region. Must be a region where the Code Execution Sandbox is available. Supported regions: northamerica-northeast1, southamerica-east1, us-central1, us-east1, us-east4, us-west1, us-west4, europe-central2, europe-north1, europe-southwest1, europe-west1, europe-west2, europe-west3, europe-west4, europe-west6, europe-west8, europe-west9, me-west1, asia-east1, asia-east2, asia-northeast1, asia-northeast3, asia-south1, asia-south2, asia-southeast1, australia-southeast2. If unset, the request's originating region is used; requests from regions where the sandbox is unavailable will fail with UNIMPLEMENTED."""
1735
+
1727
1736
 
1728
1737
  CustomCodeExecutionSpecOrDict = Union[
1729
1738
  CustomCodeExecutionSpec, CustomCodeExecutionSpecDict
@@ -6665,7 +6674,7 @@ class ReservationAffinity(_common.BaseModel):
6665
6674
  )
6666
6675
  values: Optional[list[str]] = Field(
6667
6676
  default=None,
6668
- description="""Optional. Corresponds to the label values of a reservation resource. This must be the full resource name of the reservation or reservation block.""",
6677
+ description="""Optional. Corresponds to the label values of a reservation resource. This must be the resource name of the reservation, reservation block, or reservation sub- block.""",
6669
6678
  )
6670
6679
 
6671
6680
 
@@ -6679,7 +6688,7 @@ class ReservationAffinityDict(TypedDict, total=False):
6679
6688
  """Required. Specifies the reservation affinity type."""
6680
6689
 
6681
6690
  values: Optional[list[str]]
6682
- """Optional. Corresponds to the label values of a reservation resource. This must be the full resource name of the reservation or reservation block."""
6691
+ """Optional. Corresponds to the label values of a reservation resource. This must be the resource name of the reservation, reservation block, or reservation sub- block."""
6683
6692
 
6684
6693
 
6685
6694
  ReservationAffinityOrDict = Union[ReservationAffinity, ReservationAffinityDict]
@@ -11538,6 +11547,9 @@ class Memory(_common.BaseModel):
11538
11547
  default=None,
11539
11548
  description="""Optional. Represents the structured content of the memory.""",
11540
11549
  )
11550
+ context: Optional[str] = Field(
11551
+ default=None, description="""Optional. Represents the context of the memory."""
11552
+ )
11541
11553
 
11542
11554
 
11543
11555
  class MemoryDict(TypedDict, total=False):
@@ -11594,6 +11606,9 @@ class MemoryDict(TypedDict, total=False):
11594
11606
  structured_content: Optional[MemoryStructuredContentDict]
11595
11607
  """Optional. Represents the structured content of the memory."""
11596
11608
 
11609
+ context: Optional[str]
11610
+ """Optional. Represents the context of the memory."""
11611
+
11597
11612
 
11598
11613
  MemoryOrDict = Union[Memory, MemoryDict]
11599
11614
 
@@ -13281,6 +13296,10 @@ class MemoryRevision(_common.BaseModel):
13281
13296
  default=None,
13282
13297
  description="""Output only. Represents the structured value of the memory at the time of revision creation.""",
13283
13298
  )
13299
+ context: Optional[str] = Field(
13300
+ default=None,
13301
+ description="""Output only. Represents the context of the Memory Revision. The context may include context from both the historical revisions and the extracted content.""",
13302
+ )
13284
13303
 
13285
13304
 
13286
13305
  class MemoryRevisionDict(TypedDict, total=False):
@@ -13307,6 +13326,9 @@ class MemoryRevisionDict(TypedDict, total=False):
13307
13326
  structured_data: Optional[dict[str, Any]]
13308
13327
  """Output only. Represents the structured value of the memory at the time of revision creation."""
13309
13328
 
13329
+ context: Optional[str]
13330
+ """Output only. Represents the context of the Memory Revision. The context may include context from both the historical revisions and the extracted content."""
13331
+
13310
13332
 
13311
13333
  MemoryRevisionOrDict = Union[MemoryRevision, MemoryRevisionDict]
13312
13334
 
@@ -16564,13 +16586,13 @@ SandboxEnvironmentSpecComputerUseEnvironmentOrDict = Union[
16564
16586
 
16565
16587
 
16566
16588
  class SandboxEnvironmentSpecShellEnvironment(_common.BaseModel):
16567
- """The shell environment with customized settings."""
16589
+ """The shell environment."""
16568
16590
 
16569
16591
  pass
16570
16592
 
16571
16593
 
16572
16594
  class SandboxEnvironmentSpecShellEnvironmentDict(TypedDict, total=False):
16573
- """The shell environment with customized settings."""
16595
+ """The shell environment."""
16574
16596
 
16575
16597
  pass
16576
16598
 
@@ -16590,7 +16612,12 @@ class SandboxEnvironmentSpec(_common.BaseModel):
16590
16612
  Field(default=None, description="""Optional. The computer use environment.""")
16591
16613
  )
16592
16614
  shell_environment: Optional[SandboxEnvironmentSpecShellEnvironment] = Field(
16593
- default=None, description="""Optional. The shell environment."""
16615
+ default=None,
16616
+ description="""Optional. The shell environment for executing shell commands and scripts.""",
16617
+ )
16618
+ use_gke_td: Optional[bool] = Field(
16619
+ default=None,
16620
+ description="""Optional. Immutable. Whether to provision the SandboxEnvironment via the GKE TD pool. Immutable.""",
16594
16621
  )
16595
16622
 
16596
16623
 
@@ -16606,7 +16633,10 @@ class SandboxEnvironmentSpecDict(TypedDict, total=False):
16606
16633
  """Optional. The computer use environment."""
16607
16634
 
16608
16635
  shell_environment: Optional[SandboxEnvironmentSpecShellEnvironmentDict]
16609
- """Optional. The shell environment."""
16636
+ """Optional. The shell environment for executing shell commands and scripts."""
16637
+
16638
+ use_gke_td: Optional[bool]
16639
+ """Optional. Immutable. Whether to provision the SandboxEnvironment via the GKE TD pool. Immutable."""
16610
16640
 
16611
16641
 
16612
16642
  SandboxEnvironmentSpecOrDict = Union[SandboxEnvironmentSpec, SandboxEnvironmentSpecDict]
@@ -17551,11 +17581,11 @@ class SandboxEnvironmentTemplateEgressControlConfigDnsPeeringConfig(_common.Base
17551
17581
  )
17552
17582
  target_network: Optional[str] = Field(
17553
17583
  default=None,
17554
- description="""Required. The VPC network name in the target_project where the DNS zone specified by 'domain' is visible.""",
17584
+ description="""Required. The VPC network name in the target_project where the DNS zone specified by `domain` is visible.""",
17555
17585
  )
17556
17586
  target_project: Optional[str] = Field(
17557
17587
  default=None,
17558
- description="""Required. The project ID hosting the Cloud DNS managed zone that contains the 'domain'. The Vertex AI Service Agent requires the dns.peer role on this project.""",
17588
+ description="""Required. The project ID hosting the Cloud DNS managed zone that contains the `domain`. The Vertex AI Service Agent requires the dns.peer role on this project.""",
17559
17589
  )
17560
17590
 
17561
17591
 
@@ -17568,10 +17598,10 @@ class SandboxEnvironmentTemplateEgressControlConfigDnsPeeringConfigDict(
17568
17598
  """Required. The DNS name suffix of the zone being peered to, e.g., "my-internal-domain.corp.". Must end with a dot."""
17569
17599
 
17570
17600
  target_network: Optional[str]
17571
- """Required. The VPC network name in the target_project where the DNS zone specified by 'domain' is visible."""
17601
+ """Required. The VPC network name in the target_project where the DNS zone specified by `domain` is visible."""
17572
17602
 
17573
17603
  target_project: Optional[str]
17574
- """Required. The project ID hosting the Cloud DNS managed zone that contains the 'domain'. The Vertex AI Service Agent requires the dns.peer role on this project."""
17604
+ """Required. The project ID hosting the Cloud DNS managed zone that contains the `domain`. The Vertex AI Service Agent requires the dns.peer role on this project."""
17575
17605
 
17576
17606
 
17577
17607
  SandboxEnvironmentTemplateEgressControlConfigDnsPeeringConfigOrDict = Union[
@@ -17586,10 +17616,6 @@ class SandboxEnvironmentTemplateEgressControlConfig(_common.BaseModel):
17586
17616
  internet_access: Optional[bool] = Field(
17587
17617
  default=None, description="""Optional. Whether to allow internet access."""
17588
17618
  )
17589
- customer_vpc_network: Optional[str] = Field(
17590
- default=None,
17591
- description="""Optional. The customer VPC network that sandbox egress is routed into.""",
17592
- )
17593
17619
  dns_peering_configs: Optional[
17594
17620
  list[SandboxEnvironmentTemplateEgressControlConfigDnsPeeringConfig]
17595
17621
  ] = Field(
@@ -17598,7 +17624,7 @@ class SandboxEnvironmentTemplateEgressControlConfig(_common.BaseModel):
17598
17624
  )
17599
17625
  network_attachment: Optional[str] = Field(
17600
17626
  default=None,
17601
- description="""Optional. The name of the customer VPC NetworkAttachment used to draw a PSC interface IP into the customer VPC for sandbox egress.""",
17627
+ description="""Optional. The name of the customer VPC `NetworkAttachment` used to draw a PSC interface IP into the customer VPC for sandbox egress.""",
17602
17628
  )
17603
17629
 
17604
17630
 
@@ -17608,16 +17634,13 @@ class SandboxEnvironmentTemplateEgressControlConfigDict(TypedDict, total=False):
17608
17634
  internet_access: Optional[bool]
17609
17635
  """Optional. Whether to allow internet access."""
17610
17636
 
17611
- customer_vpc_network: Optional[str]
17612
- """Optional. The customer VPC network that sandbox egress is routed into."""
17613
-
17614
17637
  dns_peering_configs: Optional[
17615
17638
  list[SandboxEnvironmentTemplateEgressControlConfigDnsPeeringConfigDict]
17616
17639
  ]
17617
17640
  """Optional. DNS peering configurations that allow sandbox egress to resolve customer-internal domains via the customer VPC."""
17618
17641
 
17619
17642
  network_attachment: Optional[str]
17620
- """Optional. The name of the customer VPC NetworkAttachment used to draw a PSC interface IP into the customer VPC for sandbox egress."""
17643
+ """Optional. The name of the customer VPC `NetworkAttachment` used to draw a PSC interface IP into the customer VPC for sandbox egress."""
17621
17644
 
17622
17645
 
17623
17646
  SandboxEnvironmentTemplateEgressControlConfigOrDict = Union[
@@ -17873,6 +17896,10 @@ class SandboxEnvironmentTemplate(_common.BaseModel):
17873
17896
  default=None,
17874
17897
  description="""Optional. The configuration for private ingress (PSC-E) of this template. When set, the sandbox router is exposed privately via a PSC service attachment so VPC-SC customers can connect from their VPC over a private endpoint instead of the public internet. The resulting service attachment is surfaced on `SandboxEnvironment.connection_info.service_attachment`. Only the PSC-E (service-attachment/ingress) portion of `PrivateServiceConnectConfig` applies here: `enable_private_service_connect` and `project_allowlist` (the consumer projects allowed to connect). The nested `psc_interface_config` (PSC-I / egress) is not used for sandbox ingress; sandbox egress is configured via `egress_control_config` instead.""",
17875
17898
  )
17899
+ use_gke_td: Optional[bool] = Field(
17900
+ default=None,
17901
+ description="""Optional. Immutable. Whether to provision the SandboxEnvironmentTemplate via the GKE TD pool.""",
17902
+ )
17876
17903
 
17877
17904
 
17878
17905
  class SandboxEnvironmentTemplateDict(TypedDict, total=False):
@@ -17909,6 +17936,9 @@ class SandboxEnvironmentTemplateDict(TypedDict, total=False):
17909
17936
  ingress_control_config: Optional[PrivateServiceConnectConfigDict]
17910
17937
  """Optional. The configuration for private ingress (PSC-E) of this template. When set, the sandbox router is exposed privately via a PSC service attachment so VPC-SC customers can connect from their VPC over a private endpoint instead of the public internet. The resulting service attachment is surfaced on `SandboxEnvironment.connection_info.service_attachment`. Only the PSC-E (service-attachment/ingress) portion of `PrivateServiceConnectConfig` applies here: `enable_private_service_connect` and `project_allowlist` (the consumer projects allowed to connect). The nested `psc_interface_config` (PSC-I / egress) is not used for sandbox ingress; sandbox egress is configured via `egress_control_config` instead."""
17911
17938
 
17939
+ use_gke_td: Optional[bool]
17940
+ """Optional. Immutable. Whether to provision the SandboxEnvironmentTemplate via the GKE TD pool."""
17941
+
17912
17942
 
17913
17943
  SandboxEnvironmentTemplateOrDict = Union[
17914
17944
  SandboxEnvironmentTemplate, SandboxEnvironmentTemplateDict
@@ -18340,6 +18370,10 @@ class SandboxEnvironmentSnapshot(_common.BaseModel):
18340
18370
  default=None,
18341
18371
  description="""Output only. The timestamp when this SandboxEnvironment was most recently updated.""",
18342
18372
  )
18373
+ use_gke_td: Optional[bool] = Field(
18374
+ default=None,
18375
+ description="""Output only. Whether the source SandboxEnvironment uses the GKE TD pool.""",
18376
+ )
18343
18377
 
18344
18378
 
18345
18379
  class SandboxEnvironmentSnapshotDict(TypedDict, total=False):
@@ -18379,6 +18413,9 @@ class SandboxEnvironmentSnapshotDict(TypedDict, total=False):
18379
18413
  update_time: Optional[datetime.datetime]
18380
18414
  """Output only. The timestamp when this SandboxEnvironment was most recently updated."""
18381
18415
 
18416
+ use_gke_td: Optional[bool]
18417
+ """Output only. Whether the source SandboxEnvironment uses the GKE TD pool."""
18418
+
18382
18419
 
18383
18420
  SandboxEnvironmentSnapshotOrDict = Union[
18384
18421
  SandboxEnvironmentSnapshot, SandboxEnvironmentSnapshotDict
@@ -20965,6 +21002,10 @@ class SchemaPromptSpecAppBuilderData(_common.BaseModel):
20965
21002
  description="""Linked resources attached to the application by the user.""",
20966
21003
  )
20967
21004
  )
21005
+ deployed_regions: Optional[list[str]] = Field(
21006
+ default=None,
21007
+ description="""Optional. The Cloud Run regions in which the application is currently deployed. Used to rediscover and redeploy the app in the regions it already runs in, which may differ from the prompt's location.""",
21008
+ )
20968
21009
 
20969
21010
 
20970
21011
  class SchemaPromptSpecAppBuilderDataDict(TypedDict, total=False):
@@ -20979,6 +21020,9 @@ class SchemaPromptSpecAppBuilderDataDict(TypedDict, total=False):
20979
21020
  linked_resources: Optional[list[SchemaPromptSpecAppBuilderDataLinkedResourceDict]]
20980
21021
  """Linked resources attached to the application by the user."""
20981
21022
 
21023
+ deployed_regions: Optional[list[str]]
21024
+ """Optional. The Cloud Run regions in which the application is currently deployed. Used to rediscover and redeploy the app in the regions it already runs in, which may differ from the prompt's location."""
21025
+
20982
21026
 
20983
21027
  SchemaPromptSpecAppBuilderDataOrDict = Union[
20984
21028
  SchemaPromptSpecAppBuilderData, SchemaPromptSpecAppBuilderDataDict
@@ -28666,11 +28710,11 @@ AudioTranscriptionWordInfoOrDict = Union[
28666
28710
 
28667
28711
 
28668
28712
  class AudioTranscription(_common.BaseModel):
28669
- """The transcription of an audio part. For multi-speaker audio, each speaker segment is a separate Part with its own AudioTranscription carrying the speaker_label."""
28713
+ """The transcription of an audio part. For multi-speaker audio, each speaker segment is a separate `Part` with its own `AudioTranscription` carrying the `speaker_label`."""
28670
28714
 
28671
28715
  speaker_label: Optional[str] = Field(
28672
28716
  default=None,
28673
- description="""Optional. A label identifying the speaker of this audio segment (e.g. "spk_1", "spk_2"). Present when diarization is set.""",
28717
+ description="""Optional. A label identifying the speaker of this audio segment (e.g. `spk_1`, `spk_2`). Present when `diarization` is set.""",
28674
28718
  )
28675
28719
  text: Optional[str] = Field(
28676
28720
  default=None,
@@ -28678,21 +28722,21 @@ class AudioTranscription(_common.BaseModel):
28678
28722
  )
28679
28723
  words: Optional[list[AudioTranscriptionWordInfo]] = Field(
28680
28724
  default=None,
28681
- description="""Optional. Detailed word-level transcriptions and timing details. Present when word_timestamp is set.""",
28725
+ description="""Optional. Detailed word-level transcriptions and timing details. Present when `word_timestamp` is set.""",
28682
28726
  )
28683
28727
 
28684
28728
 
28685
28729
  class AudioTranscriptionDict(TypedDict, total=False):
28686
- """The transcription of an audio part. For multi-speaker audio, each speaker segment is a separate Part with its own AudioTranscription carrying the speaker_label."""
28730
+ """The transcription of an audio part. For multi-speaker audio, each speaker segment is a separate `Part` with its own `AudioTranscription` carrying the `speaker_label`."""
28687
28731
 
28688
28732
  speaker_label: Optional[str]
28689
- """Optional. A label identifying the speaker of this audio segment (e.g. "spk_1", "spk_2"). Present when diarization is set."""
28733
+ """Optional. A label identifying the speaker of this audio segment (e.g. `spk_1`, `spk_2`). Present when `diarization` is set."""
28690
28734
 
28691
28735
  text: Optional[str]
28692
28736
  """Required. The transcription text of this audio segment."""
28693
28737
 
28694
28738
  words: Optional[list[AudioTranscriptionWordInfoDict]]
28695
- """Optional. Detailed word-level transcriptions and timing details. Present when word_timestamp is set."""
28739
+ """Optional. Detailed word-level transcriptions and timing details. Present when `word_timestamp` is set."""
28696
28740
 
28697
28741
 
28698
28742
  AudioTranscriptionOrDict = Union[AudioTranscription, AudioTranscriptionDict]
@@ -14,4 +14,4 @@
14
14
  #
15
15
  """Version file for agentplatform."""
16
16
 
17
- __version__ = "2.1.0"
17
+ __version__ = "2.2.0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: google-cloud-agentplatform
3
- Version: 2.1.0
3
+ Version: 2.2.0
4
4
  Summary: Google Cloud Agent Platform Client Library
5
5
  Author-email: Google LLC <googleapis-packages@google.com>
6
6
  License: Apache-2.0