Skip to content

Commit 391d32c

Browse files
cleop-googlecopybara-github
authored andcommitted
feat: GenAI SDK client(multimodal) - Add set_read_config to MultimodalDataset.
PiperOrigin-RevId: 885611714
1 parent 394253a commit 391d32c

2 files changed

Lines changed: 68 additions & 0 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
"""Tests for multimodal datasets."""
16+
17+
from vertexai._genai import types
18+
19+
20+
class TestMultimodalDataset:
21+
def test_set_read_config(self):
22+
dataset = types.MultimodalDataset()
23+
24+
dataset.set_read_config(
25+
read_config={
26+
"assembled_request_column_name": "test_column",
27+
},
28+
)
29+
30+
assert isinstance(dataset, types.MultimodalDataset)
31+
assert (
32+
dataset.metadata.gemini_request_read_config.assembled_request_column_name
33+
== "test_column"
34+
)
35+
36+
def test_set_read_config_preserves_other_fields(self):
37+
dataset = types.MultimodalDataset(
38+
metadata={
39+
"inputConfig": {
40+
"bigquerySource": {"uri": "bq://test_table"},
41+
},
42+
},
43+
)
44+
45+
dataset.set_read_config(
46+
read_config={
47+
"assembled_request_column_name": "test_column",
48+
},
49+
)
50+
51+
assert isinstance(dataset, types.MultimodalDataset)
52+
assert (
53+
dataset.metadata.gemini_request_read_config.assembled_request_column_name
54+
== "test_column"
55+
)
56+
assert dataset.metadata.input_config.bigquery_source.uri == "bq://test_table"

vertexai/_genai/types/common.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13087,6 +13087,18 @@ class MultimodalDataset(_common.BaseModel):
1308713087
default=None, description="""The description of the multimodal dataset."""
1308813088
)
1308913089

13090+
def set_read_config(
13091+
self,
13092+
*,
13093+
read_config: GeminiRequestReadConfigOrDict,
13094+
) -> None:
13095+
if isinstance(read_config, dict):
13096+
read_config = GeminiRequestReadConfig(**read_config)
13097+
13098+
if self.metadata is None:
13099+
self.metadata = SchemaTablesDatasetMetadata()
13100+
self.metadata.gemini_request_read_config = read_config
13101+
1309013102

1309113103
class MultimodalDatasetDict(TypedDict, total=False):
1309213104
"""Represents a multimodal dataset."""

0 commit comments

Comments
 (0)