Skip to content

Commit e16b647

Browse files
jsondaicopybara-github
authored andcommitted
chore: add new types for evals module in GenAI SDK
PiperOrigin-RevId: 766323678
1 parent 166b747 commit e16b647

File tree

3 files changed

+496
-41
lines changed

3 files changed

+496
-41
lines changed

vertexai/_genai/_evals_common.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import os
2020
import time
2121
from typing import Any, Callable, Optional, Union
22-
2322
from google.api_core import exceptions as api_exceptions
2423
from google.genai import types as genai_types
2524
from google.genai._api_client import BaseApiClient

vertexai/_genai/evals.py

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -692,16 +692,20 @@ def _EvaluationDataset_to_vertex(
692692
) -> dict[str, Any]:
693693
to_object: dict[str, Any] = {}
694694

695+
if getv(from_object, ["gcs_source"]) is not None:
696+
setv(
697+
to_object,
698+
["dataset", "gcs_source"],
699+
getv(from_object, ["gcs_source"]),
700+
)
701+
695702
if getv(from_object, ["bigquery_source"]) is not None:
696703
setv(
697704
to_object,
698-
["bigquerySource"],
705+
["dataset", "bigquery_source"],
699706
getv(from_object, ["bigquery_source"]),
700707
)
701708

702-
if getv(from_object, ["gcs_source"]) is not None:
703-
setv(to_object, ["gcsSource"], getv(from_object, ["gcs_source"]))
704-
705709
return to_object
706710

707711

@@ -711,6 +715,44 @@ def _Metric_to_vertex(
711715
parent_object: Optional[dict[str, Any]] = None,
712716
) -> dict[str, Any]:
713717
to_object: dict[str, Any] = {}
718+
if getv(from_object, ["prompt_template"]) is not None:
719+
setv(
720+
to_object,
721+
["pointwise_metric_spec", "prompt_template"],
722+
getv(from_object, ["prompt_template"]),
723+
)
724+
725+
if getv(from_object, ["judge_model"]) is not None:
726+
setv(
727+
parent_object,
728+
["autorater_config", "autorater_model"],
729+
getv(from_object, ["judge_model"]),
730+
)
731+
732+
if getv(from_object, ["judge_model_sampling_count"]) is not None:
733+
setv(
734+
parent_object,
735+
["autorater_config", "sampling_count"],
736+
getv(from_object, ["judge_model_sampling_count"]),
737+
)
738+
739+
if getv(from_object, ["judge_model_system_instruction"]) is not None:
740+
setv(
741+
to_object,
742+
["pointwise_metric_spec", "system_instruction"],
743+
getv(from_object, ["judge_model_system_instruction"]),
744+
)
745+
746+
if getv(from_object, ["return_raw_output"]) is not None:
747+
setv(
748+
to_object,
749+
[
750+
"pointwise_metric_spec",
751+
"custom_output_format_config",
752+
"return_raw_output",
753+
],
754+
getv(from_object, ["return_raw_output"]),
755+
)
714756

715757
return to_object
716758

@@ -936,15 +978,19 @@ def _EvaluationDataset_from_vertex(
936978
) -> dict[str, Any]:
937979
to_object: dict[str, Any] = {}
938980

939-
if getv(from_object, ["bigquerySource"]) is not None:
981+
if getv(from_object, ["dataset", "gcs_source"]) is not None:
940982
setv(
941983
to_object,
942-
["bigquery_source"],
943-
getv(from_object, ["bigquerySource"]),
984+
["gcs_source"],
985+
getv(from_object, ["dataset", "gcs_source"]),
944986
)
945987

946-
if getv(from_object, ["gcsSource"]) is not None:
947-
setv(to_object, ["gcs_source"], getv(from_object, ["gcsSource"]))
988+
if getv(from_object, ["dataset", "bigquery_source"]) is not None:
989+
setv(
990+
to_object,
991+
["bigquery_source"],
992+
getv(from_object, ["dataset", "bigquery_source"]),
993+
)
948994

949995
return to_object
950996

0 commit comments

Comments
 (0)