GeezerVison is showing github.com — feat: Publish GenAI Evaluation SDK GA features to `vertexai.evaluatio… · googleapis/python-aiplatform@45e4251
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: tests/unit/vertexai/test_evaluation.py +10-10Lines changed: 10 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 24 | 24 | import vertexai | 25 | 25 | from google.cloud.aiplatform import initializer | 26 | 26 | from google.cloud.aiplatform.metadata import metadata | 27 | | -from google.cloud.aiplatform_v1beta1.services import ( | | 27 | +from google.cloud.aiplatform_v1.services import ( | 28 | 28 | evaluation_service as gapic_evaluation_services, | 29 | 29 | ) | 30 | | -from google.cloud.aiplatform_v1beta1.types import ( | | 30 | +from google.cloud.aiplatform_v1.types import ( | 31 | 31 | evaluation_service as gapic_evaluation_service_types, | 32 | 32 | ) | | 33 | +from vertexai import evaluation | 33 | 34 | from vertexai import generative_models | 34 | | -from vertexai.preview import evaluation | 35 | | -from vertexai.preview.evaluation import _base as eval_base | 36 | | -from vertexai.preview.evaluation import _evaluation | 37 | | -from vertexai.preview.evaluation import utils | 38 | | -from vertexai.preview.evaluation.metrics import _rouge | 39 | | -from vertexai.preview.evaluation.metrics import ( | | 35 | +from vertexai.evaluation import _base as eval_base | | 36 | +from vertexai.evaluation import _evaluation | | 37 | +from vertexai.evaluation import utils | | 38 | +from vertexai.evaluation.metrics import _rouge | | 39 | +from vertexai.evaluation.metrics import ( | 40 | 40 | metric_prompt_template_examples, | 41 | 41 | ) | 42 | | -from vertexai.preview.evaluation.metrics import pairwise_metric | 43 | | -from vertexai.preview.evaluation.metrics import pointwise_metric | | 42 | +from vertexai.evaluation.metrics import pairwise_metric | | 43 | +from vertexai.evaluation.metrics import pointwise_metric | 44 | 44 | import numpy as np | 45 | 45 | import pandas as pd | 46 | 46 | import pytest | |
Collapse file Copy file name to clipboard +45Lines changed: 45 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +# -*- coding: utf-8 -*- | | 2 | + | | 3 | +# Copyright 2024 Google LLC | | 4 | +# | | 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); | | 6 | +# you may not use this file except in compliance with the License. | | 7 | +# You may obtain a copy of the License at | | 8 | +# | | 9 | +# http://www.apache.org/licenses/LICENSE-2.0 | | 10 | +# | | 11 | +# Unless required by applicable law or agreed to in writing, software | | 12 | +# distributed under the License is distributed on an "AS IS" BASIS, | | 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | | 14 | +# See the License for the specific language governing permissions and | | 15 | +# limitations under the License. | | 16 | +# | | 17 | +"""Vertex Gen AI Evaluation Service Module.""" | | 18 | + | | 19 | +from vertexai.evaluation import _base | | 20 | +from vertexai.evaluation import eval_task | | 21 | +from vertexai.evaluation import metrics | | 22 | +from vertexai.evaluation import prompt_template | | 23 | + | | 24 | + | | 25 | +EvalResult = _base.EvalResult | | 26 | +EvalTask = eval_task.EvalTask | | 27 | +PairwiseMetric = metrics.PairwiseMetric | | 28 | +PointwiseMetric = metrics.PointwiseMetric | | 29 | +CustomMetric = metrics.CustomMetric | | 30 | +PromptTemplate = prompt_template.PromptTemplate | | 31 | +PairwiseMetricPromptTemplate = metrics.PairwiseMetricPromptTemplate | | 32 | +PointwiseMetricPromptTemplate = metrics.PointwiseMetricPromptTemplate | | 33 | +MetricPromptTemplateExamples = metrics.MetricPromptTemplateExamples | | 34 | + | | 35 | +__all__ = [ | | 36 | + "EvalTask", | | 37 | + "EvalResult", | | 38 | + "PairwiseMetric", | | 39 | + "PointwiseMetric", | | 40 | + "CustomMetric", | | 41 | + "PromptTemplate", | | 42 | + "PairwiseMetricPromptTemplate", | | 43 | + "PointwiseMetricPromptTemplate", | | 44 | + "MetricPromptTemplateExamples", | | 45 | +] |
Collapse file Copy file name to clipboardExpand all lines: vertexai/evaluation/_base.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 20 | 20 | import dataclasses | 21 | 21 | from typing import Dict, List, Optional, Union, TYPE_CHECKING | 22 | 22 |
| 23 | | -from google.cloud.aiplatform_v1beta1.services import ( | | 23 | +from google.cloud.aiplatform_v1.services import ( | 24 | 24 | evaluation_service as gapic_evaluation_services, | 25 | 25 | ) | 26 | | -from vertexai.preview.evaluation.metrics import ( | | 26 | +from vertexai.evaluation.metrics import ( | 27 | 27 | _base as metrics_base, | 28 | 28 | ) | 29 | 29 |
| |
Collapse file Copy file name to clipboardExpand all lines: vertexai/evaluation/_evaluation.py +9-9Lines changed: 9 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 28 | 28 | content as gapic_content_types, | 29 | 29 | ) | 30 | 30 | from vertexai import generative_models | 31 | | -from vertexai.preview.evaluation import _base as evaluation_base | 32 | | -from vertexai.preview.evaluation import constants | 33 | | -from vertexai.preview.evaluation import ( | | 31 | +from vertexai.evaluation import _base as evaluation_base | | 32 | +from vertexai.evaluation import constants | | 33 | +from vertexai.evaluation import ( | 34 | 34 | prompt_template as prompt_template_base, | 35 | 35 | ) | 36 | | -from vertexai.preview.evaluation import utils | 37 | | -from vertexai.preview.evaluation.metrics import ( | | 36 | +from vertexai.evaluation import utils | | 37 | +from vertexai.evaluation.metrics import ( | 38 | 38 | _base as metrics_base, | 39 | 39 | ) | 40 | | -from vertexai.preview.evaluation.metrics import ( | | 40 | +from vertexai.evaluation.metrics import ( | 41 | 41 | _instance_evaluation, | 42 | 42 | ) | 43 | | -from vertexai.preview.evaluation.metrics import ( | | 43 | +from vertexai.evaluation.metrics import ( | 44 | 44 | metric_prompt_template_examples, | 45 | 45 | ) | 46 | | -from vertexai.preview.evaluation.metrics import pairwise_metric | 47 | | -from vertexai.preview.evaluation.metrics import pointwise_metric | | 46 | +from vertexai.evaluation.metrics import pairwise_metric | | 47 | +from vertexai.evaluation.metrics import pointwise_metric | 48 | 48 |
| 49 | 49 |
| 50 | 50 | try: | |
Collapse file Copy file name to clipboard File renamed without changes. Collapse file Copy file name to clipboardExpand all lines: vertexai/evaluation/eval_task.py +7-7Lines changed: 7 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 22 | 22 | from google.cloud.aiplatform import base | 23 | 23 | from google.cloud.aiplatform.metadata import metadata | 24 | 24 | from vertexai import generative_models | 25 | | -from vertexai.preview.evaluation import _base as eval_base | 26 | | -from vertexai.preview.evaluation import _evaluation | 27 | | -from vertexai.preview.evaluation import constants | 28 | | -from vertexai.preview.evaluation import utils | 29 | | -from vertexai.preview.evaluation.metrics import ( | | 25 | +from vertexai.evaluation import _base as eval_base | | 26 | +from vertexai.evaluation import _evaluation | | 27 | +from vertexai.evaluation import constants | | 28 | +from vertexai.evaluation import utils | | 29 | +from vertexai.evaluation.metrics import ( | 30 | 30 | _base as metrics_base, | 31 | 31 | ) | 32 | | -from vertexai.preview.evaluation.metrics import ( | | 32 | +from vertexai.evaluation.metrics import ( | 33 | 33 | pairwise_metric, | 34 | 34 | ) | 35 | | -from vertexai.preview.evaluation.metrics import ( | | 35 | +from vertexai.evaluation.metrics import ( | 36 | 36 | pointwise_metric, | 37 | 37 | ) | 38 | 38 | import numpy as np | |
Collapse file Copy file name to clipboard +50Lines changed: 50 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +# -*- coding: utf-8 -*- | | 2 | + | | 3 | +# Copyright 2024 Google LLC | | 4 | +# | | 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); | | 6 | +# you may not use this file except in compliance with the License. | | 7 | +# You may obtain a copy of the License at | | 8 | +# | | 9 | +# http://www.apache.org/licenses/LICENSE-2.0 | | 10 | +# | | 11 | +# Unless required by applicable law or agreed to in writing, software | | 12 | +# distributed under the License is distributed on an "AS IS" BASIS, | | 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | | 14 | +# See the License for the specific language governing permissions and | | 15 | +# limitations under the License. | | 16 | +# | | 17 | +"""Evaluation Metrics Module.""" | | 18 | + | | 19 | +from vertexai.evaluation.metrics import _base | | 20 | +from vertexai.evaluation.metrics import _rouge | | 21 | +from vertexai.evaluation.metrics import ( | | 22 | + metric_prompt_template, | | 23 | +) | | 24 | +from vertexai.evaluation.metrics import ( | | 25 | + metric_prompt_template_examples, | | 26 | +) | | 27 | +from vertexai.evaluation.metrics import pairwise_metric | | 28 | +from vertexai.evaluation.metrics import pointwise_metric | | 29 | + | | 30 | + | | 31 | +PairwiseMetric = pairwise_metric.PairwiseMetric | | 32 | +PointwiseMetric = pointwise_metric.PointwiseMetric | | 33 | +CustomMetric = _base.CustomMetric | | 34 | +PairwiseMetricPromptTemplate = metric_prompt_template.PairwiseMetricPromptTemplate | | 35 | +PointwiseMetricPromptTemplate = metric_prompt_template.PointwiseMetricPromptTemplate | | 36 | +MetricPromptTemplateExamples = ( | | 37 | + metric_prompt_template_examples.MetricPromptTemplateExamples | | 38 | +) | | 39 | +Rouge = _rouge.Rouge | | 40 | + | | 41 | + | | 42 | +__all__ = [ | | 43 | + "CustomMetric", | | 44 | + "PairwiseMetric", | | 45 | + "PointwiseMetric", | | 46 | + "PairwiseMetricPromptTemplate", | | 47 | + "PointwiseMetricPromptTemplate", | | 48 | + "MetricPromptTemplateExamples", | | 49 | + "Rouge", | | 50 | +] |
Collapse file Copy file name to clipboardExpand all lines: vertexai/evaluation/metrics/_base.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 19 | 19 | import abc | 20 | 20 | from typing import Any, Callable, Dict, Literal, Union | 21 | 21 |
| 22 | | -from vertexai.preview.evaluation import constants | 23 | | -from vertexai.preview.evaluation.metrics import ( | | 22 | +from vertexai.evaluation import constants | | 23 | +from vertexai.evaluation.metrics import ( | 24 | 24 | metric_prompt_template as metric_prompt_template_base, | 25 | 25 | ) | 26 | 26 |
| |
Collapse file Copy file name to clipboard File renamed without changes. Collapse file Copy file name to clipboardExpand all lines: vertexai/evaluation/metrics/_instance_evaluation.py +10-10Lines changed: 10 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 22 | 22 | from google import api_core | 23 | 23 | from google.cloud.aiplatform import base | 24 | 24 | from google.cloud.aiplatform import initializer | 25 | | -from google.cloud.aiplatform_v1beta1.services import ( | | 25 | +from google.cloud.aiplatform_v1.services import ( | 26 | 26 | evaluation_service as gapic_evaluation_services, | 27 | 27 | ) | 28 | | -from google.cloud.aiplatform_v1beta1.types import ( | | 28 | +from google.cloud.aiplatform_v1.types import ( | 29 | 29 | evaluation_service as gapic_eval_service_types, | 30 | 30 | ) | 31 | | -from vertexai.preview.evaluation import _base as eval_base | 32 | | -from vertexai.preview.evaluation import constants | 33 | | -from vertexai.preview.evaluation import utils | 34 | | -from vertexai.preview.evaluation import ( | | 31 | +from vertexai.evaluation import _base as eval_base | | 32 | +from vertexai.evaluation import constants | | 33 | +from vertexai.evaluation import utils | | 34 | +from vertexai.evaluation import ( | 35 | 35 | prompt_template as prompt_template_base, | 36 | 36 | ) | 37 | | -from vertexai.preview.evaluation.metrics import ( | | 37 | +from vertexai.evaluation.metrics import ( | 38 | 38 | _base as metrics_base, | 39 | 39 | ) | 40 | | -from vertexai.preview.evaluation.metrics import _rouge | 41 | | -from vertexai.preview.evaluation.metrics import pairwise_metric | 42 | | -from vertexai.preview.evaluation.metrics import pointwise_metric | | 40 | +from vertexai.evaluation.metrics import _rouge | | 41 | +from vertexai.evaluation.metrics import pairwise_metric | | 42 | +from vertexai.evaluation.metrics import pointwise_metric | 43 | 43 | from google.protobuf import json_format | 44 | 44 |
| 45 | 45 |
| |
|