Skip to content

Commit 75fe949

Browse files
[fix] logs and aoai list to string (#43993)
Co-authored-by: zyysurely <yingyingzhao@microsoft.com>
1 parent 392008a commit 75fe949

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_evaluate/_evaluate.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ def _build_internal_log_attributes(
10601060
event_data: Dict[str, Any],
10611061
metric_name: str,
10621062
evaluator_config: Optional[Dict[str, EvaluatorConfig]],
1063-
internal_log_attributes: Dict[str, str],
1063+
log_attributes: Dict[str, str],
10641064
) -> Dict[str, str]:
10651065
"""
10661066
Build internal log attributes for OpenTelemetry logging.
@@ -1074,6 +1074,8 @@ def _build_internal_log_attributes(
10741074
:return: Dictionary of internal log attributes
10751075
:rtype: Dict[str, str]
10761076
"""
1077+
# Create a copy of the base log attributes
1078+
internal_log_attributes: Dict[str, str] = log_attributes.copy()
10771079
# Add threshold if present
10781080
if event_data.get("threshold"):
10791081
internal_log_attributes["gen_ai.evaluation.threshold"] = str(event_data["threshold"])
@@ -1104,6 +1106,12 @@ def _build_internal_log_attributes(
11041106
internal_log_attributes["gen_ai.evaluation.min_value"] = str(metric_config_detail["min_value"])
11051107
if metric_config_detail.get("max_value") is not None:
11061108
internal_log_attributes["gen_ai.evaluation.max_value"] = str(metric_config_detail["max_value"])
1109+
if metric_config_detail.get("desirable_direction") is not None:
1110+
internal_log_attributes["gen_ai.evaluation.desirable_direction"] = str(
1111+
metric_config_detail["desirable_direction"]
1112+
)
1113+
if metric_config_detail.get("type") is not None:
1114+
internal_log_attributes["gen_ai.evaluation.type"] = str(metric_config_detail["type"])
11071115

11081116
return internal_log_attributes
11091117

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_evaluate/_evaluate_aoai.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -862,12 +862,8 @@ def _convert_value_to_string(val: Any) -> str:
862862
for _, rel_parts, df_col in path_specs:
863863
# Safely fetch value
864864
val = row.get(df_col, None)
865-
866-
if isinstance(val, list):
867-
str_val = val
868-
else:
869-
# Convert value to string to match schema's "type": "string" leaves.
870-
str_val = _convert_value_to_string(val)
865+
# Convert value to string to match schema's "type": "string" leaves.
866+
str_val = _convert_value_to_string(val)
871867

872868
# Insert into nested dict
873869
cursor = item_root
@@ -887,10 +883,7 @@ def _convert_value_to_string(val: Any) -> str:
887883
for col_name in input_data_df.columns:
888884
if col_name not in processed_cols:
889885
val = row.get(col_name, None)
890-
if isinstance(val, list):
891-
str_val = val
892-
else:
893-
str_val = _convert_value_to_string(val)
886+
str_val = _convert_value_to_string(val)
894887
item_root[col_name] = str_val
895888

896889
content.append({WRAPPER_KEY: item_root})

0 commit comments

Comments
 (0)