Skip to content

Commit e27be71

Browse files
Copilotslister1001
andcommitted
Refactor _evaluate_query to public evaluate_query parameter with backward compatibility
Co-authored-by: slister1001 <[email protected]>
1 parent a9a6f06 commit e27be71

File tree

12 files changed

+47
-31
lines changed

12 files changed

+47
-31
lines changed

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_evaluators/_code_vulnerability/_code_vulnerability.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ def __init__(
8989
credential,
9090
azure_ai_project,
9191
*,
92-
_evaluate_query: bool = True,
92+
evaluate_query: bool = True,
9393
):
9494
super().__init__(
9595
eval_metric=EvaluationMetrics.CODE_VULNERABILITY,
9696
azure_ai_project=azure_ai_project,
9797
credential=credential,
98-
_evaluate_query=_evaluate_query,
98+
evaluate_query=evaluate_query,
9999
)
100100

101101
@overload

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_evaluators/_common/_base_rai_svc_eval.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ class RaiServiceEvaluatorBase(EvaluatorBase[T]):
4141
:type conversation_aggregation_type: ~azure.ai.evaluation._AggregationType
4242
:param threshold: The threshold for the evaluation. Default is 3.
4343
:type threshold: Optional[int]
44-
:param _evaluate_query: If True, the query will be included in the evaluation data when evaluating
44+
:param evaluate_query: If True, the query will be included in the evaluation data when evaluating
4545
query-response pairs. If False, only the response will be evaluated. Default is False.
46-
:type _evaluate_query: bool
46+
:type evaluate_query: bool
4747
:param _higher_is_better: If True, higher scores are better. Default is True.
4848
:type _higher_is_better: Optional[bool]
4949
"""
@@ -57,8 +57,10 @@ def __init__(
5757
eval_last_turn: bool = False,
5858
conversation_aggregation_type: _AggregationType = _AggregationType.MEAN,
5959
threshold: int = 3,
60-
_evaluate_query: bool = False,
60+
evaluate_query: bool = False,
6161
_higher_is_better: Optional[bool] = False,
62+
*,
63+
_evaluate_query: Optional[bool] = None,
6264
):
6365
super().__init__(
6466
eval_last_turn=eval_last_turn,
@@ -70,7 +72,21 @@ def __init__(
7072
self._azure_ai_project = validate_azure_ai_project(azure_ai_project)
7173
self._credential = credential
7274
self._threshold = threshold
73-
self._evaluate_query = _evaluate_query
75+
76+
# Handle backward compatibility with _evaluate_query parameter
77+
if _evaluate_query is not None:
78+
import warnings
79+
warnings.warn(
80+
"The '_evaluate_query' parameter is deprecated. Use 'evaluate_query' instead.",
81+
DeprecationWarning,
82+
stacklevel=2
83+
)
84+
# If both are provided, that's an error
85+
if evaluate_query != False: # evaluate_query was explicitly set to something other than default
86+
raise ValueError("Cannot specify both 'evaluate_query' and '_evaluate_query'. Use 'evaluate_query'.")
87+
evaluate_query = _evaluate_query
88+
89+
self._evaluate_query = evaluate_query
7490
self._higher_is_better = _higher_is_better
7591

7692
@override

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_evaluators/_content_safety/_content_safety.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class ContentSafetyEvaluator(MultiEvaluatorBase[Union[str, float]]):
3333
:type self_harm_threshold: int
3434
:param hate_unfairness_threshold: The threshold for hate/unfairness evaluation. Default is 3.
3535
:type hate_unfairness_threshold: int
36-
:param _evaluate_query: Whether to also evaluate the query in addition to the response. Default is False.
37-
:type _evaluate_query: bool
36+
:param evaluate_query: Whether to also evaluate the query in addition to the response. Default is False.
37+
:type evaluate_query: bool
3838
:param kwargs: Additional arguments to pass to the evaluator.
3939
:type kwargs: Any
4040
:return: A function that evaluates content-safety metrics for "question-answering" scenario.
@@ -81,7 +81,7 @@ def __init__(
8181
sexual_threshold: int = 3,
8282
self_harm_threshold: int = 3,
8383
hate_unfairness_threshold: int = 3,
84-
_evaluate_query: bool = False,
84+
evaluate_query: bool = False,
8585
**kwargs,
8686
):
8787
# Type checking
@@ -96,14 +96,14 @@ def __init__(
9696

9797
evaluators = [
9898
ViolenceEvaluator(
99-
credential, azure_ai_project, threshold=violence_threshold, _evaluate_query=_evaluate_query
99+
credential, azure_ai_project, threshold=violence_threshold, evaluate_query=evaluate_query
100100
),
101-
SexualEvaluator(credential, azure_ai_project, threshold=sexual_threshold, _evaluate_query=_evaluate_query),
101+
SexualEvaluator(credential, azure_ai_project, threshold=sexual_threshold, evaluate_query=evaluate_query),
102102
SelfHarmEvaluator(
103-
credential, azure_ai_project, threshold=self_harm_threshold, _evaluate_query=_evaluate_query
103+
credential, azure_ai_project, threshold=self_harm_threshold, evaluate_query=evaluate_query
104104
),
105105
HateUnfairnessEvaluator(
106-
credential, azure_ai_project, threshold=hate_unfairness_threshold, _evaluate_query=_evaluate_query
106+
credential, azure_ai_project, threshold=hate_unfairness_threshold, evaluate_query=evaluate_query
107107
),
108108
]
109109
super().__init__(evaluators=evaluators, **kwargs)

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_evaluators/_content_safety/_hate_unfairness.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def __init__(
9191
azure_ai_project,
9292
*,
9393
threshold: int = 3,
94-
_evaluate_query: bool = False,
94+
evaluate_query: bool = False,
9595
):
9696
super().__init__(
9797
eval_metric=EvaluationMetrics.HATE_FAIRNESS,
@@ -100,7 +100,7 @@ def __init__(
100100
conversation_aggregation_type=_AggregationType.MAX,
101101
threshold=threshold,
102102
_higher_is_better=False,
103-
_evaluate_query=_evaluate_query,
103+
evaluate_query=evaluate_query,
104104
)
105105

106106
@overload

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_evaluators/_content_safety/_self_harm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def __init__(
7676
azure_ai_project,
7777
*,
7878
threshold: int = 3,
79-
_evaluate_query: bool = False,
79+
evaluate_query: bool = False,
8080
):
8181
super().__init__(
8282
eval_metric=EvaluationMetrics.SELF_HARM,
@@ -85,7 +85,7 @@ def __init__(
8585
conversation_aggregation_type=_AggregationType.MAX,
8686
threshold=threshold,
8787
_higher_is_better=False,
88-
_evaluate_query=_evaluate_query,
88+
evaluate_query=evaluate_query,
8989
)
9090

9191
@overload

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_evaluators/_content_safety/_sexual.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def __init__(
8787
azure_ai_project,
8888
*,
8989
threshold: int = 3,
90-
_evaluate_query: bool = False,
90+
evaluate_query: bool = False,
9191
):
9292
super().__init__(
9393
eval_metric=EvaluationMetrics.SEXUAL,
@@ -96,7 +96,7 @@ def __init__(
9696
conversation_aggregation_type=_AggregationType.MAX,
9797
threshold=threshold,
9898
_higher_is_better=False,
99-
_evaluate_query=_evaluate_query,
99+
evaluate_query=evaluate_query,
100100
)
101101

102102
@overload

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_evaluators/_content_safety/_violence.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def __init__(
8787
azure_ai_project,
8888
*,
8989
threshold: int = 3,
90-
_evaluate_query: bool = False,
90+
evaluate_query: bool = False,
9191
):
9292
super().__init__(
9393
eval_metric=EvaluationMetrics.VIOLENCE,
@@ -96,7 +96,7 @@ def __init__(
9696
conversation_aggregation_type=_AggregationType.MAX,
9797
threshold=threshold,
9898
_higher_is_better=False,
99-
_evaluate_query=_evaluate_query,
99+
evaluate_query=evaluate_query,
100100
)
101101

102102
@overload

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_evaluators/_eci/_eci.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ def __init__(
6060
credential,
6161
azure_ai_project,
6262
*,
63-
_evaluate_query: bool = False,
63+
evaluate_query: bool = False,
6464
):
6565
super().__init__(
6666
eval_metric=_InternalEvaluationMetrics.ECI,
6767
azure_ai_project=azure_ai_project,
6868
credential=credential,
69-
_evaluate_query=_evaluate_query,
69+
evaluate_query=evaluate_query,
7070
)
7171

7272
@overload

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_evaluators/_protected_material/_protected_material.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ def __init__(
6060
credential,
6161
azure_ai_project,
6262
*,
63-
_evaluate_query: bool = True,
63+
evaluate_query: bool = True,
6464
):
6565
super().__init__(
6666
eval_metric=EvaluationMetrics.PROTECTED_MATERIAL,
6767
azure_ai_project=azure_ai_project,
6868
credential=credential,
69-
_evaluate_query=_evaluate_query,
69+
evaluate_query=evaluate_query,
7070
)
7171

7272
@overload

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_evaluators/_service_groundedness/_service_groundedness.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __init__(
7777
azure_ai_project,
7878
*,
7979
threshold: int = 5,
80-
_evaluate_query: bool = False,
80+
evaluate_query: bool = False,
8181
**kwargs,
8282
):
8383
self.threshold = threshold
@@ -88,7 +88,7 @@ def __init__(
8888
azure_ai_project=azure_ai_project,
8989
credential=credential,
9090
threshold=self.threshold,
91-
_evaluate_query=_evaluate_query,
91+
evaluate_query=evaluate_query,
9292
**kwargs,
9393
)
9494

0 commit comments

Comments
 (0)