Skip to content
Merged
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
1 change: 0 additions & 1 deletion vertexai/_genai/_evals_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import os
import time
from typing import Any, Callable, Optional, Union

from google.api_core import exceptions as api_exceptions
from google.genai import types as genai_types
from google.genai._api_client import BaseApiClient
Expand Down
64 changes: 55 additions & 9 deletions vertexai/_genai/evals.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,16 +692,20 @@ def _EvaluationDataset_to_vertex(
) -> dict[str, Any]:
to_object: dict[str, Any] = {}

if getv(from_object, ["gcs_source"]) is not None:
setv(
to_object,
["dataset", "gcs_source"],
getv(from_object, ["gcs_source"]),
)

if getv(from_object, ["bigquery_source"]) is not None:
setv(
to_object,
["bigquerySource"],
["dataset", "bigquery_source"],
getv(from_object, ["bigquery_source"]),
)

if getv(from_object, ["gcs_source"]) is not None:
setv(to_object, ["gcsSource"], getv(from_object, ["gcs_source"]))

return to_object


Expand All @@ -711,6 +715,44 @@ def _Metric_to_vertex(
parent_object: Optional[dict[str, Any]] = None,
) -> dict[str, Any]:
to_object: dict[str, Any] = {}
if getv(from_object, ["prompt_template"]) is not None:
setv(
to_object,
["pointwise_metric_spec", "prompt_template"],
getv(from_object, ["prompt_template"]),
)

if getv(from_object, ["judge_model"]) is not None:
setv(
parent_object,
["autorater_config", "autorater_model"],
getv(from_object, ["judge_model"]),
)

if getv(from_object, ["judge_model_sampling_count"]) is not None:
setv(
parent_object,
["autorater_config", "sampling_count"],
getv(from_object, ["judge_model_sampling_count"]),
)

if getv(from_object, ["judge_model_system_instruction"]) is not None:
setv(
to_object,
["pointwise_metric_spec", "system_instruction"],
getv(from_object, ["judge_model_system_instruction"]),
)

if getv(from_object, ["return_raw_output"]) is not None:
setv(
to_object,
[
"pointwise_metric_spec",
"custom_output_format_config",
"return_raw_output",
],
getv(from_object, ["return_raw_output"]),
)

return to_object

Expand Down Expand Up @@ -936,15 +978,19 @@ def _EvaluationDataset_from_vertex(
) -> dict[str, Any]:
to_object: dict[str, Any] = {}

if getv(from_object, ["bigquerySource"]) is not None:
if getv(from_object, ["dataset", "gcs_source"]) is not None:
setv(
to_object,
["bigquery_source"],
getv(from_object, ["bigquerySource"]),
["gcs_source"],
getv(from_object, ["dataset", "gcs_source"]),
)

if getv(from_object, ["gcsSource"]) is not None:
setv(to_object, ["gcs_source"], getv(from_object, ["gcsSource"]))
if getv(from_object, ["dataset", "bigquery_source"]) is not None:
setv(
to_object,
["bigquery_source"],
getv(from_object, ["dataset", "bigquery_source"]),
)

return to_object

Expand Down
Loading