[Evaluation] Align shared evaluator utils/validators/base with azureml-assets builtin#47840
[Evaluation] Align shared evaluator utils/validators/base with azureml-assets builtin#47840m7md7sien wants to merge 1 commit into
Conversation
445bd64 to
17134a7
Compare
…ets builtin Backport parity changes so azureml-assets builtin evaluators can import shared code from the SDK instead of inlining overrides: - _normalize_function_call_types: also normalize openapi_call/openapi_call_output - _extract_needed_tool_definitions: conditional OpenAPI functions expansion - expand nested functions when present, else keep the top-level def (incorporates Azure#46236) - _get_agent_response + tool_call_success _get_tool_calls_results: render tool results as JSON via _stringify_tool_result (grounding tools); strings unchanged - reformat_* helpers + Groundedness context extraction + tool_call_success reformat helpers: stop logging raw payloads in fallback/debug paths via _log_safe_summary (incorporates Azure#5158) - _get_conversation_history/reformat_conversation_history: opt-in include_tool_calls inline rendering - Add shared helpers: _stringify_tool_result, _log_safe_summary, _coerce_bool, _coerce_number, _collect_failed_tool_calls, _get_tool_calls_results, _reformat_tool_calls_results - ErrorTarget: add QUALITY_GRADER/CUSTOMER_SATISFACTION/DEFLECTION_RATE/REGEX_MATCH members Adds unit tests; black (24.4.0) clean.
17134a7 to
68a4dc8
Compare
There was a problem hiding this comment.
Pull request overview
This PR backports shared evaluator utilities in azure-ai-evaluation so they align with the divergent azureml-assets builtin evaluators, enabling the builtin evaluators to eventually import these symbols directly from the SDK. It reconciles diverged shared code (OpenAPI normalization/expansion, JSON-rendered tool results), makes fallback/debug logging PII-safe, and adds new additive helpers. All shared-function changes are described as backward-compatible supersets.
Changes:
- Bucket C:
_normalize_function_call_typesnow also mapsopenapi_call/openapi_call_output→tool_call/tool_result;_extract_needed_tool_definitionsexpands OpenAPI tools into nested functions when present;_get_agent_response/conversation-history helpers render tool results as JSON via the new_stringify_tool_resultand add an opt-ininclude_tool_callspath. - Bucket D: fallback/debug logging in reformat helpers and Groundedness now emits structural-only summaries via
_log_safe_summary, never raw payloads. - Bucket E: new shared helpers (
_stringify_tool_result,_log_safe_summary,_coerce_bool,_coerce_number,_collect_failed_tool_calls,_get_tool_calls_results,_reformat_tool_calls_results) plus 4 newErrorTargetmembers.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
_common/utils.py |
Adds the new shared helpers, include_tool_calls conversation path, JSON tool-result rendering, and PII-safe fallback logging. |
_evaluators/_common/_base_prompty_eval.py |
Extends _normalize_function_call_types for OpenAPI types and rewrites OpenAPI tool-definition expansion; removes now-unused chain import. |
_evaluators/_tool_call_success/_tool_call_success.py |
Uses _stringify_tool_result and switches fallback logs to _log_safe_summary. |
_evaluators/_groundedness/_groundedness.py |
Replaces payload-logging debug line with a count-only summary. |
_exceptions.py |
Adds four new ErrorTarget enum members for parity. |
CHANGELOG.md |
Documents the OpenAPI fix and the "Other Changes" (normalization, JSON tool results, PII-safe logging). |
tests/unittests/test_utils.py |
Adds TestToolResultAndLoggingHelpers covering the new helpers and ErrorTarget members. |
tests/unittests/test_tool_call_success_logging.py |
New tests asserting fallback paths don't leak raw payloads. |
tests/unittests/test_tool_call_accuracy_evaluator.py |
Adds OpenAPI tool-definition expansion/validation tests. |
tests/unittests/test_multi_turn_utilities.py |
Adds an OpenAPI normalization preprocessing test. |
Notes on findings: The description's Bucket C MessagesOrQueryResponseInputValidator mid-execution guard (and the associated test_last_message_tool_role_accepted update) is not present in the diff or the current code, and the two _get_tool_calls_results/_reformat_tool_calls_results copies now diverge in argument formatting.
Description
Backports the changes where the azureml-assets builtin evaluators are ahead of / diverged from the shared
azure-ai-evaluationcode, so the builtin evaluators can eventually import these symbols directly from the SDK instead of inlining private copies. Grouped as buckets C (reconcile diverged shared code), D (PII-safe logging), and E (additive helpers) from the parity analysis.Bucket C — reconcile diverged shared code
_normalize_function_call_types(_evaluators/_common/_base_prompty_eval.py): also normalizeopenapi_call/openapi_call_output→tool_call/tool_result(kept the existingfunction_callkey-rename, so this is a strict superset). This also unblocks importing the widely-used_preprocess_messages._get_agent_response(_common/utils.py): render tool results via the new_stringify_tool_result, so list/dict grounding-tool outputs (Azure AI Search, SharePoint, Fabric) are readable JSON instead of a Pythonrepr. Plain string results are unchanged → backward compatible._get_conversation_history/reformat_conversation_history: new opt-ininclude_tool_callspath that renders tool calls/results inline. Default behavior is unchanged.Bucket D — PII-safe fallback logging
reformat_agent_response,reformat_conversation_history, andreformat_tool_definitionsnow emit richer, structural-only fallback summaries via the new_log_safe_summary(never raw payloads).Bucket E — additive shared helpers
_common/utils.py:_stringify_tool_result,_log_safe_summary,_coerce_bool,_coerce_number,_collect_failed_tool_calls,_get_tool_calls_results,_reformat_tool_calls_results.EvaluationLevelalready exists in_common/constants.py— not re-added._create_extended_error_target, added the missingErrorTargetmembers:QUALITY_GRADER_EVALUATOR,CUSTOMER_SATISFACTION_EVALUATOR,DEFLECTION_RATE_EVALUATOR,REGEX_MATCH_EVALUATOR(the other extended names already existed).Testing
TestToolResultAndLoggingHelpersintest_utils.pyand an OpenAPI preprocessing test intest_multi_turn_utilities.py. Pre-existing OpenAPI-normalization tests now pass.test_multi_turn_utilities.py,test_common_validators.py,test_utils.py: 201 passed.black(24.4.0, repo config) clean.Notes