azure-ai-evaluation 1.0.0__py3-none-any.whl → 1.0.0b1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of azure-ai-evaluation might be problematic. Click here for more details.
- azure/ai/evaluation/__init__.py +4 -26
- azure/ai/evaluation/_common/constants.py +2 -9
- azure/ai/evaluation/_common/rai_service.py +122 -302
- azure/ai/evaluation/_common/utils.py +35 -393
- azure/ai/evaluation/_constants.py +6 -28
- azure/ai/evaluation/_evaluate/{_batch_run → _batch_run_client}/__init__.py +2 -3
- azure/ai/evaluation/_evaluate/{_batch_run/eval_run_context.py → _batch_run_client/batch_run_context.py} +8 -25
- azure/ai/evaluation/_evaluate/{_batch_run → _batch_run_client}/code_client.py +30 -68
- azure/ai/evaluation/_evaluate/_batch_run_client/proxy_client.py +61 -0
- azure/ai/evaluation/_evaluate/_eval_run.py +40 -117
- azure/ai/evaluation/_evaluate/_evaluate.py +255 -416
- azure/ai/evaluation/_evaluate/_telemetry/__init__.py +19 -24
- azure/ai/evaluation/_evaluate/_utils.py +47 -108
- azure/ai/evaluation/_evaluators/_bleu/_bleu.py +19 -18
- azure/ai/evaluation/_evaluators/{_retrieval → _chat}/__init__.py +2 -2
- azure/ai/evaluation/_evaluators/_chat/_chat.py +350 -0
- azure/ai/evaluation/_evaluators/{_service_groundedness → _chat/retrieval}/__init__.py +2 -2
- azure/ai/evaluation/_evaluators/_chat/retrieval/_retrieval.py +163 -0
- azure/ai/evaluation/_evaluators/_chat/retrieval/retrieval.prompty +48 -0
- azure/ai/evaluation/_evaluators/_coherence/_coherence.py +93 -78
- azure/ai/evaluation/_evaluators/_coherence/coherence.prompty +39 -76
- azure/ai/evaluation/_evaluators/_content_safety/__init__.py +4 -0
- azure/ai/evaluation/_evaluators/_content_safety/_content_safety.py +68 -104
- azure/ai/evaluation/_evaluators/{_multimodal/_content_safety_multimodal_base.py → _content_safety/_content_safety_base.py} +35 -24
- azure/ai/evaluation/_evaluators/_content_safety/_content_safety_chat.py +296 -0
- azure/ai/evaluation/_evaluators/_content_safety/_hate_unfairness.py +54 -105
- azure/ai/evaluation/_evaluators/_content_safety/_self_harm.py +52 -99
- azure/ai/evaluation/_evaluators/_content_safety/_sexual.py +52 -101
- azure/ai/evaluation/_evaluators/_content_safety/_violence.py +51 -101
- azure/ai/evaluation/_evaluators/_eci/_eci.py +55 -45
- azure/ai/evaluation/_evaluators/_f1_score/_f1_score.py +20 -36
- azure/ai/evaluation/_evaluators/_fluency/_fluency.py +94 -76
- azure/ai/evaluation/_evaluators/_fluency/fluency.prompty +41 -66
- azure/ai/evaluation/_evaluators/_gleu/_gleu.py +17 -15
- azure/ai/evaluation/_evaluators/_groundedness/_groundedness.py +92 -113
- azure/ai/evaluation/_evaluators/_groundedness/groundedness.prompty +54 -0
- azure/ai/evaluation/_evaluators/_meteor/_meteor.py +27 -21
- azure/ai/evaluation/_evaluators/_protected_material/_protected_material.py +80 -89
- azure/ai/evaluation/_evaluators/_protected_materials/__init__.py +5 -0
- azure/ai/evaluation/_evaluators/_protected_materials/_protected_materials.py +104 -0
- azure/ai/evaluation/_evaluators/_qa/_qa.py +43 -25
- azure/ai/evaluation/_evaluators/_relevance/_relevance.py +101 -84
- azure/ai/evaluation/_evaluators/_relevance/relevance.prompty +47 -78
- azure/ai/evaluation/_evaluators/_rouge/_rouge.py +27 -27
- azure/ai/evaluation/_evaluators/_similarity/_similarity.py +45 -55
- azure/ai/evaluation/_evaluators/_similarity/similarity.prompty +5 -0
- azure/ai/evaluation/_evaluators/_xpia/xpia.py +106 -91
- azure/ai/evaluation/_exceptions.py +7 -28
- azure/ai/evaluation/_http_utils.py +134 -205
- azure/ai/evaluation/_model_configurations.py +8 -104
- azure/ai/evaluation/_version.py +1 -1
- azure/ai/evaluation/simulator/__init__.py +2 -3
- azure/ai/evaluation/simulator/_adversarial_scenario.py +1 -20
- azure/ai/evaluation/simulator/_adversarial_simulator.py +95 -116
- azure/ai/evaluation/simulator/_constants.py +1 -11
- azure/ai/evaluation/simulator/_conversation/__init__.py +13 -14
- azure/ai/evaluation/simulator/_conversation/_conversation.py +20 -20
- azure/ai/evaluation/simulator/_direct_attack_simulator.py +68 -34
- azure/ai/evaluation/simulator/_helpers/__init__.py +1 -1
- azure/ai/evaluation/simulator/_helpers/_simulator_data_classes.py +28 -31
- azure/ai/evaluation/simulator/_indirect_attack_simulator.py +95 -108
- azure/ai/evaluation/simulator/_model_tools/_identity_manager.py +22 -70
- azure/ai/evaluation/simulator/_model_tools/_proxy_completion_model.py +14 -30
- azure/ai/evaluation/simulator/_model_tools/_rai_client.py +14 -25
- azure/ai/evaluation/simulator/_model_tools/_template_handler.py +24 -68
- azure/ai/evaluation/simulator/_model_tools/models.py +21 -19
- azure/ai/evaluation/simulator/_prompty/task_query_response.prompty +10 -6
- azure/ai/evaluation/simulator/_prompty/task_simulate.prompty +5 -6
- azure/ai/evaluation/simulator/_tracing.py +28 -25
- azure/ai/evaluation/simulator/_utils.py +13 -34
- azure/ai/evaluation/simulator/simulator.py +579 -0
- azure_ai_evaluation-1.0.0b1.dist-info/METADATA +377 -0
- azure_ai_evaluation-1.0.0b1.dist-info/RECORD +97 -0
- {azure_ai_evaluation-1.0.0.dist-info → azure_ai_evaluation-1.0.0b1.dist-info}/WHEEL +1 -1
- azure/ai/evaluation/_common/_experimental.py +0 -172
- azure/ai/evaluation/_common/math.py +0 -89
- azure/ai/evaluation/_evaluate/_batch_run/proxy_client.py +0 -99
- azure/ai/evaluation/_evaluate/_batch_run/target_run_context.py +0 -46
- azure/ai/evaluation/_evaluators/_common/__init__.py +0 -13
- azure/ai/evaluation/_evaluators/_common/_base_eval.py +0 -344
- azure/ai/evaluation/_evaluators/_common/_base_prompty_eval.py +0 -88
- azure/ai/evaluation/_evaluators/_common/_base_rai_svc_eval.py +0 -133
- azure/ai/evaluation/_evaluators/_groundedness/groundedness_with_query.prompty +0 -113
- azure/ai/evaluation/_evaluators/_groundedness/groundedness_without_query.prompty +0 -99
- azure/ai/evaluation/_evaluators/_multimodal/__init__.py +0 -20
- azure/ai/evaluation/_evaluators/_multimodal/_content_safety_multimodal.py +0 -132
- azure/ai/evaluation/_evaluators/_multimodal/_hate_unfairness.py +0 -100
- azure/ai/evaluation/_evaluators/_multimodal/_protected_material.py +0 -124
- azure/ai/evaluation/_evaluators/_multimodal/_self_harm.py +0 -100
- azure/ai/evaluation/_evaluators/_multimodal/_sexual.py +0 -100
- azure/ai/evaluation/_evaluators/_multimodal/_violence.py +0 -100
- azure/ai/evaluation/_evaluators/_retrieval/_retrieval.py +0 -112
- azure/ai/evaluation/_evaluators/_retrieval/retrieval.prompty +0 -93
- azure/ai/evaluation/_evaluators/_service_groundedness/_service_groundedness.py +0 -148
- azure/ai/evaluation/_vendor/__init__.py +0 -3
- azure/ai/evaluation/_vendor/rouge_score/__init__.py +0 -14
- azure/ai/evaluation/_vendor/rouge_score/rouge_scorer.py +0 -328
- azure/ai/evaluation/_vendor/rouge_score/scoring.py +0 -63
- azure/ai/evaluation/_vendor/rouge_score/tokenize.py +0 -63
- azure/ai/evaluation/_vendor/rouge_score/tokenizers.py +0 -53
- azure/ai/evaluation/simulator/_data_sources/__init__.py +0 -3
- azure/ai/evaluation/simulator/_data_sources/grounding.json +0 -1150
- azure/ai/evaluation/simulator/_prompty/__init__.py +0 -0
- azure/ai/evaluation/simulator/_simulator.py +0 -716
- azure_ai_evaluation-1.0.0.dist-info/METADATA +0 -595
- azure_ai_evaluation-1.0.0.dist-info/NOTICE.txt +0 -70
- azure_ai_evaluation-1.0.0.dist-info/RECORD +0 -119
- {azure_ai_evaluation-1.0.0.dist-info → azure_ai_evaluation-1.0.0b1.dist-info}/top_level.txt +0 -0
|
@@ -2,124 +2,139 @@
|
|
|
2
2
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
3
|
# ---------------------------------------------------------
|
|
4
4
|
import logging
|
|
5
|
-
from typing import
|
|
5
|
+
from typing import Optional
|
|
6
6
|
|
|
7
|
-
from
|
|
7
|
+
from promptflow._utils.async_utils import async_run_allowing_running_loop
|
|
8
8
|
|
|
9
|
-
from azure.ai.evaluation._common._experimental import experimental
|
|
10
9
|
from azure.ai.evaluation._common.constants import EvaluationMetrics
|
|
11
|
-
from azure.ai.evaluation.
|
|
12
|
-
from azure.ai.evaluation.
|
|
10
|
+
from azure.ai.evaluation._common.rai_service import evaluate_with_rai_service
|
|
11
|
+
from azure.ai.evaluation._exceptions import EvaluationException, ErrorBlame, ErrorCategory, ErrorTarget
|
|
12
|
+
from azure.ai.evaluation._model_configurations import AzureAIProject
|
|
13
13
|
|
|
14
14
|
logger = logging.getLogger(__name__)
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Indirect attacks, also known as cross-domain prompt injected attacks (XPIA), are when jailbreak attacks are
|
|
23
|
-
injected into the context of a document or source that may result in an altered, unexpected behavior.
|
|
24
|
-
|
|
25
|
-
Indirect attacks evaluations are broken down into three subcategories:
|
|
26
|
-
- Manipulated Content: This category involves commands that aim to alter or fabricate information, often
|
|
27
|
-
to mislead or deceive. It includes actions like spreading false information, altering language or
|
|
28
|
-
formatting, and hiding or emphasizing specific details. The goal is often to manipulate perceptions
|
|
29
|
-
or behaviors by controlling the flow and presentation of information.
|
|
30
|
-
- Intrusion: This category encompasses commands that attempt to breach systems, gain unauthorized access,
|
|
31
|
-
or elevate privileges illicitly. It includes creating backdoors, exploiting vulnerabilities, and
|
|
32
|
-
traditional jailbreaks to bypass security measures. The intent is often to gain control or access
|
|
33
|
-
sensitive data without detection.
|
|
34
|
-
- Information Gathering: This category pertains to accessing, deleting, or modifying data without
|
|
35
|
-
authorization, often for malicious purposes. It includes exfiltrating sensitive data, tampering with
|
|
36
|
-
system records, and removing or altering existing information. The focus is on acquiring or
|
|
37
|
-
manipulating data to exploit or compromise systems and individuals.
|
|
38
|
-
|
|
39
|
-
Indirect attack scores are boolean values, where True indicates that the response contains an indirect attack.
|
|
40
|
-
|
|
41
|
-
:param credential: The credential for connecting to Azure AI project. Required
|
|
42
|
-
:type credential: ~azure.core.credentials.TokenCredential
|
|
17
|
+
class IndirectAttackEvaluator:
|
|
18
|
+
"""A Cross-Domain Prompt Injection Attack (XPIA) jailbreak evaluator.
|
|
19
|
+
|
|
20
|
+
Detect whether cross domain injected attacks are present in your AI system's response.
|
|
21
|
+
|
|
43
22
|
:param azure_ai_project: The scope of the Azure AI project. It contains subscription id, resource group, and project
|
|
44
23
|
name.
|
|
45
24
|
:type azure_ai_project: ~azure.ai.evaluation.AzureAIProject
|
|
25
|
+
:param eval_last_turn: Set to True to evaluate only the most recent exchange in the dialogue,
|
|
26
|
+
focusing on the latest user inquiry and the assistant's corresponding response. Defaults to False
|
|
27
|
+
:type eval_last_turn: bool
|
|
28
|
+
:param credential: The credential for connecting to Azure AI project.
|
|
29
|
+
:type credential: ~azure.core.credentials.TokenCredential
|
|
30
|
+
:return: A function that evaluates and generates metrics for XPIA chat scenario. Metrics include the overall
|
|
31
|
+
evaluation label and reason for the Q/A Pair, as well as sub-labels for manipulated content, intrusion, and
|
|
32
|
+
information.
|
|
33
|
+
:rtype: Callable
|
|
34
|
+
**Usage**
|
|
46
35
|
|
|
47
|
-
|
|
36
|
+
.. code-block:: python
|
|
48
37
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
:end-before: [END indirect_attack_evaluator]
|
|
52
|
-
:language: python
|
|
53
|
-
:dedent: 8
|
|
54
|
-
:caption: Initialize and call an IndirectAttackEvaluator.
|
|
55
|
-
"""
|
|
38
|
+
eval_fn = IndirectAttackEvaluator(model_config)
|
|
39
|
+
result = eval_fn(query="What is the capital of France?", response="Paris.")
|
|
56
40
|
|
|
57
|
-
|
|
58
|
-
"""Evaluator identifier, experimental and to be used only with evaluation in cloud."""
|
|
41
|
+
**Output format for question-answer pair**
|
|
59
42
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
43
|
+
.. code-block:: python
|
|
44
|
+
|
|
45
|
+
{
|
|
46
|
+
'xpia_label': False,
|
|
47
|
+
'xpia_reason': 'The conversation does not contain any manipulated content, intrusion or
|
|
48
|
+
information gathering.'
|
|
49
|
+
'xpia_information_gathering': False,
|
|
50
|
+
'xpia_intrusion': False
|
|
51
|
+
'xpia_manipulated_content': False
|
|
52
|
+
}
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
def __init__(self, azure_ai_project: dict, eval_last_turn: bool = False, credential=None):
|
|
56
|
+
self._evaluator = _IndirectAttackEvaluator(azure_ai_project, credential)
|
|
57
|
+
self._eval_last_turn = eval_last_turn
|
|
71
58
|
|
|
72
|
-
@overload
|
|
73
59
|
def __call__(
|
|
74
60
|
self,
|
|
75
61
|
*,
|
|
76
|
-
query: str,
|
|
77
|
-
response: str,
|
|
78
|
-
|
|
79
|
-
|
|
62
|
+
query: Optional[str],
|
|
63
|
+
response: Optional[str],
|
|
64
|
+
**kwargs,
|
|
65
|
+
):
|
|
66
|
+
"""
|
|
67
|
+
Evaluates content according to the presence of attacks injected into the conversation context to
|
|
68
|
+
interrupt normal expected functionality by eliciting manipulated content, intrusion and attempting
|
|
69
|
+
to gather information outside the scope of your AI system.
|
|
70
|
+
:keyword query: The query to be evaluated. Mutually exclusive with 'conversation'.
|
|
71
|
+
:paramtype query: Optional[str]
|
|
72
|
+
:keyword response: The response to be evaluated. Mutually exclusive with 'conversation'.
|
|
73
|
+
:paramtype response: Optional[str]
|
|
74
|
+
:return: The evaluation scores and reasoning.
|
|
75
|
+
:rtype: dict
|
|
76
|
+
"""
|
|
77
|
+
|
|
78
|
+
return self._evaluator(query=query, response=response, **kwargs)
|
|
80
79
|
|
|
80
|
+
|
|
81
|
+
class _AsyncIndirectAttackEvaluator:
|
|
82
|
+
def __init__(self, azure_ai_project: dict, credential=None):
|
|
83
|
+
self._azure_ai_project = azure_ai_project
|
|
84
|
+
self._credential = credential
|
|
85
|
+
|
|
86
|
+
async def __call__(self, *, query: str, response: str, **kwargs):
|
|
87
|
+
"""
|
|
88
|
+
Evaluates content according to this evaluator's metric.
|
|
81
89
|
:keyword query: The query to be evaluated.
|
|
82
90
|
:paramtype query: str
|
|
83
91
|
:keyword response: The response to be evaluated.
|
|
84
92
|
:paramtype response: str
|
|
85
|
-
:return: The
|
|
86
|
-
:rtype:
|
|
93
|
+
:return: The evaluation score computation based on the metric (self.metric).
|
|
94
|
+
:rtype: Any
|
|
87
95
|
"""
|
|
96
|
+
# Validate inputs
|
|
97
|
+
# Raises value error if failed, so execution alone signifies success.
|
|
98
|
+
if not (query and query.strip() and query != "None") or not (
|
|
99
|
+
response and response.strip() and response != "None"
|
|
100
|
+
):
|
|
101
|
+
msg = "Both 'query' and 'response' must be non-empty strings."
|
|
102
|
+
raise EvaluationException(
|
|
103
|
+
message=msg,
|
|
104
|
+
internal_message=msg,
|
|
105
|
+
error_category=ErrorCategory.MISSING_FIELD,
|
|
106
|
+
error_blame=ErrorBlame.USER_ERROR,
|
|
107
|
+
error_target=ErrorTarget.INDIRECT_ATTACK_EVALUATOR,
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
# Run score computation based on supplied metric.
|
|
111
|
+
result = await evaluate_with_rai_service(
|
|
112
|
+
metric_name=EvaluationMetrics.XPIA,
|
|
113
|
+
query=query,
|
|
114
|
+
response=response,
|
|
115
|
+
project_scope=self._azure_ai_project,
|
|
116
|
+
credential=self._credential,
|
|
117
|
+
)
|
|
118
|
+
return result
|
|
88
119
|
|
|
89
|
-
@overload
|
|
90
|
-
def __call__(
|
|
91
|
-
self,
|
|
92
|
-
*,
|
|
93
|
-
conversation: Conversation,
|
|
94
|
-
) -> Dict[str, Union[float, Dict[str, List[Union[str, bool]]]]]:
|
|
95
|
-
"""Evaluate cross domain injected attacks are present in a conversation
|
|
96
|
-
|
|
97
|
-
:keyword conversation: The conversation to evaluate. Expected to contain a list of conversation turns under the
|
|
98
|
-
key "messages", and potentially a global context under the key "context". Conversation turns are expected
|
|
99
|
-
to be dictionaries with keys "content", "role", and possibly "context".
|
|
100
|
-
:paramtype conversation: Optional[~azure.ai.evaluation.Conversation]
|
|
101
|
-
:return: The cross domain injection attack score
|
|
102
|
-
:rtype: Dict[str, Union[str, bool, Dict[str, List[Union[str, bool]]]]]
|
|
103
|
-
"""
|
|
104
120
|
|
|
105
|
-
|
|
106
|
-
def
|
|
107
|
-
self,
|
|
108
|
-
*args,
|
|
109
|
-
**kwargs,
|
|
110
|
-
):
|
|
111
|
-
"""
|
|
112
|
-
Evaluate whether cross domain injected attacks are present in your AI system's response.
|
|
121
|
+
class _IndirectAttackEvaluator:
|
|
122
|
+
def __init__(self, azure_ai_project: dict, credential=None):
|
|
123
|
+
self._async_evaluator = _AsyncIndirectAttackEvaluator(azure_ai_project, credential)
|
|
113
124
|
|
|
125
|
+
def __call__(self, *, query: str, response: str, **kwargs):
|
|
126
|
+
"""
|
|
127
|
+
Evaluates XPIA content.
|
|
114
128
|
:keyword query: The query to be evaluated.
|
|
115
|
-
:paramtype query:
|
|
129
|
+
:paramtype query: str
|
|
116
130
|
:keyword response: The response to be evaluated.
|
|
117
|
-
:paramtype response:
|
|
118
|
-
:keyword
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
:
|
|
122
|
-
:return: The cross domain injection attack score
|
|
123
|
-
:rtype: Union[Dict[str, Union[str, bool]], Dict[str, Union[float, Dict[str, List[Union[str, bool]]]]]]
|
|
131
|
+
:paramtype response: str
|
|
132
|
+
:keyword context: The context to be evaluated.
|
|
133
|
+
:paramtype context: str
|
|
134
|
+
:return: The XPIA score.
|
|
135
|
+
:rtype: dict
|
|
124
136
|
"""
|
|
125
|
-
return
|
|
137
|
+
return async_run_allowing_running_loop(self._async_evaluator, query=query, response=response, **kwargs)
|
|
138
|
+
|
|
139
|
+
def _to_async(self):
|
|
140
|
+
return self._async_evaluator
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
"""This includes enums and classes for exceptions for use in azure-ai-evaluation."""
|
|
5
5
|
|
|
6
6
|
from enum import Enum
|
|
7
|
-
from typing import Optional
|
|
8
7
|
|
|
9
8
|
from azure.core.exceptions import AzureError
|
|
10
9
|
|
|
@@ -21,9 +20,6 @@ class ErrorCategory(Enum):
|
|
|
21
20
|
* RESOURCE_NOT_FOUND -> Resource could not be found
|
|
22
21
|
* FAILED_EXECUTION -> Execution failed
|
|
23
22
|
* SERVICE_UNAVAILABLE -> Service is unavailable
|
|
24
|
-
* MISSING_PACKAGE -> Required package is missing
|
|
25
|
-
* FAILED_REMOTE_TRACKING -> Remote tracking failed
|
|
26
|
-
* PROJECT_ACCESS_ERROR -> Access to project failed
|
|
27
23
|
* UNKNOWN -> Undefined placeholder. Avoid using.
|
|
28
24
|
"""
|
|
29
25
|
|
|
@@ -34,9 +30,6 @@ class ErrorCategory(Enum):
|
|
|
34
30
|
RESOURCE_NOT_FOUND = "RESOURCE NOT FOUND"
|
|
35
31
|
FAILED_EXECUTION = "FAILED_EXECUTION"
|
|
36
32
|
SERVICE_UNAVAILABLE = "SERVICE UNAVAILABLE"
|
|
37
|
-
MISSING_PACKAGE = "MISSING PACKAGE"
|
|
38
|
-
FAILED_REMOTE_TRACKING = "FAILED REMOTE TRACKING"
|
|
39
|
-
PROJECT_ACCESS_ERROR = "PROJECT ACCESS ERROR"
|
|
40
33
|
UNKNOWN = "UNKNOWN"
|
|
41
34
|
|
|
42
35
|
|
|
@@ -61,17 +54,15 @@ class ErrorTarget(Enum):
|
|
|
61
54
|
EVAL_RUN = "EvalRun"
|
|
62
55
|
CODE_CLIENT = "CodeClient"
|
|
63
56
|
RAI_CLIENT = "RAIClient"
|
|
57
|
+
CHAT_EVALUATOR = "ChatEvaluator"
|
|
64
58
|
COHERENCE_EVALUATOR = "CoherenceEvaluator"
|
|
65
59
|
CONTENT_SAFETY_CHAT_EVALUATOR = "ContentSafetyEvaluator"
|
|
66
|
-
CONTENT_SAFETY_MULTIMODAL_EVALUATOR = "ContentSafetyMultimodalEvaluator"
|
|
67
60
|
ECI_EVALUATOR = "ECIEvaluator"
|
|
68
61
|
F1_EVALUATOR = "F1Evaluator"
|
|
69
62
|
GROUNDEDNESS_EVALUATOR = "GroundednessEvaluator"
|
|
70
63
|
PROTECTED_MATERIAL_EVALUATOR = "ProtectedMaterialEvaluator"
|
|
71
64
|
RELEVANCE_EVALUATOR = "RelevanceEvaluator"
|
|
72
65
|
SIMILARITY_EVALUATOR = "SimilarityEvaluator"
|
|
73
|
-
FLUENCY_EVALUATOR = "FluencyEvaluator"
|
|
74
|
-
RETRIEVAL_EVALUATOR = "RetrievalEvaluator"
|
|
75
66
|
INDIRECT_ATTACK_EVALUATOR = "IndirectAttackEvaluator"
|
|
76
67
|
INDIRECT_ATTACK_SIMULATOR = "IndirectAttackSimulator"
|
|
77
68
|
ADVERSARIAL_SIMULATOR = "AdversarialSimulator"
|
|
@@ -84,7 +75,7 @@ class ErrorTarget(Enum):
|
|
|
84
75
|
|
|
85
76
|
|
|
86
77
|
class EvaluationException(AzureError):
|
|
87
|
-
"""The base class for all exceptions raised in
|
|
78
|
+
"""The base class for all exceptions raised in pazure-ai-evaluation. If there is a need to define a custom
|
|
88
79
|
exception type, that custom exception type should extend from this class.
|
|
89
80
|
|
|
90
81
|
:param message: A message describing the error. This is the error message the user will see.
|
|
@@ -93,36 +84,24 @@ class EvaluationException(AzureError):
|
|
|
93
84
|
:type internal_message: str
|
|
94
85
|
:param target: The name of the element that caused the exception to be thrown.
|
|
95
86
|
:type target: ~azure.ai.evaluation._exceptions.ErrorTarget
|
|
96
|
-
:param
|
|
97
|
-
:type
|
|
98
|
-
:param
|
|
99
|
-
:type
|
|
100
|
-
:param tsg_link: A link to the TSG page for troubleshooting the error.
|
|
101
|
-
:type tsg_link: str
|
|
87
|
+
:param error_category: The error category, defaults to Unknown.
|
|
88
|
+
:type error_category: ~azure.ai.evaluation._exceptionsErrorCategory
|
|
89
|
+
:param error: The original exception if any.
|
|
90
|
+
:type error: Exception
|
|
102
91
|
"""
|
|
103
92
|
|
|
104
93
|
def __init__(
|
|
105
94
|
self,
|
|
106
95
|
message: str,
|
|
96
|
+
internal_message: str,
|
|
107
97
|
*args,
|
|
108
|
-
internal_message: Optional[str] = None,
|
|
109
98
|
target: ErrorTarget = ErrorTarget.UNKNOWN,
|
|
110
99
|
category: ErrorCategory = ErrorCategory.UNKNOWN,
|
|
111
100
|
blame: ErrorBlame = ErrorBlame.UNKNOWN,
|
|
112
|
-
tsg_link: Optional[str] = None,
|
|
113
101
|
**kwargs,
|
|
114
102
|
) -> None:
|
|
115
103
|
self.category = category
|
|
116
104
|
self.target = target
|
|
117
105
|
self.blame = blame
|
|
118
106
|
self.internal_message = internal_message
|
|
119
|
-
self.tsg_link = tsg_link
|
|
120
107
|
super().__init__(message, *args, **kwargs)
|
|
121
|
-
|
|
122
|
-
def __str__(self):
|
|
123
|
-
error_blame = "InternalError" if self.blame != ErrorBlame.USER_ERROR else "UserError"
|
|
124
|
-
msg = f"({error_blame}) {super().__str__()}"
|
|
125
|
-
if self.tsg_link:
|
|
126
|
-
msg += f"\nVisit {self.tsg_link} to troubleshoot this issue."
|
|
127
|
-
|
|
128
|
-
return msg
|