diff --git a/vertexai/evaluation/notebook_utils.py b/vertexai/evaluation/notebook_utils.py index 0d29e5efcb..f6b8cc7a64 100644 --- a/vertexai/evaluation/notebook_utils.py +++ b/vertexai/evaluation/notebook_utils.py @@ -16,6 +16,7 @@ # """Python functions which run only within a Jupyter or Colab notebook.""" +import html as html_lib import random import string import sys @@ -153,7 +154,9 @@ def display_explanations( for _, row in df.iterrows(): for col in df.columns: - display(HTML(f"

{col}:

{row[col]}
")) + safe_col = html_lib.escape(str(col)) + safe_val = html_lib.escape(str(row[col])) + display(HTML(f"

{safe_col}:

{safe_val}
")) display(HTML("
")) diff --git a/vertexai/preview/evaluation/notebook_utils.py b/vertexai/preview/evaluation/notebook_utils.py index 942945ca13..175771f8c7 100644 --- a/vertexai/preview/evaluation/notebook_utils.py +++ b/vertexai/preview/evaluation/notebook_utils.py @@ -16,6 +16,7 @@ # """Python functions which run only within a Jupyter or Colab notebook.""" +import html as html_lib import random import string import sys @@ -153,7 +154,9 @@ def display_explanations( for _, row in df.iterrows(): for col in df.columns: - display(HTML(f"

{col}:

{row[col]}
")) + safe_col = html_lib.escape(str(col)) + safe_val = html_lib.escape(str(row[col])) + display(HTML(f"

{safe_col}:

{safe_val}
")) display(HTML("
"))