Skip to content

Commit c130cf4

Browse files
authored
Fix __call__ Overload Types (Azure#38238)
* Fix __call__ overload issues * fix typing issue * make query required for groundednesspro * fix a malformatted docstring * fix some type hints and remove eval_last_turn from evaluators * fix optional import * comment out eval last turn section
1 parent 67b6cfb commit c130cf4

File tree

16 files changed

+32
-47
lines changed

16 files changed

+32
-47
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ def __call__( # pylint: disable=docstring-missing-param
9393
or a conversation for a potentially multi-turn evaluation. If the conversation has more than one pair of
9494
turns, the evaluator will aggregate the results of each turn.
9595
96+
:keyword query: The query to be evaluated.
97+
:paramtype query: str
9698
:keyword response: The response to be evaluated.
9799
:paramtype response: Optional[str]
98-
:keyword context: The context to be evaluated.
99-
:paramtype context: Optional[str]
100100
:keyword conversation: The conversation to evaluate. Expected to contain a list of conversation turns under the
101101
key "messages". Conversation turns are expected
102102
to be dictionaries with keys "content" and "role".

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ class ContentSafetyEvaluator(EvaluatorBase[Union[str, float]]):
2727
:param azure_ai_project: The scope of the Azure AI project.
2828
It contains subscription id, resource group, and project name.
2929
:type azure_ai_project: ~azure.ai.evaluation.AzureAIProject
30-
:param eval_last_turn: Whether to evaluate the last turn of a conversation. Default is False.
31-
:type eval_last_turn: bool
3230
:param kwargs: Additional arguments to pass to the evaluator.
3331
:type kwargs: Any
3432
:return: A function that evaluates content-safety metrics for "question-answering" scenario.
@@ -69,8 +67,8 @@ class ContentSafetyEvaluator(EvaluatorBase[Union[str, float]]):
6967
"""
7068

7169
# TODO address 3579092 to re-enabled parallel evals.
72-
def __init__(self, credential, azure_ai_project, eval_last_turn: bool = False, **kwargs):
73-
super().__init__(eval_last_turn=eval_last_turn)
70+
def __init__(self, credential, azure_ai_project, **kwargs):
71+
super().__init__()
7472
self._parallel = kwargs.pop("_parallel", False)
7573
self._evaluators: List[Callable[..., Dict[str, Union[str, float]]]] = [
7674
ViolenceEvaluator(credential, azure_ai_project),

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,11 @@ def __init__(
5050
self,
5151
credential,
5252
azure_ai_project,
53-
eval_last_turn: bool = False,
5453
):
5554
super().__init__(
5655
eval_metric=EvaluationMetrics.HATE_FAIRNESS,
5756
azure_ai_project=azure_ai_project,
5857
credential=credential,
59-
eval_last_turn=eval_last_turn,
6058
)
6159

6260
@overload

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,11 @@ def __init__(
5050
self,
5151
credential,
5252
azure_ai_project,
53-
eval_last_turn: bool = False,
5453
):
5554
super().__init__(
5655
eval_metric=EvaluationMetrics.SELF_HARM,
5756
azure_ai_project=azure_ai_project,
5857
credential=credential,
59-
eval_last_turn=eval_last_turn,
6058
)
6159

6260
@overload

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,11 @@ def __init__(
5050
self,
5151
credential,
5252
azure_ai_project,
53-
eval_last_turn: bool = False,
5453
):
5554
super().__init__(
5655
eval_metric=EvaluationMetrics.SEXUAL,
5756
azure_ai_project=azure_ai_project,
5857
credential=credential,
59-
eval_last_turn=eval_last_turn,
6058
)
6159

6260
@overload

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,11 @@ def __init__(
5050
self,
5151
credential,
5252
azure_ai_project,
53-
eval_last_turn: bool = False,
5453
):
5554
super().__init__(
5655
eval_metric=EvaluationMetrics.VIOLENCE,
5756
azure_ai_project=azure_ai_project,
5857
credential=credential,
59-
eval_last_turn=eval_last_turn,
6058
)
6159

6260
@overload

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,11 @@ def __init__(
5555
self,
5656
credential,
5757
azure_ai_project,
58-
eval_last_turn: bool = False,
5958
):
6059
super().__init__(
6160
eval_metric=_InternalEvaluationMetrics.ECI,
6261
azure_ai_project=azure_ai_project,
6362
credential=credential,
64-
eval_last_turn=eval_last_turn,
6563
)
6664

6765
@overload

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def __call__(
5555
*,
5656
response: str,
5757
) -> Dict[str, Union[str, float]]:
58-
"""Evaluate fluency in given query/response
58+
"""Evaluate fluency in given response
5959
6060
:keyword response: The response to be evaluated.
6161
:paramtype response: str

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,11 @@ def __init__(
5656
self,
5757
credential,
5858
azure_ai_project,
59-
eval_last_turn: bool = False,
6059
):
6160
super().__init__(
6261
eval_metric=EvaluationMetrics.PROTECTED_MATERIAL,
6362
azure_ai_project=azure_ai_project,
6463
credential=credential,
65-
eval_last_turn=eval_last_turn,
6664
)
6765

6866
@overload

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,14 @@ def __call__(
180180
self,
181181
*,
182182
conversation: Conversation,
183-
) -> Dict[str, Union[float, Dict[str, List[float]]]]:
183+
) -> Dict[str, Union[float, Dict[str, List[Union[str, float]]]]]:
184184
"""Evaluates retrieval for a for a multi-turn evaluation. If the conversation has more than one turn,
185185
the evaluator will aggregate the results of each turn.
186186
187187
:keyword conversation: The conversation to be evaluated.
188188
:paramtype conversation: Optional[~azure.ai.evaluation.Conversation]
189189
:return: The scores for Chat scenario.
190-
:rtype: :rtype: Dict[str, Union[float, Dict[str, List[float]]]]
190+
:rtype: Dict[str, Union[float, Dict[str, List[float]]]]
191191
"""
192192

193193
def __call__(self, *args, **kwargs): # pylint: disable=docstring-missing-param
@@ -202,7 +202,7 @@ def __call__(self, *args, **kwargs): # pylint: disable=docstring-missing-param
202202
:keyword conversation: The conversation to be evaluated.
203203
:paramtype conversation: Optional[~azure.ai.evaluation.Conversation]
204204
:return: The scores for Chat scenario.
205-
:rtype: :rtype: Dict[str, Union[float, Dict[str, List[float]]]]
205+
:rtype: :rtype: Dict[str, Union[float, Dict[str, List[str, float]]]]
206206
"""
207207
query = kwargs.pop("query", None)
208208
context = kwargs.pop("context", None)

0 commit comments

Comments
 (0)