From 8a2034900c6caa9349d00a0fcf0f5e7af762f9ef Mon Sep 17 00:00:00 2001 From: A Vertex SDK engineer Date: Wed, 29 Oct 2025 11:17:52 -0700 Subject: [PATCH] fix: GenAI Client(evals) - Apply sync function for agent run PiperOrigin-RevId: 825629527 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 38 ------------------- google/cloud/aiplatform/gapic_version.py | 2 +- .../schema/predict/instance/gapic_version.py | 2 +- .../predict/instance_v1/gapic_version.py | 2 +- .../v1/schema/predict/params/gapic_version.py | 2 +- .../schema/predict/params_v1/gapic_version.py | 2 +- .../predict/prediction/gapic_version.py | 2 +- .../predict/prediction_v1/gapic_version.py | 2 +- .../trainingjob/definition/gapic_version.py | 2 +- .../definition_v1/gapic_version.py | 2 +- .../schema/predict/instance/gapic_version.py | 2 +- .../predict/instance_v1beta1/gapic_version.py | 2 +- .../schema/predict/params/gapic_version.py | 2 +- .../predict/params_v1beta1/gapic_version.py | 2 +- .../predict/prediction/gapic_version.py | 2 +- .../prediction_v1beta1/gapic_version.py | 2 +- .../trainingjob/definition/gapic_version.py | 2 +- .../definition_v1beta1/gapic_version.py | 2 +- google/cloud/aiplatform/version.py | 2 +- google/cloud/aiplatform_v1/gapic_version.py | 2 +- .../cloud/aiplatform_v1beta1/gapic_version.py | 2 +- pypi/_vertex_ai_placeholder/version.py | 2 +- ...t_metadata_google.cloud.aiplatform.v1.json | 2 +- ...adata_google.cloud.aiplatform.v1beta1.json | 2 +- tests/unit/vertexai/genai/test_evals.py | 32 ++++------------ vertexai/_genai/_evals_common.py | 20 +++++----- 27 files changed, 41 insertions(+), 97 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 799af689d1..5ef55aa751 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.123.0" + ".": "1.122.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 07f5de91c7..1144795a2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,43 +1,5 @@ # Changelog -## [1.123.0](https://github.com/googleapis/python-aiplatform/compare/v1.122.0...v1.123.0) (2025-10-29) - - -### Features - -* Add initial support for Python v3.14 ([4618729](https://github.com/googleapis/python-aiplatform/commit/4618729e9b41163cda3056a3fde497a0c0d7178f)) -* Add more attributes to OTel resource for ADK tracing ([5aaa60e](https://github.com/googleapis/python-aiplatform/commit/5aaa60e30a5695c2a5eb49283388fa36809e389e)) -* Add Python 3.13 Kokoro run config ([57d2709](https://github.com/googleapis/python-aiplatform/commit/57d270909b02132296692b4adc6dbc89ee8de9c6)) -* Add support for `app` input in AdkApp template ([10ca56f](https://github.com/googleapis/python-aiplatform/commit/10ca56f797f7c9cbfbe53e8830420135a58ac003)) -* Add support of google-cloud-storage v3 dependency ([85cbb75](https://github.com/googleapis/python-aiplatform/commit/85cbb7532d1e8337b1747bce53c765a9b94d067a)) -* Disable prompt/response content in ADK spans if telemetry env is set ([be5d1f5](https://github.com/googleapis/python-aiplatform/commit/be5d1f59121c5255e6061a518a5abe9e3e3c0a17)) -* GenAI Client(evals) - Add agent data to EvaluationRun `show` in Vertex AI GenAI SDK evals ([d62afc3](https://github.com/googleapis/python-aiplatform/commit/d62afc32db85a103c25878dd82a338feb86f53fe)) -* GenAI SDK client - add context management to AsyncClient ([8075e60](https://github.com/googleapis/python-aiplatform/commit/8075e6067a9ba924249155ec204488df97512ec8)) -* GenAI SDK client - Enabling zero-shot prompt optimization for prompts from Android API by passing optimization_target=vertexai.types.OptimizeTarget.OPTIMIZATION_TARGET_GEMINI_NANO in the config ([92d8b2a](https://github.com/googleapis/python-aiplatform/commit/92d8b2a1659cc40c89a651c3a1b93ae5af5a9bf1)) -* GenAI SDK client (Multimodal Dataset) - Create a multimodal dataset from Big Query. ([d4e211d](https://github.com/googleapis/python-aiplatform/commit/d4e211d00d3276aa6cb645deb27397467fc27c5b)) -* GenAI SDK client(memory): Add extracted memories to MemoryRevision resources ([2267d58](https://github.com/googleapis/python-aiplatform/commit/2267d58f6ad849dcd4f0a2cce12e4bb1a06781eb)) -* GenAI SDK client(memory): Add filter to RetrieveMemories ([2267d58](https://github.com/googleapis/python-aiplatform/commit/2267d58f6ad849dcd4f0a2cce12e4bb1a06781eb)) -* GenAI SDK client(memory): Add Memory Topic labels to Memory ([de941a6](https://github.com/googleapis/python-aiplatform/commit/de941a6fc3ca7885a0fc3e42b5ef7c44a783963b)) -* GenAI SDK client(multimodal) - Add get/update/list/delete to multimodal datasets. ([34996a2](https://github.com/googleapis/python-aiplatform/commit/34996a28de0495462aea9c7c2baf8b4249afb9df)) -* GenAI SDK client(multimodal) - Add public get/update/delete methods to multimodal datasets. ([6737a70](https://github.com/googleapis/python-aiplatform/commit/6737a705d8a14023a0dce2902d62f34afb1bb763)) -* Support Inline Source Deployment in Agent Engine ([9ae5f35](https://github.com/googleapis/python-aiplatform/commit/9ae5f356feef56d4ad652b9b6a705ce4f02079e7)) - - -### Bug Fixes - -* Allow both camelCase and snake_case in _StreamRunRequest ([6a6674d](https://github.com/googleapis/python-aiplatform/commit/6a6674d76bcd148ededfafd7d3f248d880c2b110)) -* Clone agent_framework attribute in ModuleAgent.clone() ([81f8c40](https://github.com/googleapis/python-aiplatform/commit/81f8c406bb979f3521067b2dea1544db0f4194f4)) -* GenAI Client(evals) - fix hallucination visualization ([a52da0b](https://github.com/googleapis/python-aiplatform/commit/a52da0b3d04c19e777ab8fff5d724c5cda8118f3)) -* GenAI Client(evals) - fix visualization ([67f9099](https://github.com/googleapis/python-aiplatform/commit/67f9099af92226fac603c4cbec944e66c4fc737f)) -* GenAI SDK client - Fix log showing how to get an Agent Engine. Positional arguments are not allowed. ([0fc74de](https://github.com/googleapis/python-aiplatform/commit/0fc74dea6d9e8826f29b7b9c1a10f348be911f6a)) -* Remove unnecessary pandas import from multimodal datasets preview module. ([5dd51a2](https://github.com/googleapis/python-aiplatform/commit/5dd51a2ea6fa115ab8d33970d22aefaab31dfcbd)) - - -### Documentation - -* Add docstring for classes and fields that are not supported in Gemini or Vertex API ([cd99635](https://github.com/googleapis/python-aiplatform/commit/cd99635cd5b85334dbdfddd0ef3cb7ec5c93846d)) -* Add docstring for enum classes that are not supported in Gemini or Vertex API ([db364ab](https://github.com/googleapis/python-aiplatform/commit/db364ab793cde5c25518bbaaa6df9a0f44ee9ac6)) - ## [1.122.0](https://github.com/googleapis/python-aiplatform/compare/v1.121.0...v1.122.0) (2025-10-21) diff --git a/google/cloud/aiplatform/gapic_version.py b/google/cloud/aiplatform/gapic_version.py index b7e5e1c3c3..4008f57291 100644 --- a/google/cloud/aiplatform/gapic_version.py +++ b/google/cloud/aiplatform/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.123.0" # {x-release-please-version} +__version__ = "1.122.0" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1/schema/predict/instance/gapic_version.py b/google/cloud/aiplatform/v1/schema/predict/instance/gapic_version.py index b7e5e1c3c3..4008f57291 100644 --- a/google/cloud/aiplatform/v1/schema/predict/instance/gapic_version.py +++ b/google/cloud/aiplatform/v1/schema/predict/instance/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.123.0" # {x-release-please-version} +__version__ = "1.122.0" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1/schema/predict/instance_v1/gapic_version.py b/google/cloud/aiplatform/v1/schema/predict/instance_v1/gapic_version.py index b7e5e1c3c3..4008f57291 100644 --- a/google/cloud/aiplatform/v1/schema/predict/instance_v1/gapic_version.py +++ b/google/cloud/aiplatform/v1/schema/predict/instance_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.123.0" # {x-release-please-version} +__version__ = "1.122.0" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1/schema/predict/params/gapic_version.py b/google/cloud/aiplatform/v1/schema/predict/params/gapic_version.py index b7e5e1c3c3..4008f57291 100644 --- a/google/cloud/aiplatform/v1/schema/predict/params/gapic_version.py +++ b/google/cloud/aiplatform/v1/schema/predict/params/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.123.0" # {x-release-please-version} +__version__ = "1.122.0" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1/schema/predict/params_v1/gapic_version.py b/google/cloud/aiplatform/v1/schema/predict/params_v1/gapic_version.py index b7e5e1c3c3..4008f57291 100644 --- a/google/cloud/aiplatform/v1/schema/predict/params_v1/gapic_version.py +++ b/google/cloud/aiplatform/v1/schema/predict/params_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.123.0" # {x-release-please-version} +__version__ = "1.122.0" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1/schema/predict/prediction/gapic_version.py b/google/cloud/aiplatform/v1/schema/predict/prediction/gapic_version.py index b7e5e1c3c3..4008f57291 100644 --- a/google/cloud/aiplatform/v1/schema/predict/prediction/gapic_version.py +++ b/google/cloud/aiplatform/v1/schema/predict/prediction/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.123.0" # {x-release-please-version} +__version__ = "1.122.0" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/gapic_version.py b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/gapic_version.py index b7e5e1c3c3..4008f57291 100644 --- a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/gapic_version.py +++ b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.123.0" # {x-release-please-version} +__version__ = "1.122.0" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1/schema/trainingjob/definition/gapic_version.py b/google/cloud/aiplatform/v1/schema/trainingjob/definition/gapic_version.py index b7e5e1c3c3..4008f57291 100644 --- a/google/cloud/aiplatform/v1/schema/trainingjob/definition/gapic_version.py +++ b/google/cloud/aiplatform/v1/schema/trainingjob/definition/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.123.0" # {x-release-please-version} +__version__ = "1.122.0" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/gapic_version.py b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/gapic_version.py index b7e5e1c3c3..4008f57291 100644 --- a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/gapic_version.py +++ b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.123.0" # {x-release-please-version} +__version__ = "1.122.0" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/instance/gapic_version.py b/google/cloud/aiplatform/v1beta1/schema/predict/instance/gapic_version.py index b7e5e1c3c3..4008f57291 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/instance/gapic_version.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/instance/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.123.0" # {x-release-please-version} +__version__ = "1.122.0" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/gapic_version.py b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/gapic_version.py index b7e5e1c3c3..4008f57291 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/gapic_version.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.123.0" # {x-release-please-version} +__version__ = "1.122.0" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/params/gapic_version.py b/google/cloud/aiplatform/v1beta1/schema/predict/params/gapic_version.py index b7e5e1c3c3..4008f57291 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/params/gapic_version.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/params/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.123.0" # {x-release-please-version} +__version__ = "1.122.0" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/gapic_version.py b/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/gapic_version.py index b7e5e1c3c3..4008f57291 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/gapic_version.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.123.0" # {x-release-please-version} +__version__ = "1.122.0" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/prediction/gapic_version.py b/google/cloud/aiplatform/v1beta1/schema/predict/prediction/gapic_version.py index b7e5e1c3c3..4008f57291 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/prediction/gapic_version.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/prediction/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.123.0" # {x-release-please-version} +__version__ = "1.122.0" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/gapic_version.py b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/gapic_version.py index b7e5e1c3c3..4008f57291 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/gapic_version.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.123.0" # {x-release-please-version} +__version__ = "1.122.0" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition/gapic_version.py b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition/gapic_version.py index b7e5e1c3c3..4008f57291 100644 --- a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition/gapic_version.py +++ b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.123.0" # {x-release-please-version} +__version__ = "1.122.0" # {x-release-please-version} diff --git a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/gapic_version.py b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/gapic_version.py index b7e5e1c3c3..4008f57291 100644 --- a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/gapic_version.py +++ b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.123.0" # {x-release-please-version} +__version__ = "1.122.0" # {x-release-please-version} diff --git a/google/cloud/aiplatform/version.py b/google/cloud/aiplatform/version.py index 4456074835..c1cf7391f6 100644 --- a/google/cloud/aiplatform/version.py +++ b/google/cloud/aiplatform/version.py @@ -15,4 +15,4 @@ # limitations under the License. # -__version__ = "1.123.0" +__version__ = "1.122.0" diff --git a/google/cloud/aiplatform_v1/gapic_version.py b/google/cloud/aiplatform_v1/gapic_version.py index b7e5e1c3c3..4008f57291 100644 --- a/google/cloud/aiplatform_v1/gapic_version.py +++ b/google/cloud/aiplatform_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.123.0" # {x-release-please-version} +__version__ = "1.122.0" # {x-release-please-version} diff --git a/google/cloud/aiplatform_v1beta1/gapic_version.py b/google/cloud/aiplatform_v1beta1/gapic_version.py index b7e5e1c3c3..4008f57291 100644 --- a/google/cloud/aiplatform_v1beta1/gapic_version.py +++ b/google/cloud/aiplatform_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.123.0" # {x-release-please-version} +__version__ = "1.122.0" # {x-release-please-version} diff --git a/pypi/_vertex_ai_placeholder/version.py b/pypi/_vertex_ai_placeholder/version.py index 862b1bf8e2..2c3a733490 100644 --- a/pypi/_vertex_ai_placeholder/version.py +++ b/pypi/_vertex_ai_placeholder/version.py @@ -15,4 +15,4 @@ # limitations under the License. # -__version__ = "1.123.0" +__version__ = "1.122.0" diff --git a/samples/generated_samples/snippet_metadata_google.cloud.aiplatform.v1.json b/samples/generated_samples/snippet_metadata_google.cloud.aiplatform.v1.json index 452f5200b7..f409e033c5 100644 --- a/samples/generated_samples/snippet_metadata_google.cloud.aiplatform.v1.json +++ b/samples/generated_samples/snippet_metadata_google.cloud.aiplatform.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-aiplatform", - "version": "1.123.0" + "version": "1.122.0" }, "snippets": [ { diff --git a/samples/generated_samples/snippet_metadata_google.cloud.aiplatform.v1beta1.json b/samples/generated_samples/snippet_metadata_google.cloud.aiplatform.v1beta1.json index da1dd0b8b4..cae9aed2de 100644 --- a/samples/generated_samples/snippet_metadata_google.cloud.aiplatform.v1beta1.json +++ b/samples/generated_samples/snippet_metadata_google.cloud.aiplatform.v1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-aiplatform", - "version": "1.123.0" + "version": "1.122.0" }, "snippets": [ { diff --git a/tests/unit/vertexai/genai/test_evals.py b/tests/unit/vertexai/genai/test_evals.py index 5e7b03f57f..2c6442818d 100644 --- a/tests/unit/vertexai/genai/test_evals.py +++ b/tests/unit/vertexai/genai/test_evals.py @@ -1070,9 +1070,7 @@ def test_run_inference_with_agent_engine_and_session_inputs_dict( ) mock_agent_engine = mock.Mock() - mock_agent_engine.async_create_session = mock.AsyncMock( - return_value={"id": "session1"} - ) + mock_agent_engine.create_session.return_value = {"id": "session1"} stream_query_return_value = [ { "id": "1", @@ -1088,13 +1086,7 @@ def test_run_inference_with_agent_engine_and_session_inputs_dict( }, ] - async def _async_iterator(iterable): - for item in iterable: - yield item - - mock_agent_engine.async_stream_query.return_value = _async_iterator( - stream_query_return_value - ) + mock_agent_engine.stream_query.return_value = iter(stream_query_return_value) mock_vertexai_client.return_value.agent_engines.get.return_value = ( mock_agent_engine ) @@ -1108,10 +1100,10 @@ async def _async_iterator(iterable): mock_vertexai_client.return_value.agent_engines.get.assert_called_once_with( name="projects/test-project/locations/us-central1/reasoningEngines/123" ) - mock_agent_engine.async_create_session.assert_called_once_with( + mock_agent_engine.create_session.assert_called_once_with( user_id="123", state={"a": "1"} ) - mock_agent_engine.async_stream_query.assert_called_once_with( + mock_agent_engine.stream_query.assert_called_once_with( user_id="123", session_id="session1", message="agent prompt" ) @@ -1162,9 +1154,7 @@ def test_run_inference_with_agent_engine_and_session_inputs_literal_string( ) mock_agent_engine = mock.Mock() - mock_agent_engine.async_create_session = mock.AsyncMock( - return_value={"id": "session1"} - ) + mock_agent_engine.create_session.return_value = {"id": "session1"} stream_query_return_value = [ { "id": "1", @@ -1180,13 +1170,7 @@ def test_run_inference_with_agent_engine_and_session_inputs_literal_string( }, ] - async def _async_iterator(iterable): - for item in iterable: - yield item - - mock_agent_engine.async_stream_query.return_value = _async_iterator( - stream_query_return_value - ) + mock_agent_engine.stream_query.return_value = iter(stream_query_return_value) mock_vertexai_client.return_value.agent_engines.get.return_value = ( mock_agent_engine ) @@ -1200,10 +1184,10 @@ async def _async_iterator(iterable): mock_vertexai_client.return_value.agent_engines.get.assert_called_once_with( name="projects/test-project/locations/us-central1/reasoningEngines/123" ) - mock_agent_engine.async_create_session.assert_called_once_with( + mock_agent_engine.create_session.assert_called_once_with( user_id="123", state={"a": "1"} ) - mock_agent_engine.async_stream_query.assert_called_once_with( + mock_agent_engine.stream_query.assert_called_once_with( user_id="123", session_id="session1", message="agent prompt" ) diff --git a/vertexai/_genai/_evals_common.py b/vertexai/_genai/_evals_common.py index 8388784272..341ae88a7f 100644 --- a/vertexai/_genai/_evals_common.py +++ b/vertexai/_genai/_evals_common.py @@ -278,12 +278,10 @@ def agent_run_wrapper( and type(agent_engine).__name__ == "AgentEngine" ): agent_engine_instance = agent_engine - return asyncio.run( - inference_fn_arg( - row=row_arg, - contents=contents_arg, - agent_engine=agent_engine_instance, - ) + return inference_fn_arg( + row=row_arg, + contents=contents_arg, + agent_engine=agent_engine_instance, ) future = executor.submit( @@ -1265,7 +1263,7 @@ def _run_agent( ) -async def _execute_agent_run_with_retry( +def _execute_agent_run_with_retry( row: pd.Series, contents: Union[genai_types.ContentListUnion, genai_types.ContentListUnionDict], agent_engine: types.AgentEngine, @@ -1287,7 +1285,7 @@ async def _execute_agent_run_with_retry( ) user_id = session_inputs.user_id session_state = session_inputs.state - session = await agent_engine.async_create_session( + session = agent_engine.create_session( user_id=user_id, state=session_state, ) @@ -1298,7 +1296,7 @@ async def _execute_agent_run_with_retry( for attempt in range(max_retries): try: responses = [] - async for event in agent_engine.async_stream_query( + for event in agent_engine.stream_query( user_id=user_id, session_id=session["id"], message=contents, @@ -1317,7 +1315,7 @@ async def _execute_agent_run_with_retry( ) if attempt == max_retries - 1: return {"error": f"Resource exhausted after retries: {e}"} - await asyncio.sleep(2**attempt) + time.sleep(2**attempt) except Exception as e: # pylint: disable=broad-exception-caught logger.error( "Unexpected error during generate_content on attempt %d/%d: %s", @@ -1328,7 +1326,7 @@ async def _execute_agent_run_with_retry( if attempt == max_retries - 1: return {"error": f"Failed after retries: {e}"} - await asyncio.sleep(1) + time.sleep(1) return {"error": f"Failed to get agent run results after {max_retries} retries"}