File tree 2 files changed +21
-0
lines changed
google/cloud/aiplatform/utils
2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 17
17
18
18
import sys
19
19
import typing
20
+ import urllib
20
21
from uuid import uuid4
21
22
from typing import Optional
22
23
@@ -266,3 +267,18 @@ def display_browse_prebuilt_metrics_button() -> None:
266
267
"https://cloud.google.com/vertex-ai/generative-ai/docs/models/metrics-templates"
267
268
)
268
269
display_link ("Browse pre-built metrics" , uri , "list" )
270
+
271
+
272
+ def display_gen_ai_evaluation_results_button (
273
+ gcs_file_path : Optional [str ] = None ,
274
+ ) -> None :
275
+ """Function to generate a link bound to the Gen AI evaluation run."""
276
+ if not is_ipython_available ():
277
+ return
278
+
279
+ uri = "https://cloud.google.com/vertex-ai/generative-ai/docs/models/view-evaluation"
280
+ if gcs_file_path is not None :
281
+ gcs_file_path = urllib .parse .quote (gcs_file_path )
282
+ uri = f"https://console.cloud.google.com/storage/browser/_details/{ gcs_file_path } ;colab_enterprise=gen_ai_evaluation"
283
+
284
+ display_link ("View evaluation results" , uri , "bar_chart" )
Original file line number Diff line number Diff line change 29
29
from google .cloud .aiplatform import compat
30
30
from google .cloud .aiplatform import initializer
31
31
from google .cloud .aiplatform import utils
32
+ from google .cloud .aiplatform .utils import _ipython_utils
32
33
from google .cloud .aiplatform_v1 .services import (
33
34
evaluation_service as gapic_evaluation_services ,
34
35
)
@@ -295,12 +296,16 @@ def upload_evaluation_results(
295
296
file_name: File name to store the data.
296
297
"""
297
298
if not destination_uri_prefix :
299
+ _ipython_utils .display_gen_ai_evaluation_results_button ()
298
300
return
299
301
if destination_uri_prefix .startswith (_GCS_PREFIX ):
300
302
_ , extension = os .path .splitext (file_name )
301
303
file_type = extension .lower ()[1 :]
302
304
output_path = destination_uri_prefix + "/" + file_name
303
305
_upload_pandas_df_to_gcs (dataset , output_path , file_type )
306
+ _ipython_utils .display_gen_ai_evaluation_results_button (
307
+ output_path .split (_GCS_PREFIX )[1 ]
308
+ )
304
309
else :
305
310
raise ValueError (
306
311
f"Unsupported destination URI: { destination_uri_prefix } ."
You can’t perform that action at this time.
0 commit comments