azure-ai-evaluation 1.5.0__py3-none-any.whl → 1.6.0__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.

Files changed (123) hide show
  1. azure/ai/evaluation/__init__.py +9 -0
  2. azure/ai/evaluation/_aoai/__init__.py +10 -0
  3. azure/ai/evaluation/_aoai/aoai_grader.py +89 -0
  4. azure/ai/evaluation/_aoai/label_grader.py +66 -0
  5. azure/ai/evaluation/_aoai/string_check_grader.py +65 -0
  6. azure/ai/evaluation/_aoai/text_similarity_grader.py +88 -0
  7. azure/ai/evaluation/_azure/_clients.py +4 -4
  8. azure/ai/evaluation/_azure/_envs.py +208 -0
  9. azure/ai/evaluation/_azure/_token_manager.py +12 -7
  10. azure/ai/evaluation/_common/__init__.py +5 -0
  11. azure/ai/evaluation/_common/evaluation_onedp_client.py +118 -0
  12. azure/ai/evaluation/_common/onedp/__init__.py +32 -0
  13. azure/ai/evaluation/_common/onedp/_client.py +139 -0
  14. azure/ai/evaluation/_common/onedp/_configuration.py +73 -0
  15. azure/ai/evaluation/_common/onedp/_model_base.py +1232 -0
  16. azure/ai/evaluation/_common/onedp/_patch.py +21 -0
  17. azure/ai/evaluation/_common/onedp/_serialization.py +2032 -0
  18. azure/ai/evaluation/_common/onedp/_types.py +21 -0
  19. azure/ai/evaluation/_common/onedp/_validation.py +50 -0
  20. azure/ai/evaluation/_common/onedp/_vendor.py +50 -0
  21. azure/ai/evaluation/_common/onedp/_version.py +9 -0
  22. azure/ai/evaluation/_common/onedp/aio/__init__.py +29 -0
  23. azure/ai/evaluation/_common/onedp/aio/_client.py +143 -0
  24. azure/ai/evaluation/_common/onedp/aio/_configuration.py +75 -0
  25. azure/ai/evaluation/_common/onedp/aio/_patch.py +21 -0
  26. azure/ai/evaluation/_common/onedp/aio/_vendor.py +40 -0
  27. azure/ai/evaluation/_common/onedp/aio/operations/__init__.py +39 -0
  28. azure/ai/evaluation/_common/onedp/aio/operations/_operations.py +4494 -0
  29. azure/ai/evaluation/_common/onedp/aio/operations/_patch.py +21 -0
  30. azure/ai/evaluation/_common/onedp/models/__init__.py +142 -0
  31. azure/ai/evaluation/_common/onedp/models/_enums.py +162 -0
  32. azure/ai/evaluation/_common/onedp/models/_models.py +2228 -0
  33. azure/ai/evaluation/_common/onedp/models/_patch.py +21 -0
  34. azure/ai/evaluation/_common/onedp/operations/__init__.py +39 -0
  35. azure/ai/evaluation/_common/onedp/operations/_operations.py +5655 -0
  36. azure/ai/evaluation/_common/onedp/operations/_patch.py +21 -0
  37. azure/ai/evaluation/_common/onedp/py.typed +1 -0
  38. azure/ai/evaluation/_common/onedp/servicepatterns/__init__.py +1 -0
  39. azure/ai/evaluation/_common/onedp/servicepatterns/aio/__init__.py +1 -0
  40. azure/ai/evaluation/_common/onedp/servicepatterns/aio/operations/__init__.py +25 -0
  41. azure/ai/evaluation/_common/onedp/servicepatterns/aio/operations/_operations.py +34 -0
  42. azure/ai/evaluation/_common/onedp/servicepatterns/aio/operations/_patch.py +20 -0
  43. azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/__init__.py +1 -0
  44. azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/aio/__init__.py +1 -0
  45. azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/aio/operations/__init__.py +22 -0
  46. azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/aio/operations/_operations.py +29 -0
  47. azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/aio/operations/_patch.py +20 -0
  48. azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/operations/__init__.py +22 -0
  49. azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/operations/_operations.py +29 -0
  50. azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/operations/_patch.py +20 -0
  51. azure/ai/evaluation/_common/onedp/servicepatterns/operations/__init__.py +25 -0
  52. azure/ai/evaluation/_common/onedp/servicepatterns/operations/_operations.py +34 -0
  53. azure/ai/evaluation/_common/onedp/servicepatterns/operations/_patch.py +20 -0
  54. azure/ai/evaluation/_common/rai_service.py +158 -28
  55. azure/ai/evaluation/_common/raiclient/_version.py +1 -1
  56. azure/ai/evaluation/_common/utils.py +79 -1
  57. azure/ai/evaluation/_constants.py +16 -0
  58. azure/ai/evaluation/_eval_mapping.py +71 -0
  59. azure/ai/evaluation/_evaluate/_batch_run/_run_submitter_client.py +30 -16
  60. azure/ai/evaluation/_evaluate/_batch_run/eval_run_context.py +8 -0
  61. azure/ai/evaluation/_evaluate/_batch_run/proxy_client.py +5 -0
  62. azure/ai/evaluation/_evaluate/_batch_run/target_run_context.py +17 -1
  63. azure/ai/evaluation/_evaluate/_eval_run.py +1 -1
  64. azure/ai/evaluation/_evaluate/_evaluate.py +325 -74
  65. azure/ai/evaluation/_evaluate/_evaluate_aoai.py +534 -0
  66. azure/ai/evaluation/_evaluate/_utils.py +117 -4
  67. azure/ai/evaluation/_evaluators/_common/_base_eval.py +8 -3
  68. azure/ai/evaluation/_evaluators/_common/_base_prompty_eval.py +12 -3
  69. azure/ai/evaluation/_evaluators/_common/_base_rai_svc_eval.py +2 -2
  70. azure/ai/evaluation/_evaluators/_document_retrieval/__init__.py +11 -0
  71. azure/ai/evaluation/_evaluators/_document_retrieval/_document_retrieval.py +467 -0
  72. azure/ai/evaluation/_evaluators/_fluency/_fluency.py +1 -1
  73. azure/ai/evaluation/_evaluators/_groundedness/_groundedness.py +1 -1
  74. azure/ai/evaluation/_evaluators/_intent_resolution/_intent_resolution.py +6 -2
  75. azure/ai/evaluation/_evaluators/_relevance/_relevance.py +1 -1
  76. azure/ai/evaluation/_evaluators/_response_completeness/_response_completeness.py +7 -2
  77. azure/ai/evaluation/_evaluators/_response_completeness/response_completeness.prompty +31 -46
  78. azure/ai/evaluation/_evaluators/_similarity/_similarity.py +1 -1
  79. azure/ai/evaluation/_evaluators/_task_adherence/_task_adherence.py +5 -2
  80. azure/ai/evaluation/_evaluators/_tool_call_accuracy/_tool_call_accuracy.py +6 -2
  81. azure/ai/evaluation/_exceptions.py +2 -0
  82. azure/ai/evaluation/_legacy/_adapters/__init__.py +0 -14
  83. azure/ai/evaluation/_legacy/_adapters/_check.py +17 -0
  84. azure/ai/evaluation/_legacy/_adapters/_flows.py +1 -1
  85. azure/ai/evaluation/_legacy/_batch_engine/_engine.py +51 -32
  86. azure/ai/evaluation/_legacy/_batch_engine/_openai_injector.py +114 -8
  87. azure/ai/evaluation/_legacy/_batch_engine/_result.py +6 -0
  88. azure/ai/evaluation/_legacy/_batch_engine/_run.py +6 -0
  89. azure/ai/evaluation/_legacy/_batch_engine/_run_submitter.py +69 -29
  90. azure/ai/evaluation/_legacy/_batch_engine/_trace.py +54 -62
  91. azure/ai/evaluation/_legacy/_batch_engine/_utils.py +19 -1
  92. azure/ai/evaluation/_legacy/_common/__init__.py +3 -0
  93. azure/ai/evaluation/_legacy/_common/_async_token_provider.py +124 -0
  94. azure/ai/evaluation/_legacy/_common/_thread_pool_executor_with_context.py +15 -0
  95. azure/ai/evaluation/_legacy/prompty/_connection.py +11 -74
  96. azure/ai/evaluation/_legacy/prompty/_exceptions.py +80 -0
  97. azure/ai/evaluation/_legacy/prompty/_prompty.py +119 -9
  98. azure/ai/evaluation/_legacy/prompty/_utils.py +72 -2
  99. azure/ai/evaluation/_safety_evaluation/_safety_evaluation.py +90 -17
  100. azure/ai/evaluation/_version.py +1 -1
  101. azure/ai/evaluation/red_team/_attack_strategy.py +1 -1
  102. azure/ai/evaluation/red_team/_red_team.py +825 -450
  103. azure/ai/evaluation/red_team/_utils/metric_mapping.py +23 -0
  104. azure/ai/evaluation/red_team/_utils/strategy_utils.py +1 -1
  105. azure/ai/evaluation/simulator/_adversarial_simulator.py +63 -39
  106. azure/ai/evaluation/simulator/_constants.py +1 -0
  107. azure/ai/evaluation/simulator/_conversation/__init__.py +13 -6
  108. azure/ai/evaluation/simulator/_conversation/_conversation.py +2 -1
  109. azure/ai/evaluation/simulator/_direct_attack_simulator.py +35 -22
  110. azure/ai/evaluation/simulator/_helpers/_language_suffix_mapping.py +1 -0
  111. azure/ai/evaluation/simulator/_indirect_attack_simulator.py +40 -25
  112. azure/ai/evaluation/simulator/_model_tools/__init__.py +2 -1
  113. azure/ai/evaluation/simulator/_model_tools/_generated_rai_client.py +24 -18
  114. azure/ai/evaluation/simulator/_model_tools/_identity_manager.py +5 -10
  115. azure/ai/evaluation/simulator/_model_tools/_proxy_completion_model.py +65 -41
  116. azure/ai/evaluation/simulator/_model_tools/_template_handler.py +9 -5
  117. azure/ai/evaluation/simulator/_model_tools/models.py +20 -17
  118. {azure_ai_evaluation-1.5.0.dist-info → azure_ai_evaluation-1.6.0.dist-info}/METADATA +25 -2
  119. {azure_ai_evaluation-1.5.0.dist-info → azure_ai_evaluation-1.6.0.dist-info}/RECORD +123 -65
  120. /azure/ai/evaluation/_legacy/{_batch_engine → _common}/_logging.py +0 -0
  121. {azure_ai_evaluation-1.5.0.dist-info → azure_ai_evaluation-1.6.0.dist-info}/NOTICE.txt +0 -0
  122. {azure_ai_evaluation-1.5.0.dist-info → azure_ai_evaluation-1.6.0.dist-info}/WHEEL +0 -0
  123. {azure_ai_evaluation-1.5.0.dist-info → azure_ai_evaluation-1.6.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,21 @@
1
+ # coding=utf-8
2
+ # --------------------------------------------------------------------------
3
+ # Copyright (c) Microsoft Corporation. All rights reserved.
4
+ # Licensed under the MIT License. See License.txt in the project root for license information.
5
+ # --------------------------------------------------------------------------
6
+ """Customize generated code here.
7
+
8
+ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize
9
+ """
10
+ from typing import List
11
+
12
+ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level
13
+
14
+
15
+ def patch_sdk():
16
+ """Do not remove from this file.
17
+
18
+ `patch_sdk` is a last resort escape hatch that allows you to do customizations
19
+ you can't accomplish using the techniques described in
20
+ https://aka.ms/azsdk/python/dpcodegen/python/customize
21
+ """
@@ -0,0 +1,142 @@
1
+ # coding=utf-8
2
+ # --------------------------------------------------------------------------
3
+ # Copyright (c) Microsoft Corporation. All rights reserved.
4
+ # Licensed under the MIT License. See License.txt in the project root for license information.
5
+ # Code generated by Microsoft (R) Python Code Generator.
6
+ # Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
+ # --------------------------------------------------------------------------
8
+ # pylint: disable=wrong-import-position
9
+
10
+ from typing import TYPE_CHECKING
11
+
12
+ if TYPE_CHECKING:
13
+ from ._patch import * # pylint: disable=unused-wildcard-import
14
+
15
+
16
+ from ._models import ( # type: ignore
17
+ AOAIModelConfig,
18
+ AnnotationDTO,
19
+ ApiKeyCredentials,
20
+ AssetCredentialRequest,
21
+ AssetCredentialResponse,
22
+ AttackObjective,
23
+ AzureAISearchIndex,
24
+ BaseCredentials,
25
+ BlobReferenceForConsumption,
26
+ Connection,
27
+ Content,
28
+ CosmosDBIndex,
29
+ CustomCredential,
30
+ CustomizationParameters,
31
+ DatasetVersion,
32
+ Deployment,
33
+ EmbeddingConfiguration,
34
+ EntraIDCredentials,
35
+ Evaluation,
36
+ EvaluationResult,
37
+ EvaluationTarget,
38
+ EvaluationUpload,
39
+ EvaluatorConfiguration,
40
+ FileDatasetVersion,
41
+ FolderDatasetVersion,
42
+ Index,
43
+ InputData,
44
+ InputDataset,
45
+ LongRunningResponse,
46
+ MAASModelConfig,
47
+ ManagedAzureAISearchIndex,
48
+ Message,
49
+ Metadata,
50
+ ModelDeployment,
51
+ NoAuthenticationCredentials,
52
+ PendingUploadRequest,
53
+ PendingUploadResponse,
54
+ RedTeam,
55
+ RedTeamUpload,
56
+ SASCredentials,
57
+ SasCredential,
58
+ SimulationDTO,
59
+ Sku,
60
+ SystemData,
61
+ TargetHarm,
62
+ TargetModelConfig,
63
+ )
64
+
65
+ from ._enums import ( # type: ignore
66
+ AttackStrategy,
67
+ ConnectionType,
68
+ CredentialType,
69
+ DatasetType,
70
+ DeploymentType,
71
+ IndexType,
72
+ ListViewType,
73
+ PendingUploadType,
74
+ ResultType,
75
+ RiskCategory,
76
+ SimulationType,
77
+ )
78
+ from ._patch import __all__ as _patch_all
79
+ from ._patch import *
80
+ from ._patch import patch_sdk as _patch_sdk
81
+
82
+ __all__ = [
83
+ "AOAIModelConfig",
84
+ "AnnotationDTO",
85
+ "ApiKeyCredentials",
86
+ "AssetCredentialRequest",
87
+ "AssetCredentialResponse",
88
+ "AttackObjective",
89
+ "AzureAISearchIndex",
90
+ "BaseCredentials",
91
+ "BlobReferenceForConsumption",
92
+ "Connection",
93
+ "Content",
94
+ "CosmosDBIndex",
95
+ "CustomCredential",
96
+ "CustomizationParameters",
97
+ "DatasetVersion",
98
+ "Deployment",
99
+ "EmbeddingConfiguration",
100
+ "EntraIDCredentials",
101
+ "Evaluation",
102
+ "EvaluationResult",
103
+ "EvaluationTarget",
104
+ "EvaluationUpload",
105
+ "EvaluatorConfiguration",
106
+ "FileDatasetVersion",
107
+ "FolderDatasetVersion",
108
+ "Index",
109
+ "InputData",
110
+ "InputDataset",
111
+ "LongRunningResponse",
112
+ "MAASModelConfig",
113
+ "ManagedAzureAISearchIndex",
114
+ "Message",
115
+ "Metadata",
116
+ "ModelDeployment",
117
+ "NoAuthenticationCredentials",
118
+ "PendingUploadRequest",
119
+ "PendingUploadResponse",
120
+ "RedTeam",
121
+ "RedTeamUpload",
122
+ "SASCredentials",
123
+ "SasCredential",
124
+ "SimulationDTO",
125
+ "Sku",
126
+ "SystemData",
127
+ "TargetHarm",
128
+ "TargetModelConfig",
129
+ "AttackStrategy",
130
+ "ConnectionType",
131
+ "CredentialType",
132
+ "DatasetType",
133
+ "DeploymentType",
134
+ "IndexType",
135
+ "ListViewType",
136
+ "PendingUploadType",
137
+ "ResultType",
138
+ "RiskCategory",
139
+ "SimulationType",
140
+ ]
141
+ __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
142
+ _patch_sdk()
@@ -0,0 +1,162 @@
1
+ # coding=utf-8
2
+ # --------------------------------------------------------------------------
3
+ # Copyright (c) Microsoft Corporation. All rights reserved.
4
+ # Licensed under the MIT License. See License.txt in the project root for license information.
5
+ # Code generated by Microsoft (R) Python Code Generator.
6
+ # Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
+ # --------------------------------------------------------------------------
8
+
9
+ from enum import Enum
10
+ from azure.core import CaseInsensitiveEnumMeta
11
+
12
+
13
+ class AttackStrategy(str, Enum, metaclass=CaseInsensitiveEnumMeta):
14
+ """Strategies for attacks."""
15
+
16
+ EASY = "easy"
17
+ """Represents a default set of easy complexity attacks. Easy complexity attack strategies are
18
+ defined as attacks that do not require any Large Language Model to convert or orchestrate."""
19
+ ASCII_ART = "ascii_art"
20
+ """Represents ASCII art, a graphic design technique that uses printable characters."""
21
+ ASCII_SMUGGLER = "ascii_smuggler"
22
+ """Represents ASCII smuggling, a technique for encoding or hiding data."""
23
+ ATBASH = "atbash"
24
+ """Represents the Atbash cipher, a substitution cipher that reverses the alphabet."""
25
+ BASE64 = "base64"
26
+ """Represents Base64 encoding, a method for encoding binary data as text."""
27
+ BINARY = "binary"
28
+ """Represents binary encoding, a representation of data in binary format."""
29
+ CAESAR = "caesar"
30
+ """Represents the Caesar cipher, a substitution cipher that shifts characters."""
31
+ CHARACTER_SPACE = "character_space"
32
+ """Represents character space manipulation, a technique involving spacing between characters."""
33
+ JAILBREAK = "jailbreak"
34
+ """Represents character swapping, a technique for rearranging characters in text."""
35
+
36
+
37
+ class ConnectionType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
38
+ """The Type (or category) of the connection."""
39
+
40
+ AZURE_OPEN_AI = "AzureOpenAI"
41
+ """Azure OpenAI Service"""
42
+ AZURE_BLOB_STORAGE = "AzureBlob"
43
+ """Azure Blob Storage, with specified container"""
44
+ AZURE_STORAGE_ACCOUNT = "AzureStorageAccount"
45
+ """Azure Blob Storage, with container not specified (used by Assistants)"""
46
+ AZURE_AI_SEARCH = "CognitiveSearch"
47
+ """Azure AI Search"""
48
+ COSMOS_DB = "CosmosDB"
49
+ """CosmosDB"""
50
+ API_KEY = "ApiKey"
51
+ """Generic connection that uses API Key authentication"""
52
+ APPLICATION_CONFIGURATION = "AppConfig"
53
+ """Application Configuration"""
54
+ APPLICATION_INSIGHTS = "AppInsights"
55
+ """Application Insights"""
56
+ CUSTOM = "CustomKeys"
57
+ """Custom Keys"""
58
+
59
+
60
+ class CredentialType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
61
+ """The credential type used by the connection."""
62
+
63
+ API_KEY = "ApiKey"
64
+ """API Key credential"""
65
+ ENTRA_ID = "AAD"
66
+ """Entra ID credential (formerly known as AAD)"""
67
+ SAS = "SAS"
68
+ """Shared Access Signature (SAS) credential"""
69
+ CUSTOM = "CustomKeys"
70
+ """Custom credential"""
71
+ NONE = "None"
72
+ """No credential"""
73
+
74
+
75
+ class DatasetType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
76
+ """Enum to determine the type of data."""
77
+
78
+ URI_FILE = "uri_file"
79
+ """URI file."""
80
+ URI_FOLDER = "uri_folder"
81
+ """URI folder."""
82
+
83
+
84
+ class DeploymentType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
85
+ """Type of DeploymentType."""
86
+
87
+ MODEL_DEPLOYMENT = "ModelDeployment"
88
+ """Model deployment"""
89
+
90
+
91
+ class IndexType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
92
+ """Type of IndexType."""
93
+
94
+ AZURE_SEARCH = "AzureSearch"
95
+ """Azure search"""
96
+ COSMOS_DB = "CosmosDBNoSqlVectorStore"
97
+ """CosmosDB"""
98
+ MANAGED_AZURE_SEARCH = "ManagedAzureSearch"
99
+ """Managed Azure Search"""
100
+
101
+
102
+ class ListViewType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
103
+ """List View Type Definition."""
104
+
105
+ ACTIVE_ONLY = "ActiveOnly"
106
+ """List only active items."""
107
+ ARCHIVED_ONLY = "ArchivedOnly"
108
+ """List only archived items."""
109
+ ALL = "All"
110
+ """List all items."""
111
+
112
+
113
+ class PendingUploadType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
114
+ """The type of pending upload."""
115
+
116
+ NONE = "None"
117
+ """No pending upload."""
118
+ TEMPORARY_BLOB_REFERENCE = "TemporaryBlobReference"
119
+ """Temporary Blob Reference is the only supported type."""
120
+
121
+
122
+ class ResultType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
123
+ """Type of Evaluation result."""
124
+
125
+ BENCHMARK = "Benchmark"
126
+ """Benchmark result"""
127
+ EVALUATION = "Evaluation"
128
+ """Evaluations Result"""
129
+ REDTEAM = "Redteam"
130
+ """Red Team Result"""
131
+ SIMULATION = "Simulation"
132
+ """Simulation Result"""
133
+
134
+
135
+ class RiskCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta):
136
+ """Risk category for the attack objective."""
137
+
138
+ HATE_UNFAIRNESS = "HateUnfairness"
139
+ """Represents content related to hate or unfairness."""
140
+ VIOLENCE = "Violence"
141
+ """Represents content related to violence."""
142
+ SEXUAL = "Sexual"
143
+ """Represents content of a sexual nature."""
144
+ SELF_HARM = "SelfHarm"
145
+ """Represents content related to self-harm."""
146
+ PROTECTED_MATERIAL = "ProtectedMaterial"
147
+ """Represents content involving protected material."""
148
+ CODE_VULNERABILITY = "CodeVulnerability"
149
+ """Represents content related to code vulnerabilities."""
150
+ UNGROUNDED_ATTRIBUTES = "UngroundedAttributes"
151
+ """Represents content with ungrounded attributes."""
152
+
153
+
154
+ class SimulationType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
155
+ """Simulation type."""
156
+
157
+ DEFAULT = "Default"
158
+ """Default simulation type."""
159
+ CUSTOM_PERSONA = "CustomPersona"
160
+ """Custom persona simulation type."""
161
+ HARM_TURN_GENERATOR = "HarmTurnGenerator"
162
+ """Harm turn generator simulation type."""