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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,18 @@ def test_assemble_dataset(client):
def test_assemble_dataset_public(client):
bigquery_destination = client.datasets.assemble(
name=DATASET,
template_config=types.GeminiTemplateConfig(
gemini_example=types.GeminiExample(
model="gemini-1.5-flash",
contents=[
{
"role": "user",
"parts": [{"text": "What is the capital of {name}?"}],
}
],
),
gemini_request_read_config=types.GeminiRequestReadConfig(
template_config=types.GeminiTemplateConfig(
gemini_example=types.GeminiExample(
model="gemini-1.5-flash",
contents=[
{
"role": "user",
"parts": [{"text": "What is the capital of {name}?"}],
}
],
),
)
),
)
assert bigquery_destination.startswith(f"bq://{BIGQUERY_TABLE_NAME}")
Expand Down Expand Up @@ -81,16 +83,18 @@ async def test_assemble_dataset_async(client):
async def test_assemble_dataset_public_async(client):
bigquery_destination = await client.aio.datasets.assemble(
name=DATASET,
template_config=types.GeminiTemplateConfig(
gemini_example=types.GeminiExample(
model="gemini-1.5-flash",
contents=[
{
"role": "user",
"parts": [{"text": "What is the capital of {name}?"}],
}
],
),
gemini_request_read_config=types.GeminiRequestReadConfig(
template_config=types.GeminiTemplateConfig(
gemini_example=types.GeminiExample(
model="gemini-1.5-flash",
contents=[
{
"role": "user",
"parts": [{"text": "What is the capital of {name}?"}],
}
],
),
)
),
)
assert bigquery_destination.startswith(f"bq://{BIGQUERY_TABLE_NAME}")
208 changes: 112 additions & 96 deletions tests/unit/vertexai/genai/replays/test_assess_multimodal_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,17 @@ def test_assess_tuning_resources(client):
response = client.datasets.assess_tuning_resources(
dataset_name=DATASET,
model_name="gemini-2.5-flash-001",
template_config=types.GeminiTemplateConfig(
gemini_example=types.GeminiExample(
contents=[
{
"role": "user",
"parts": [{"text": "What is the capital of {name}?"}],
}
],
),
gemini_request_read_config=types.GeminiRequestReadConfig(
template_config=types.GeminiTemplateConfig(
gemini_example=types.GeminiExample(
contents=[
{
"role": "user",
"parts": [{"text": "What is the capital of {name}?"}],
}
],
),
)
),
)
assert isinstance(response, types.TuningResourceUsageAssessmentResult)
Expand All @@ -71,19 +73,21 @@ def test_assess_tuning_validity(client):
dataset_name=DATASET,
dataset_usage="SFT_VALIDATION",
model_name="gemini-2.5-flash-001",
template_config=types.GeminiTemplateConfig(
gemini_example=types.GeminiExample(
contents=[
{
"role": "user",
"parts": [{"text": "What is the capital of {name}?"}],
},
{
"role": "model",
"parts": [{"text": "{capital}"}],
},
],
),
gemini_request_read_config=types.GeminiRequestReadConfig(
template_config=types.GeminiTemplateConfig(
gemini_example=types.GeminiExample(
contents=[
{
"role": "user",
"parts": [{"text": "What is the capital of {name}?"}],
},
{
"role": "model",
"parts": [{"text": "{capital}"}],
},
],
),
)
),
)
assert isinstance(response, types.TuningValidationAssessmentResult)
Expand All @@ -93,19 +97,21 @@ def test_assess_batch_prediction_resources(client):
response = client.datasets.assess_batch_prediction_resources(
dataset_name=DATASET,
model_name="gemini-2.5-flash-001",
template_config=types.GeminiTemplateConfig(
gemini_example=types.GeminiExample(
contents=[
{
"role": "user",
"parts": [{"text": "What is the capital of {name}?"}],
},
{
"role": "model",
"parts": [{"text": "{capital}"}],
},
],
),
gemini_request_read_config=types.GeminiRequestReadConfig(
template_config=types.GeminiTemplateConfig(
gemini_example=types.GeminiExample(
contents=[
{
"role": "user",
"parts": [{"text": "What is the capital of {name}?"}],
},
{
"role": "model",
"parts": [{"text": "{capital}"}],
},
],
),
)
),
)
assert isinstance(response, types.BatchPredictionResourceUsageAssessmentResult)
Expand All @@ -115,19 +121,21 @@ def test_assess_batch_prediction_validity(client):
response = client.datasets.assess_batch_prediction_validity(
dataset_name=DATASET,
model_name="gemini-2.5-flash-001",
template_config=types.GeminiTemplateConfig(
gemini_example=types.GeminiExample(
contents=[
{
"role": "user",
"parts": [{"text": "What is the capital of {name}?"}],
},
{
"role": "model",
"parts": [{"text": "{capital}"}],
},
],
),
gemini_request_read_config=types.GeminiRequestReadConfig(
template_config=types.GeminiTemplateConfig(
gemini_example=types.GeminiExample(
contents=[
{
"role": "user",
"parts": [{"text": "What is the capital of {name}?"}],
},
{
"role": "model",
"parts": [{"text": "{capital}"}],
},
],
),
)
),
)
assert isinstance(response, types.BatchPredictionValidationAssessmentResult)
Expand Down Expand Up @@ -169,15 +177,17 @@ async def test_assess_tuning_resources_async(client):
response = await client.aio.datasets.assess_tuning_resources(
dataset_name=DATASET,
model_name="gemini-2.5-flash-001",
template_config=types.GeminiTemplateConfig(
gemini_example=types.GeminiExample(
contents=[
{
"role": "user",
"parts": [{"text": "What is the capital of {name}?"}],
}
],
),
gemini_request_read_config=types.GeminiRequestReadConfig(
template_config=types.GeminiTemplateConfig(
gemini_example=types.GeminiExample(
contents=[
{
"role": "user",
"parts": [{"text": "What is the capital of {name}?"}],
}
],
),
)
),
)
assert isinstance(response, types.TuningResourceUsageAssessmentResult)
Expand All @@ -189,19 +199,21 @@ async def test_assess_tuning_validity_async(client):
dataset_name=DATASET,
dataset_usage="SFT_VALIDATION",
model_name="gemini-2.5-flash-001",
template_config=types.GeminiTemplateConfig(
gemini_example=types.GeminiExample(
contents=[
{
"role": "user",
"parts": [{"text": "What is the capital of {name}?"}],
},
{
"role": "model",
"parts": [{"text": "{capital}"}],
},
],
),
gemini_request_read_config=types.GeminiRequestReadConfig(
template_config=types.GeminiTemplateConfig(
gemini_example=types.GeminiExample(
contents=[
{
"role": "user",
"parts": [{"text": "What is the capital of {name}?"}],
},
{
"role": "model",
"parts": [{"text": "{capital}"}],
},
],
),
)
),
)
assert isinstance(response, types.TuningValidationAssessmentResult)
Expand All @@ -212,19 +224,21 @@ async def test_assess_batch_prediction_resources_async(client):
response = await client.aio.datasets.assess_batch_prediction_resources(
dataset_name=DATASET,
model_name="gemini-2.5-flash-001",
template_config=types.GeminiTemplateConfig(
gemini_example=types.GeminiExample(
contents=[
{
"role": "user",
"parts": [{"text": "What is the capital of {name}?"}],
},
{
"role": "model",
"parts": [{"text": "{capital}"}],
},
],
),
gemini_request_read_config=types.GeminiRequestReadConfig(
template_config=types.GeminiTemplateConfig(
gemini_example=types.GeminiExample(
contents=[
{
"role": "user",
"parts": [{"text": "What is the capital of {name}?"}],
},
{
"role": "model",
"parts": [{"text": "{capital}"}],
},
],
),
)
),
)
assert isinstance(response, types.BatchPredictionResourceUsageAssessmentResult)
Expand All @@ -235,19 +249,21 @@ async def test_assess_batch_prediction_validity_async(client):
response = await client.aio.datasets.assess_batch_prediction_validity(
dataset_name=DATASET,
model_name="gemini-2.5-flash-001",
template_config=types.GeminiTemplateConfig(
gemini_example=types.GeminiExample(
contents=[
{
"role": "user",
"parts": [{"text": "What is the capital of {name}?"}],
},
{
"role": "model",
"parts": [{"text": "{capital}"}],
},
],
),
gemini_request_read_config=types.GeminiRequestReadConfig(
template_config=types.GeminiTemplateConfig(
gemini_example=types.GeminiExample(
contents=[
{
"role": "user",
"parts": [{"text": "What is the capital of {name}?"}],
},
{
"role": "model",
"parts": [{"text": "{capital}"}],
},
],
),
)
),
)
assert isinstance(response, types.BatchPredictionValidationAssessmentResult)
56 changes: 56 additions & 0 deletions tests/unit/vertexai/genai/test_datasets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""Tests for multimodal datasets."""

from vertexai._genai import types


class TestMultimodalDataset:
def test_set_read_config(self):
dataset = types.MultimodalDataset()

dataset.set_read_config(
read_config={
"assembled_request_column_name": "test_column",
},
)

assert isinstance(dataset, types.MultimodalDataset)
assert (
dataset.metadata.gemini_request_read_config.assembled_request_column_name
== "test_column"
)

def test_set_read_config_preserves_other_fields(self):
dataset = types.MultimodalDataset(
metadata={
"inputConfig": {
"bigquerySource": {"uri": "bq://test_table"},
},
},
)

dataset.set_read_config(
read_config={
"assembled_request_column_name": "test_column",
},
)

assert isinstance(dataset, types.MultimodalDataset)
assert (
dataset.metadata.gemini_request_read_config.assembled_request_column_name
== "test_column"
)
assert dataset.metadata.input_config.bigquery_source.uri == "bq://test_table"
Loading
Loading