Skip to content

Commit 9a8f379

Browse files
authored
[Evaluation] Rename parameter name project_scope to azure_ai_project (#37409)
* Rename project_scope to azure_ai_project * fix the docstring * try to fix the docstring again
1 parent 6e5a7d6 commit 9a8f379

File tree

14 files changed

+106
-96
lines changed

14 files changed

+106
-96
lines changed

sdk/evaluation/azure-ai-evaluation/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## 1.0.0b1 (Unreleased)
44

5+
6+
### Breaking Changes
7+
8+
- The parameter name `project_scope` in content safety evaluators have been renamed to `azure_ai_project` for consistency with evaluate API and simulators.
9+
10+
511
### Features Added
612

713
- First preview

sdk/evaluation/azure-ai-evaluation/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ if __name__ == "__main__":
6161
# Content Safety Evaluator
6262

6363
# Initialize Project Scope
64-
project_scope = {
64+
azure_ai_project = {
6565
"subscription_id": "e0fd569c-e34a-4249-8c24-e8d723c7f054",
6666
"resource_group_name": "rg-test",
6767
"project_name": "project-test",
6868
}
6969

70-
violence_eval = ViolenceEvaluator(project_scope)
70+
violence_eval = ViolenceEvaluator(azure_ai_project)
7171
violence_score = violence_eval(question="What is the capital of France?", answer="Paris.")
7272
pprint(violence_score)
7373
# {'violence': 'Very low',

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ class ContentSafetyEvaluator:
2121
"""
2222
Initialize a content safety evaluator configured to evaluate content safetry metrics for QA scenario.
2323
24-
:param project_scope: The scope of the Azure AI project.
24+
:param azure_ai_project: The scope of the Azure AI project.
2525
It contains subscription id, resource group, and project name.
26-
:type project_scope: dict
26+
:type azure_ai_project: dict
2727
:param parallel: If True, use parallel execution for evaluators. Else, use sequential execution.
2828
Default is True.
2929
:param credential: The credential for connecting to Azure AI project.
@@ -35,12 +35,12 @@ class ContentSafetyEvaluator:
3535
3636
.. code-block:: python
3737
38-
project_scope = {
38+
azure_ai_project = {
3939
"subscription_id": "<subscription_id>",
4040
"resource_group_name": "<resource_group_name>",
4141
"project_name": "<project_name>",
4242
}
43-
eval_fn = ContentSafetyEvaluator(project_scope)
43+
eval_fn = ContentSafetyEvaluator(azure_ai_project)
4444
result = eval_fn(
4545
question="What is the capital of France?",
4646
answer="Paris.",
@@ -66,13 +66,13 @@ class ContentSafetyEvaluator:
6666
}
6767
"""
6868

69-
def __init__(self, project_scope: dict, parallel: bool = True, credential=None):
69+
def __init__(self, azure_ai_project: dict, parallel: bool = True, credential=None):
7070
self._parallel = parallel
7171
self._evaluators = [
72-
ViolenceEvaluator(project_scope, credential),
73-
SexualEvaluator(project_scope, credential),
74-
SelfHarmEvaluator(project_scope, credential),
75-
HateUnfairnessEvaluator(project_scope, credential),
72+
ViolenceEvaluator(azure_ai_project, credential),
73+
SexualEvaluator(azure_ai_project, credential),
74+
SelfHarmEvaluator(azure_ai_project, credential),
75+
HateUnfairnessEvaluator(azure_ai_project, credential),
7676
]
7777

7878
def __call__(self, *, question: str, answer: str, **kwargs):

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/evaluators/_content_safety/_content_safety_base.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ class ContentSafetyEvaluatorBase(ABC):
1616
1717
:param metric: The metric to be evaluated.
1818
:type metric: ~azure.ai.evaluation.evaluators._content_safety.flow.constants.EvaluationMetrics
19-
:param project_scope: The scope of the Azure AI project.
19+
:param azure_ai_project: The scope of the Azure AI project.
2020
It contains subscription id, resource group, and project name.
21-
:type project_scope: Dict
21+
:type azure_ai_project: Dict
2222
:param credential: The credential for connecting to Azure AI project.
2323
:type credential: ~azure.core.credentials.TokenCredential
2424
"""
2525

26-
def __init__(self, metric: EvaluationMetrics, project_scope: dict, credential=None):
26+
def __init__(self, metric: EvaluationMetrics, azure_ai_project: dict, credential=None):
2727
self._metric = metric
28-
self._project_scope = project_scope
28+
self._azure_ai_project = azure_ai_project
2929
self._credential = credential
3030

3131
async def __call__(self, *, question: str, answer: str, **kwargs):
@@ -51,7 +51,7 @@ async def __call__(self, *, question: str, answer: str, **kwargs):
5151
metric_name=self._metric,
5252
question=question,
5353
answer=answer,
54-
project_scope=self._project_scope,
54+
project_scope=self._azure_ai_project,
5555
credential=self._credential,
5656
)
5757
return result

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/evaluators/_content_safety/_content_safety_chat.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ class ContentSafetyChatEvaluator:
2727
"""
2828
Initialize a content safety chat evaluator configured to evaluate content safetry metrics for chat scenario.
2929
30-
:param project_scope: The scope of the Azure AI project.
30+
:param azure_ai_project: The scope of the Azure AI project.
3131
It contains subscription id, resource group, and project name.
32-
:type project_scope: dict
32+
:type azure_ai_project: dict
3333
:param eval_last_turn: Set to True to evaluate only the most recent exchange in the dialogue,
3434
focusing on the latest user inquiry and the assistant's corresponding response. Defaults to False
3535
:type eval_last_turn: bool
@@ -45,12 +45,16 @@ class ContentSafetyChatEvaluator:
4545
4646
.. code-block:: python
4747
48-
eval_fn = ContentSafetyChatEvaluator(model_config)
49-
conversation = [
48+
azure_ai_project = {
49+
"subscription_id": "<subscription_id>",
50+
"resource_group_name": "<resource_group_name>",
51+
"project_name": "<project_name>",
52+
}
53+
eval_fn = ContentSafetyChatEvaluator(azure_ai_project)
54+
result = eval_fn(conversation=[
5055
{"role": "user", "content": "What is the value of 2 + 2?"},
5156
{"role": "assistant", "content": "2 + 2 = 4"}
52-
]
53-
result = ContentSafetyChatEvaluator(conversation=conversation)
57+
])
5458
5559
**Output format**
5660
@@ -82,14 +86,14 @@ class ContentSafetyChatEvaluator:
8286
}
8387
"""
8488

85-
def __init__(self, project_scope: dict, eval_last_turn: bool = False, parallel: bool = True, credential=None):
89+
def __init__(self, azure_ai_project: dict, eval_last_turn: bool = False, parallel: bool = True, credential=None):
8690
self._eval_last_turn = eval_last_turn
8791
self._parallel = parallel
8892
self._evaluators = [
89-
ViolenceEvaluator(project_scope, credential),
90-
SexualEvaluator(project_scope, credential),
91-
SelfHarmEvaluator(project_scope, credential),
92-
HateUnfairnessEvaluator(project_scope, credential),
93+
ViolenceEvaluator(azure_ai_project, credential),
94+
SexualEvaluator(azure_ai_project, credential),
95+
SelfHarmEvaluator(azure_ai_project, credential),
96+
HateUnfairnessEvaluator(azure_ai_project, credential),
9397
]
9498

9599
def __call__(self, *, conversation, **kwargs):

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212

1313
class _AsyncHateUnfairnessEvaluator(ContentSafetyEvaluatorBase):
14-
def __init__(self, project_scope: dict, credential=None):
14+
def __init__(self, azure_ai_project: dict, credential=None):
1515
# Hate_fairness is the actual backend metric name. Which, uh, doesn't sound great.
1616
# so invert the name.
1717
super().__init__(
1818
metric=EvaluationMetrics.HATE_FAIRNESS,
19-
project_scope=project_scope,
19+
azure_ai_project=azure_ai_project,
2020
credential=credential,
2121
)
2222

@@ -28,22 +28,22 @@ class HateUnfairnessEvaluator:
2828
"""
2929
Initialize a hate-unfairness evaluator for hate unfairness score.
3030
31-
:param project_scope: The scope of the Azure AI project.
31+
:param azure_ai_project: The scope of the Azure AI project.
3232
It contains subscription id, resource group, and project name.
33-
:type project_scope: dict
33+
:type azure_ai_project: dict
3434
:param credential: The credential for connecting to Azure AI project.
3535
:type credential: ~azure.core.credentials.TokenCredential
3636
3737
**Usage**
3838
3939
.. code-block:: python
4040
41-
project_scope = {
41+
azure_ai_project = {
4242
"subscription_id": "<subscription_id>",
4343
"resource_group_name": "<resource_group_name>",
4444
"project_name": "<project_name>",
4545
}
46-
eval_fn = HateUnfairnessEvaluator(project_scope)
46+
eval_fn = HateUnfairnessEvaluator(azure_ai_project)
4747
result = eval_fn(question="What is the capital of France?", answer="Paris.")
4848
4949
**Output format**
@@ -57,8 +57,8 @@ class HateUnfairnessEvaluator:
5757
}
5858
"""
5959

60-
def __init__(self, project_scope: dict, credential=None) -> None:
61-
self._async_evaluator = _AsyncHateUnfairnessEvaluator(project_scope, credential)
60+
def __init__(self, azure_ai_project: dict, credential=None) -> None:
61+
self._async_evaluator = _AsyncHateUnfairnessEvaluator(azure_ai_project, credential)
6262

6363
def __call__(self, *, question: str, answer: str, **kwargs):
6464
"""

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212

1313
class _AsyncSelfHarmEvaluator(ContentSafetyEvaluatorBase):
14-
def __init__(self, project_scope: dict, credential=None):
14+
def __init__(self, azure_ai_project: dict, credential=None):
1515
super().__init__(
1616
metric=EvaluationMetrics.SELF_HARM,
17-
project_scope=project_scope,
17+
azure_ai_project=azure_ai_project,
1818
credential=credential,
1919
)
2020

@@ -26,22 +26,22 @@ class SelfHarmEvaluator:
2626
"""
2727
Initialize a self harm evaluator for self harm score.
2828
29-
:param project_scope: The scope of the Azure AI project.
29+
:param azure_ai_project: The scope of the Azure AI project.
3030
It contains subscription id, resource group, and project name.
31-
:type project_scope: dict
31+
:type azure_ai_project: dict
3232
:param credential: The credential for connecting to Azure AI project.
3333
:type credential: ~azure.core.credentials.TokenCredential
3434
3535
**Usage**
3636
3737
.. code-block:: python
3838
39-
project_scope = {
39+
azure_ai_project = {
4040
"subscription_id": "<subscription_id>",
4141
"resource_group_name": "<resource_group_name>",
4242
"project_name": "<project_name>",
4343
}
44-
eval_fn = SelfHarmEvaluator(project_scope)
44+
eval_fn = SelfHarmEvaluator(azure_ai_project)
4545
result = eval_fn(question="What is the capital of France?", answer="Paris.")
4646
4747
**Output format**
@@ -55,8 +55,8 @@ class SelfHarmEvaluator:
5555
}
5656
"""
5757

58-
def __init__(self, project_scope: dict, credential=None):
59-
self._async_evaluator = _AsyncSelfHarmEvaluator(project_scope, credential)
58+
def __init__(self, azure_ai_project: dict, credential=None):
59+
self._async_evaluator = _AsyncSelfHarmEvaluator(azure_ai_project, credential)
6060

6161
def __call__(self, *, question: str, answer: str, **kwargs):
6262
"""

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212

1313
class _AsyncSexualEvaluator(ContentSafetyEvaluatorBase):
14-
def __init__(self, project_scope: dict, credential=None):
14+
def __init__(self, azure_ai_project: dict, credential=None):
1515
super().__init__(
1616
metric=EvaluationMetrics.SEXUAL,
17-
project_scope=project_scope,
17+
azure_ai_project=azure_ai_project,
1818
credential=credential,
1919
)
2020

@@ -26,22 +26,22 @@ class SexualEvaluator:
2626
"""
2727
Initialize a sexual evaluator for sexual score.
2828
29-
:param project_scope: The scope of the Azure AI project.
29+
:param azure_ai_project: The scope of the Azure AI project.
3030
It contains subscription id, resource group, and project name.
31-
:type project_scope: dict
31+
:type azure_ai_project: dict
3232
:param credential: The credential for connecting to Azure AI project.
3333
:type credential: ~azure.core.credentials.TokenCredential
3434
3535
**Usage**
3636
3737
.. code-block:: python
3838
39-
project_scope = {
39+
azure_ai_project = {
4040
"subscription_id": "<subscription_id>",
4141
"resource_group_name": "<resource_group_name>",
4242
"project_name": "<project_name>",
4343
}
44-
eval_fn = SexualEvaluator(project_scope)
44+
eval_fn = SexualEvaluator(azure_ai_project)
4545
result = eval_fn(question="What is the capital of France?", answer="Paris.")
4646
4747
**Output format**
@@ -55,8 +55,8 @@ class SexualEvaluator:
5555
}
5656
"""
5757

58-
def __init__(self, project_scope: dict, credential=None):
59-
self._async_evaluator = _AsyncSexualEvaluator(project_scope, credential)
58+
def __init__(self, azure_ai_project: dict, credential=None):
59+
self._async_evaluator = _AsyncSexualEvaluator(azure_ai_project, credential)
6060

6161
def __call__(self, *, question: str, answer: str, **kwargs):
6262
"""

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212

1313
class _AsyncViolenceEvaluator(ContentSafetyEvaluatorBase):
14-
def __init__(self, project_scope: dict, credential=None):
14+
def __init__(self, azure_ai_project: dict, credential=None):
1515
super().__init__(
1616
metric=EvaluationMetrics.VIOLENCE,
17-
project_scope=project_scope,
17+
azure_ai_project=azure_ai_project,
1818
credential=credential,
1919
)
2020

@@ -26,22 +26,22 @@ class ViolenceEvaluator:
2626
"""
2727
Initialize a violence evaluator for violence score.
2828
29-
:param project_scope: The scope of the Azure AI project.
29+
:param azure_ai_project: The scope of the Azure AI project.
3030
It contains subscription id, resource group, and project name.
31-
:type project_scope: dict
31+
:type azure_ai_project: dict
3232
:param credential: The credential for connecting to Azure AI project.
3333
:type credential: ~azure.core.credentials.TokenCredential
3434
3535
**Usage**
3636
3737
.. code-block:: python
3838
39-
project_scope = {
39+
azure_ai_project = {
4040
"subscription_id": "<subscription_id>",
4141
"resource_group_name": "<resource_group_name>",
4242
"project_name": "<project_name>",
4343
}
44-
eval_fn = ViolenceEvaluator(project_scope)
44+
eval_fn = ViolenceEvaluator(azure_ai_project)
4545
result = eval_fn(question="What is the capital of France?", answer="Paris.")
4646
4747
**Output format**
@@ -55,8 +55,8 @@ class ViolenceEvaluator:
5555
}
5656
"""
5757

58-
def __init__(self, project_scope: dict, credential=None):
59-
self._async_evaluator = _AsyncViolenceEvaluator(project_scope, credential)
58+
def __init__(self, azure_ai_project: dict, credential=None):
59+
self._async_evaluator = _AsyncViolenceEvaluator(azure_ai_project, credential)
6060

6161
def __call__(self, *, question: str, answer: str, **kwargs):
6262
"""

0 commit comments

Comments
 (0)