azure-ai-evaluation 1.2.0__py3-none-any.whl → 1.4.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 (134) hide show
  1. azure/ai/evaluation/__init__.py +42 -14
  2. azure/ai/evaluation/_azure/_models.py +6 -6
  3. azure/ai/evaluation/_common/constants.py +6 -2
  4. azure/ai/evaluation/_common/rai_service.py +38 -4
  5. azure/ai/evaluation/_common/raiclient/__init__.py +34 -0
  6. azure/ai/evaluation/_common/raiclient/_client.py +128 -0
  7. azure/ai/evaluation/_common/raiclient/_configuration.py +87 -0
  8. azure/ai/evaluation/_common/raiclient/_model_base.py +1235 -0
  9. azure/ai/evaluation/_common/raiclient/_patch.py +20 -0
  10. azure/ai/evaluation/_common/raiclient/_serialization.py +2050 -0
  11. azure/ai/evaluation/_common/raiclient/_version.py +9 -0
  12. azure/ai/evaluation/_common/raiclient/aio/__init__.py +29 -0
  13. azure/ai/evaluation/_common/raiclient/aio/_client.py +130 -0
  14. azure/ai/evaluation/_common/raiclient/aio/_configuration.py +87 -0
  15. azure/ai/evaluation/_common/raiclient/aio/_patch.py +20 -0
  16. azure/ai/evaluation/_common/raiclient/aio/operations/__init__.py +25 -0
  17. azure/ai/evaluation/_common/raiclient/aio/operations/_operations.py +981 -0
  18. azure/ai/evaluation/_common/raiclient/aio/operations/_patch.py +20 -0
  19. azure/ai/evaluation/_common/raiclient/models/__init__.py +60 -0
  20. azure/ai/evaluation/_common/raiclient/models/_enums.py +18 -0
  21. azure/ai/evaluation/_common/raiclient/models/_models.py +651 -0
  22. azure/ai/evaluation/_common/raiclient/models/_patch.py +20 -0
  23. azure/ai/evaluation/_common/raiclient/operations/__init__.py +25 -0
  24. azure/ai/evaluation/_common/raiclient/operations/_operations.py +1225 -0
  25. azure/ai/evaluation/_common/raiclient/operations/_patch.py +20 -0
  26. azure/ai/evaluation/_common/raiclient/py.typed +1 -0
  27. azure/ai/evaluation/_common/utils.py +30 -10
  28. azure/ai/evaluation/_constants.py +10 -0
  29. azure/ai/evaluation/_converters/__init__.py +3 -0
  30. azure/ai/evaluation/_converters/_ai_services.py +804 -0
  31. azure/ai/evaluation/_converters/_models.py +302 -0
  32. azure/ai/evaluation/_evaluate/_batch_run/__init__.py +10 -3
  33. azure/ai/evaluation/_evaluate/_batch_run/_run_submitter_client.py +104 -0
  34. azure/ai/evaluation/_evaluate/_batch_run/batch_clients.py +82 -0
  35. azure/ai/evaluation/_evaluate/_eval_run.py +1 -1
  36. azure/ai/evaluation/_evaluate/_evaluate.py +36 -4
  37. azure/ai/evaluation/_evaluators/_bleu/_bleu.py +23 -3
  38. azure/ai/evaluation/_evaluators/_code_vulnerability/__init__.py +5 -0
  39. azure/ai/evaluation/_evaluators/_code_vulnerability/_code_vulnerability.py +120 -0
  40. azure/ai/evaluation/_evaluators/_coherence/_coherence.py +21 -2
  41. azure/ai/evaluation/_evaluators/_common/_base_eval.py +43 -3
  42. azure/ai/evaluation/_evaluators/_common/_base_multi_eval.py +3 -1
  43. azure/ai/evaluation/_evaluators/_common/_base_prompty_eval.py +43 -4
  44. azure/ai/evaluation/_evaluators/_common/_base_rai_svc_eval.py +16 -4
  45. azure/ai/evaluation/_evaluators/_content_safety/_content_safety.py +42 -5
  46. azure/ai/evaluation/_evaluators/_content_safety/_hate_unfairness.py +15 -0
  47. azure/ai/evaluation/_evaluators/_content_safety/_self_harm.py +15 -0
  48. azure/ai/evaluation/_evaluators/_content_safety/_sexual.py +15 -0
  49. azure/ai/evaluation/_evaluators/_content_safety/_violence.py +15 -0
  50. azure/ai/evaluation/_evaluators/_f1_score/_f1_score.py +28 -4
  51. azure/ai/evaluation/_evaluators/_fluency/_fluency.py +21 -2
  52. azure/ai/evaluation/_evaluators/_gleu/_gleu.py +26 -3
  53. azure/ai/evaluation/_evaluators/_groundedness/_groundedness.py +21 -3
  54. azure/ai/evaluation/_evaluators/_intent_resolution/__init__.py +7 -0
  55. azure/ai/evaluation/_evaluators/_intent_resolution/_intent_resolution.py +152 -0
  56. azure/ai/evaluation/_evaluators/_intent_resolution/intent_resolution.prompty +161 -0
  57. azure/ai/evaluation/_evaluators/_meteor/_meteor.py +26 -3
  58. azure/ai/evaluation/_evaluators/_qa/_qa.py +51 -7
  59. azure/ai/evaluation/_evaluators/_relevance/_relevance.py +26 -2
  60. azure/ai/evaluation/_evaluators/_response_completeness/__init__.py +7 -0
  61. azure/ai/evaluation/_evaluators/_response_completeness/_response_completeness.py +157 -0
  62. azure/ai/evaluation/_evaluators/_response_completeness/response_completeness.prompty +99 -0
  63. azure/ai/evaluation/_evaluators/_retrieval/_retrieval.py +21 -2
  64. azure/ai/evaluation/_evaluators/_rouge/_rouge.py +113 -4
  65. azure/ai/evaluation/_evaluators/_service_groundedness/_service_groundedness.py +23 -3
  66. azure/ai/evaluation/_evaluators/_similarity/_similarity.py +24 -5
  67. azure/ai/evaluation/_evaluators/_task_adherence/__init__.py +7 -0
  68. azure/ai/evaluation/_evaluators/_task_adherence/_task_adherence.py +148 -0
  69. azure/ai/evaluation/_evaluators/_task_adherence/task_adherence.prompty +117 -0
  70. azure/ai/evaluation/_evaluators/_tool_call_accuracy/__init__.py +9 -0
  71. azure/ai/evaluation/_evaluators/_tool_call_accuracy/_tool_call_accuracy.py +292 -0
  72. azure/ai/evaluation/_evaluators/_tool_call_accuracy/tool_call_accuracy.prompty +71 -0
  73. azure/ai/evaluation/_evaluators/_ungrounded_attributes/__init__.py +5 -0
  74. azure/ai/evaluation/_evaluators/_ungrounded_attributes/_ungrounded_attributes.py +103 -0
  75. azure/ai/evaluation/_evaluators/_xpia/xpia.py +2 -0
  76. azure/ai/evaluation/_exceptions.py +5 -1
  77. azure/ai/evaluation/_legacy/__init__.py +3 -0
  78. azure/ai/evaluation/_legacy/_batch_engine/__init__.py +9 -0
  79. azure/ai/evaluation/_legacy/_batch_engine/_config.py +45 -0
  80. azure/ai/evaluation/_legacy/_batch_engine/_engine.py +368 -0
  81. azure/ai/evaluation/_legacy/_batch_engine/_exceptions.py +88 -0
  82. azure/ai/evaluation/_legacy/_batch_engine/_logging.py +292 -0
  83. azure/ai/evaluation/_legacy/_batch_engine/_openai_injector.py +23 -0
  84. azure/ai/evaluation/_legacy/_batch_engine/_result.py +99 -0
  85. azure/ai/evaluation/_legacy/_batch_engine/_run.py +121 -0
  86. azure/ai/evaluation/_legacy/_batch_engine/_run_storage.py +128 -0
  87. azure/ai/evaluation/_legacy/_batch_engine/_run_submitter.py +217 -0
  88. azure/ai/evaluation/_legacy/_batch_engine/_status.py +25 -0
  89. azure/ai/evaluation/_legacy/_batch_engine/_trace.py +105 -0
  90. azure/ai/evaluation/_legacy/_batch_engine/_utils.py +82 -0
  91. azure/ai/evaluation/_legacy/_batch_engine/_utils_deprecated.py +131 -0
  92. azure/ai/evaluation/_legacy/prompty/__init__.py +36 -0
  93. azure/ai/evaluation/_legacy/prompty/_connection.py +182 -0
  94. azure/ai/evaluation/_legacy/prompty/_exceptions.py +59 -0
  95. azure/ai/evaluation/_legacy/prompty/_prompty.py +313 -0
  96. azure/ai/evaluation/_legacy/prompty/_utils.py +545 -0
  97. azure/ai/evaluation/_legacy/prompty/_yaml_utils.py +99 -0
  98. azure/ai/evaluation/_red_team/__init__.py +3 -0
  99. azure/ai/evaluation/_red_team/_attack_objective_generator.py +192 -0
  100. azure/ai/evaluation/_red_team/_attack_strategy.py +42 -0
  101. azure/ai/evaluation/_red_team/_callback_chat_target.py +74 -0
  102. azure/ai/evaluation/_red_team/_default_converter.py +21 -0
  103. azure/ai/evaluation/_red_team/_red_team.py +1858 -0
  104. azure/ai/evaluation/_red_team/_red_team_result.py +246 -0
  105. azure/ai/evaluation/_red_team/_utils/__init__.py +3 -0
  106. azure/ai/evaluation/_red_team/_utils/constants.py +64 -0
  107. azure/ai/evaluation/_red_team/_utils/formatting_utils.py +164 -0
  108. azure/ai/evaluation/_red_team/_utils/logging_utils.py +139 -0
  109. azure/ai/evaluation/_red_team/_utils/strategy_utils.py +188 -0
  110. azure/ai/evaluation/_safety_evaluation/__init__.py +3 -0
  111. azure/ai/evaluation/_safety_evaluation/_generated_rai_client.py +0 -0
  112. azure/ai/evaluation/_safety_evaluation/_safety_evaluation.py +741 -0
  113. azure/ai/evaluation/_version.py +2 -1
  114. azure/ai/evaluation/simulator/_adversarial_scenario.py +3 -1
  115. azure/ai/evaluation/simulator/_adversarial_simulator.py +61 -27
  116. azure/ai/evaluation/simulator/_conversation/__init__.py +4 -5
  117. azure/ai/evaluation/simulator/_conversation/_conversation.py +4 -0
  118. azure/ai/evaluation/simulator/_model_tools/_generated_rai_client.py +145 -0
  119. azure/ai/evaluation/simulator/_model_tools/_proxy_completion_model.py +2 -0
  120. azure/ai/evaluation/simulator/_model_tools/_rai_client.py +71 -1
  121. {azure_ai_evaluation-1.2.0.dist-info → azure_ai_evaluation-1.4.0.dist-info}/METADATA +75 -15
  122. azure_ai_evaluation-1.4.0.dist-info/RECORD +197 -0
  123. {azure_ai_evaluation-1.2.0.dist-info → azure_ai_evaluation-1.4.0.dist-info}/WHEEL +1 -1
  124. azure/ai/evaluation/_evaluators/_multimodal/__init__.py +0 -20
  125. azure/ai/evaluation/_evaluators/_multimodal/_content_safety_multimodal.py +0 -132
  126. azure/ai/evaluation/_evaluators/_multimodal/_content_safety_multimodal_base.py +0 -55
  127. azure/ai/evaluation/_evaluators/_multimodal/_hate_unfairness.py +0 -100
  128. azure/ai/evaluation/_evaluators/_multimodal/_protected_material.py +0 -124
  129. azure/ai/evaluation/_evaluators/_multimodal/_self_harm.py +0 -100
  130. azure/ai/evaluation/_evaluators/_multimodal/_sexual.py +0 -100
  131. azure/ai/evaluation/_evaluators/_multimodal/_violence.py +0 -100
  132. azure_ai_evaluation-1.2.0.dist-info/RECORD +0 -125
  133. {azure_ai_evaluation-1.2.0.dist-info → azure_ai_evaluation-1.4.0.dist-info}/NOTICE.txt +0 -0
  134. {azure_ai_evaluation-1.2.0.dist-info → azure_ai_evaluation-1.4.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,981 @@
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
+ from io import IOBase
9
+ import json
10
+ import sys
11
+ from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, overload
12
+
13
+ from azure.core import AsyncPipelineClient
14
+ from azure.core.exceptions import (
15
+ ClientAuthenticationError,
16
+ HttpResponseError,
17
+ ResourceExistsError,
18
+ ResourceNotFoundError,
19
+ ResourceNotModifiedError,
20
+ StreamClosedError,
21
+ StreamConsumedError,
22
+ map_error,
23
+ )
24
+ from azure.core.pipeline import PipelineResponse
25
+ from azure.core.rest import AsyncHttpResponse, HttpRequest
26
+ from azure.core.tracing.decorator_async import distributed_trace_async
27
+ from azure.core.utils import case_insensitive_dict
28
+
29
+ from ... import models as _models
30
+ from ..._model_base import SdkJSONEncoder, _deserialize
31
+ from ..._serialization import Deserializer, Serializer
32
+ from ...operations._operations import (
33
+ build_rai_svc_get_annotation_request,
34
+ build_rai_svc_get_attack_objectives_request,
35
+ build_rai_svc_get_jail_break_dataset_request,
36
+ build_rai_svc_get_jail_break_dataset_with_type_request,
37
+ build_rai_svc_get_operation_result_request,
38
+ build_rai_svc_get_template_parameters_image_request,
39
+ build_rai_svc_get_template_parameters_request,
40
+ build_rai_svc_get_template_parameters_with_type_request,
41
+ build_rai_svc_submit_annotation_request,
42
+ build_rai_svc_submit_aoai_evaluation_request,
43
+ build_rai_svc_submit_simulation_request,
44
+ )
45
+ from .._configuration import MachineLearningServicesClientConfiguration
46
+
47
+ if sys.version_info >= (3, 9):
48
+ from collections.abc import MutableMapping
49
+ else:
50
+ from typing import MutableMapping # type: ignore
51
+ JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object
52
+ T = TypeVar("T")
53
+ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
54
+
55
+
56
+ class RAISvcOperations:
57
+ """
58
+ .. warning::
59
+ **DO NOT** instantiate this class directly.
60
+
61
+ Instead, you should access the following operations through
62
+ :class:`~raiclient.aio.MachineLearningServicesClient`'s
63
+ :attr:`rai_svc` attribute.
64
+ """
65
+
66
+ def __init__(self, *args, **kwargs) -> None:
67
+ input_args = list(args)
68
+ self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
69
+ self._config: MachineLearningServicesClientConfiguration = (
70
+ input_args.pop(0) if input_args else kwargs.pop("config")
71
+ )
72
+ self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
73
+ self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
74
+
75
+ @distributed_trace_async
76
+ async def get_annotation(self, **kwargs: Any) -> List[str]:
77
+ """Get the supported annotation tasks.
78
+
79
+ :return: list of str
80
+ :rtype: list[str]
81
+ :raises ~azure.core.exceptions.HttpResponseError:
82
+ """
83
+ error_map: MutableMapping = {
84
+ 401: ClientAuthenticationError,
85
+ 404: ResourceNotFoundError,
86
+ 409: ResourceExistsError,
87
+ 304: ResourceNotModifiedError,
88
+ }
89
+ error_map.update(kwargs.pop("error_map", {}) or {})
90
+
91
+ _headers = kwargs.pop("headers", {}) or {}
92
+ _params = kwargs.pop("params", {}) or {}
93
+
94
+ cls: ClsType[List[str]] = kwargs.pop("cls", None)
95
+
96
+ _request = build_rai_svc_get_annotation_request(
97
+ api_version=self._config.api_version,
98
+ headers=_headers,
99
+ params=_params,
100
+ )
101
+ path_format_arguments = {
102
+ "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
103
+ "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"),
104
+ "resourceGroupName": self._serialize.url(
105
+ "self._config.resource_group_name", self._config.resource_group_name, "str"
106
+ ),
107
+ "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"),
108
+ }
109
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
110
+
111
+ _stream = kwargs.pop("stream", False)
112
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
113
+ _request, stream=_stream, **kwargs
114
+ )
115
+
116
+ response = pipeline_response.http_response
117
+
118
+ if response.status_code not in [200]:
119
+ if _stream:
120
+ try:
121
+ await response.read() # Load the body in memory and close the socket
122
+ except (StreamConsumedError, StreamClosedError):
123
+ pass
124
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
125
+ raise HttpResponseError(response=response)
126
+
127
+ if _stream:
128
+ deserialized = response.iter_bytes()
129
+ else:
130
+ deserialized = _deserialize(List[str], response.json())
131
+
132
+ if cls:
133
+ return cls(pipeline_response, deserialized, {}) # type: ignore
134
+
135
+ return deserialized # type: ignore
136
+
137
+ @overload
138
+ async def submit_annotation(
139
+ self, body: _models.AnnotationDTO, *, content_type: str = "application/json", **kwargs: Any
140
+ ) -> _models.LongRunningResponse:
141
+ """Submit a request for annotation.
142
+
143
+ :param body: Properties of a Prompt Version. Required.
144
+ :type body: ~raiclient.models.AnnotationDTO
145
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
146
+ Default value is "application/json".
147
+ :paramtype content_type: str
148
+ :return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
149
+ :rtype: ~raiclient.models.LongRunningResponse
150
+ :raises ~azure.core.exceptions.HttpResponseError:
151
+ """
152
+
153
+ @overload
154
+ async def submit_annotation(
155
+ self, body: JSON, *, content_type: str = "application/json", **kwargs: Any
156
+ ) -> _models.LongRunningResponse:
157
+ """Submit a request for annotation.
158
+
159
+ :param body: Properties of a Prompt Version. Required.
160
+ :type body: JSON
161
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
162
+ Default value is "application/json".
163
+ :paramtype content_type: str
164
+ :return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
165
+ :rtype: ~raiclient.models.LongRunningResponse
166
+ :raises ~azure.core.exceptions.HttpResponseError:
167
+ """
168
+
169
+ @overload
170
+ async def submit_annotation(
171
+ self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
172
+ ) -> _models.LongRunningResponse:
173
+ """Submit a request for annotation.
174
+
175
+ :param body: Properties of a Prompt Version. Required.
176
+ :type body: IO[bytes]
177
+ :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
178
+ Default value is "application/json".
179
+ :paramtype content_type: str
180
+ :return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
181
+ :rtype: ~raiclient.models.LongRunningResponse
182
+ :raises ~azure.core.exceptions.HttpResponseError:
183
+ """
184
+
185
+ @distributed_trace_async
186
+ async def submit_annotation(
187
+ self, body: Union[_models.AnnotationDTO, JSON, IO[bytes]], **kwargs: Any
188
+ ) -> _models.LongRunningResponse:
189
+ """Submit a request for annotation.
190
+
191
+ :param body: Properties of a Prompt Version. Is one of the following types: AnnotationDTO,
192
+ JSON, IO[bytes] Required.
193
+ :type body: ~raiclient.models.AnnotationDTO or JSON or IO[bytes]
194
+ :return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
195
+ :rtype: ~raiclient.models.LongRunningResponse
196
+ :raises ~azure.core.exceptions.HttpResponseError:
197
+ """
198
+ error_map: MutableMapping = {
199
+ 401: ClientAuthenticationError,
200
+ 404: ResourceNotFoundError,
201
+ 409: ResourceExistsError,
202
+ 304: ResourceNotModifiedError,
203
+ }
204
+ error_map.update(kwargs.pop("error_map", {}) or {})
205
+
206
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
207
+ _params = kwargs.pop("params", {}) or {}
208
+
209
+ content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
210
+ cls: ClsType[_models.LongRunningResponse] = kwargs.pop("cls", None)
211
+
212
+ content_type = content_type or "application/json"
213
+ _content = None
214
+ if isinstance(body, (IOBase, bytes)):
215
+ _content = body
216
+ else:
217
+ _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
218
+
219
+ _request = build_rai_svc_submit_annotation_request(
220
+ content_type=content_type,
221
+ api_version=self._config.api_version,
222
+ content=_content,
223
+ headers=_headers,
224
+ params=_params,
225
+ )
226
+ path_format_arguments = {
227
+ "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
228
+ "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"),
229
+ "resourceGroupName": self._serialize.url(
230
+ "self._config.resource_group_name", self._config.resource_group_name, "str"
231
+ ),
232
+ "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"),
233
+ }
234
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
235
+
236
+ _stream = kwargs.pop("stream", False)
237
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
238
+ _request, stream=_stream, **kwargs
239
+ )
240
+
241
+ response = pipeline_response.http_response
242
+
243
+ if response.status_code not in [202]:
244
+ if _stream:
245
+ try:
246
+ await response.read() # Load the body in memory and close the socket
247
+ except (StreamConsumedError, StreamClosedError):
248
+ pass
249
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
250
+ raise HttpResponseError(response=response)
251
+
252
+ if _stream:
253
+ deserialized = response.iter_bytes()
254
+ else:
255
+ deserialized = _deserialize(_models.LongRunningResponse, response.json())
256
+
257
+ if cls:
258
+ return cls(pipeline_response, deserialized, {}) # type: ignore
259
+
260
+ return deserialized # type: ignore
261
+
262
+ @distributed_trace_async
263
+ async def get_jail_break_dataset_with_type(self, type: str, **kwargs: Any) -> List[str]:
264
+ """Get the jailbreak dataset with type.
265
+
266
+ :param type: Type of jailbreak dataset. Required.
267
+ :type type: str
268
+ :return: list of str
269
+ :rtype: list[str]
270
+ :raises ~azure.core.exceptions.HttpResponseError:
271
+ """
272
+ error_map: MutableMapping = {
273
+ 401: ClientAuthenticationError,
274
+ 404: ResourceNotFoundError,
275
+ 409: ResourceExistsError,
276
+ 304: ResourceNotModifiedError,
277
+ }
278
+ error_map.update(kwargs.pop("error_map", {}) or {})
279
+
280
+ _headers = kwargs.pop("headers", {}) or {}
281
+ _params = kwargs.pop("params", {}) or {}
282
+
283
+ cls: ClsType[List[str]] = kwargs.pop("cls", None)
284
+
285
+ _request = build_rai_svc_get_jail_break_dataset_with_type_request(
286
+ type=type,
287
+ api_version=self._config.api_version,
288
+ headers=_headers,
289
+ params=_params,
290
+ )
291
+ path_format_arguments = {
292
+ "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
293
+ "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"),
294
+ "resourceGroupName": self._serialize.url(
295
+ "self._config.resource_group_name", self._config.resource_group_name, "str"
296
+ ),
297
+ "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"),
298
+ }
299
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
300
+
301
+ _stream = kwargs.pop("stream", False)
302
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
303
+ _request, stream=_stream, **kwargs
304
+ )
305
+
306
+ response = pipeline_response.http_response
307
+
308
+ if response.status_code not in [200]:
309
+ if _stream:
310
+ try:
311
+ await response.read() # Load the body in memory and close the socket
312
+ except (StreamConsumedError, StreamClosedError):
313
+ pass
314
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
315
+ raise HttpResponseError(response=response)
316
+
317
+ if _stream:
318
+ deserialized = response.iter_bytes()
319
+ else:
320
+ deserialized = _deserialize(List[str], response.json())
321
+
322
+ if cls:
323
+ return cls(pipeline_response, deserialized, {}) # type: ignore
324
+
325
+ return deserialized # type: ignore
326
+
327
+ @distributed_trace_async
328
+ async def get_attack_objectives(
329
+ self,
330
+ *,
331
+ risk_types: Optional[List[str]] = None,
332
+ lang: Optional[str] = None,
333
+ strategy: Optional[str] = None,
334
+ **kwargs: Any
335
+ ) -> List[_models.AttackObjective]:
336
+ """Get the attack objectives.
337
+
338
+ :keyword risk_types: Risk types for the attack objectives dataset. Default value is None.
339
+ :paramtype risk_types: list[str]
340
+ :keyword lang: The language for the attack objectives dataset, defaults to 'en'. Default value
341
+ is None.
342
+ :paramtype lang: str
343
+ :keyword strategy: The strategy. Default value is None.
344
+ :paramtype strategy: str
345
+ :return: list of AttackObjective
346
+ :rtype: list[~raiclient.models.AttackObjective]
347
+ :raises ~azure.core.exceptions.HttpResponseError:
348
+ """
349
+ error_map: MutableMapping = {
350
+ 401: ClientAuthenticationError,
351
+ 404: ResourceNotFoundError,
352
+ 409: ResourceExistsError,
353
+ 304: ResourceNotModifiedError,
354
+ }
355
+ error_map.update(kwargs.pop("error_map", {}) or {})
356
+
357
+ _headers = kwargs.pop("headers", {}) or {}
358
+ _params = kwargs.pop("params", {}) or {}
359
+
360
+ cls: ClsType[List[_models.AttackObjective]] = kwargs.pop("cls", None)
361
+
362
+ _request = build_rai_svc_get_attack_objectives_request(
363
+ risk_types=risk_types,
364
+ lang=lang,
365
+ strategy=strategy,
366
+ api_version=self._config.api_version,
367
+ headers=_headers,
368
+ params=_params,
369
+ )
370
+ path_format_arguments = {
371
+ "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
372
+ "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"),
373
+ "resourceGroupName": self._serialize.url(
374
+ "self._config.resource_group_name", self._config.resource_group_name, "str"
375
+ ),
376
+ "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"),
377
+ }
378
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
379
+
380
+ _stream = kwargs.pop("stream", False)
381
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
382
+ _request, stream=_stream, **kwargs
383
+ )
384
+
385
+ response = pipeline_response.http_response
386
+
387
+ if response.status_code not in [200]:
388
+ if _stream:
389
+ try:
390
+ await response.read() # Load the body in memory and close the socket
391
+ except (StreamConsumedError, StreamClosedError):
392
+ pass
393
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
394
+ raise HttpResponseError(response=response)
395
+
396
+ if _stream:
397
+ deserialized = response.iter_bytes()
398
+ else:
399
+ deserialized = _deserialize(List[_models.AttackObjective], response.json())
400
+
401
+ if cls:
402
+ return cls(pipeline_response, deserialized, {}) # type: ignore
403
+
404
+ return deserialized # type: ignore
405
+
406
+ @distributed_trace_async
407
+ async def get_jail_break_dataset(self, **kwargs: Any) -> List[str]:
408
+ """Get the jailbreak dataset.
409
+
410
+ :return: list of str
411
+ :rtype: list[str]
412
+ :raises ~azure.core.exceptions.HttpResponseError:
413
+ """
414
+ error_map: MutableMapping = {
415
+ 401: ClientAuthenticationError,
416
+ 404: ResourceNotFoundError,
417
+ 409: ResourceExistsError,
418
+ 304: ResourceNotModifiedError,
419
+ }
420
+ error_map.update(kwargs.pop("error_map", {}) or {})
421
+
422
+ _headers = kwargs.pop("headers", {}) or {}
423
+ _params = kwargs.pop("params", {}) or {}
424
+
425
+ cls: ClsType[List[str]] = kwargs.pop("cls", None)
426
+
427
+ _request = build_rai_svc_get_jail_break_dataset_request(
428
+ api_version=self._config.api_version,
429
+ headers=_headers,
430
+ params=_params,
431
+ )
432
+ path_format_arguments = {
433
+ "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
434
+ "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"),
435
+ "resourceGroupName": self._serialize.url(
436
+ "self._config.resource_group_name", self._config.resource_group_name, "str"
437
+ ),
438
+ "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"),
439
+ }
440
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
441
+
442
+ _stream = kwargs.pop("stream", False)
443
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
444
+ _request, stream=_stream, **kwargs
445
+ )
446
+
447
+ response = pipeline_response.http_response
448
+
449
+ if response.status_code not in [200]:
450
+ if _stream:
451
+ try:
452
+ await response.read() # Load the body in memory and close the socket
453
+ except (StreamConsumedError, StreamClosedError):
454
+ pass
455
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
456
+ raise HttpResponseError(response=response)
457
+
458
+ if _stream:
459
+ deserialized = response.iter_bytes()
460
+ else:
461
+ deserialized = _deserialize(List[str], response.json())
462
+
463
+ if cls:
464
+ return cls(pipeline_response, deserialized, {}) # type: ignore
465
+
466
+ return deserialized # type: ignore
467
+
468
+ @distributed_trace_async
469
+ async def get_template_parameters_with_type(self, type: str, **kwargs: Any) -> str:
470
+ """Get template parameters with type.
471
+
472
+ :param type: Type for the template parameters. Required.
473
+ :type type: str
474
+ :return: str
475
+ :rtype: str
476
+ :raises ~azure.core.exceptions.HttpResponseError:
477
+ """
478
+ error_map: MutableMapping = {
479
+ 401: ClientAuthenticationError,
480
+ 404: ResourceNotFoundError,
481
+ 409: ResourceExistsError,
482
+ 304: ResourceNotModifiedError,
483
+ }
484
+ error_map.update(kwargs.pop("error_map", {}) or {})
485
+
486
+ _headers = kwargs.pop("headers", {}) or {}
487
+ _params = kwargs.pop("params", {}) or {}
488
+
489
+ cls: ClsType[str] = kwargs.pop("cls", None)
490
+
491
+ _request = build_rai_svc_get_template_parameters_with_type_request(
492
+ type=type,
493
+ api_version=self._config.api_version,
494
+ headers=_headers,
495
+ params=_params,
496
+ )
497
+ path_format_arguments = {
498
+ "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
499
+ "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"),
500
+ "resourceGroupName": self._serialize.url(
501
+ "self._config.resource_group_name", self._config.resource_group_name, "str"
502
+ ),
503
+ "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"),
504
+ }
505
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
506
+
507
+ _stream = kwargs.pop("stream", False)
508
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
509
+ _request, stream=_stream, **kwargs
510
+ )
511
+
512
+ response = pipeline_response.http_response
513
+
514
+ if response.status_code not in [200]:
515
+ if _stream:
516
+ try:
517
+ await response.read() # Load the body in memory and close the socket
518
+ except (StreamConsumedError, StreamClosedError):
519
+ pass
520
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
521
+ raise HttpResponseError(response=response)
522
+
523
+ if _stream:
524
+ deserialized = response.iter_bytes()
525
+ else:
526
+ deserialized = _deserialize(str, response.json())
527
+
528
+ if cls:
529
+ return cls(pipeline_response, deserialized, {}) # type: ignore
530
+
531
+ return deserialized # type: ignore
532
+
533
+ @distributed_trace_async
534
+ async def get_template_parameters(self, **kwargs: Any) -> str:
535
+ """Get template parameters.
536
+
537
+ :return: str
538
+ :rtype: str
539
+ :raises ~azure.core.exceptions.HttpResponseError:
540
+ """
541
+ error_map: MutableMapping = {
542
+ 401: ClientAuthenticationError,
543
+ 404: ResourceNotFoundError,
544
+ 409: ResourceExistsError,
545
+ 304: ResourceNotModifiedError,
546
+ }
547
+ error_map.update(kwargs.pop("error_map", {}) or {})
548
+
549
+ _headers = kwargs.pop("headers", {}) or {}
550
+ _params = kwargs.pop("params", {}) or {}
551
+
552
+ cls: ClsType[str] = kwargs.pop("cls", None)
553
+
554
+ _request = build_rai_svc_get_template_parameters_request(
555
+ api_version=self._config.api_version,
556
+ headers=_headers,
557
+ params=_params,
558
+ )
559
+ path_format_arguments = {
560
+ "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
561
+ "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"),
562
+ "resourceGroupName": self._serialize.url(
563
+ "self._config.resource_group_name", self._config.resource_group_name, "str"
564
+ ),
565
+ "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"),
566
+ }
567
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
568
+
569
+ _stream = kwargs.pop("stream", False)
570
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
571
+ _request, stream=_stream, **kwargs
572
+ )
573
+
574
+ response = pipeline_response.http_response
575
+
576
+ if response.status_code not in [200]:
577
+ if _stream:
578
+ try:
579
+ await response.read() # Load the body in memory and close the socket
580
+ except (StreamConsumedError, StreamClosedError):
581
+ pass
582
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
583
+ raise HttpResponseError(response=response)
584
+
585
+ if _stream:
586
+ deserialized = response.iter_bytes()
587
+ else:
588
+ deserialized = _deserialize(str, response.json())
589
+
590
+ if cls:
591
+ return cls(pipeline_response, deserialized, {}) # type: ignore
592
+
593
+ return deserialized # type: ignore
594
+
595
+ @distributed_trace_async
596
+ async def get_template_parameters_image(self, *, path: str, **kwargs: Any) -> str:
597
+ """Get the template parameters image.
598
+
599
+ :keyword path: Image path. Required.
600
+ :paramtype path: str
601
+ :return: str
602
+ :rtype: str
603
+ :raises ~azure.core.exceptions.HttpResponseError:
604
+ """
605
+ error_map: MutableMapping = {
606
+ 401: ClientAuthenticationError,
607
+ 404: ResourceNotFoundError,
608
+ 409: ResourceExistsError,
609
+ 304: ResourceNotModifiedError,
610
+ }
611
+ error_map.update(kwargs.pop("error_map", {}) or {})
612
+
613
+ _headers = kwargs.pop("headers", {}) or {}
614
+ _params = kwargs.pop("params", {}) or {}
615
+
616
+ cls: ClsType[str] = kwargs.pop("cls", None)
617
+
618
+ _request = build_rai_svc_get_template_parameters_image_request(
619
+ path=path,
620
+ api_version=self._config.api_version,
621
+ headers=_headers,
622
+ params=_params,
623
+ )
624
+ path_format_arguments = {
625
+ "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
626
+ "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"),
627
+ "resourceGroupName": self._serialize.url(
628
+ "self._config.resource_group_name", self._config.resource_group_name, "str"
629
+ ),
630
+ "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"),
631
+ }
632
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
633
+
634
+ _stream = kwargs.pop("stream", False)
635
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
636
+ _request, stream=_stream, **kwargs
637
+ )
638
+
639
+ response = pipeline_response.http_response
640
+
641
+ if response.status_code not in [200]:
642
+ if _stream:
643
+ try:
644
+ await response.read() # Load the body in memory and close the socket
645
+ except (StreamConsumedError, StreamClosedError):
646
+ pass
647
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
648
+ raise HttpResponseError(response=response)
649
+
650
+ if _stream:
651
+ deserialized = response.iter_bytes()
652
+ else:
653
+ deserialized = _deserialize(str, response.json())
654
+
655
+ if cls:
656
+ return cls(pipeline_response, deserialized, {}) # type: ignore
657
+
658
+ return deserialized # type: ignore
659
+
660
+ @overload
661
+ async def submit_simulation(
662
+ self, body: _models.SimulationDTO, *, content_type: str = "application/json", **kwargs: Any
663
+ ) -> _models.LongRunningResponse:
664
+ """Submit a request for simulation.
665
+
666
+ :param body: Properties of a Prompt Version. Required.
667
+ :type body: ~raiclient.models.SimulationDTO
668
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
669
+ Default value is "application/json".
670
+ :paramtype content_type: str
671
+ :return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
672
+ :rtype: ~raiclient.models.LongRunningResponse
673
+ :raises ~azure.core.exceptions.HttpResponseError:
674
+ """
675
+
676
+ @overload
677
+ async def submit_simulation(
678
+ self, body: JSON, *, content_type: str = "application/json", **kwargs: Any
679
+ ) -> _models.LongRunningResponse:
680
+ """Submit a request for simulation.
681
+
682
+ :param body: Properties of a Prompt Version. Required.
683
+ :type body: JSON
684
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
685
+ Default value is "application/json".
686
+ :paramtype content_type: str
687
+ :return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
688
+ :rtype: ~raiclient.models.LongRunningResponse
689
+ :raises ~azure.core.exceptions.HttpResponseError:
690
+ """
691
+
692
+ @overload
693
+ async def submit_simulation(
694
+ self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
695
+ ) -> _models.LongRunningResponse:
696
+ """Submit a request for simulation.
697
+
698
+ :param body: Properties of a Prompt Version. Required.
699
+ :type body: IO[bytes]
700
+ :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
701
+ Default value is "application/json".
702
+ :paramtype content_type: str
703
+ :return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
704
+ :rtype: ~raiclient.models.LongRunningResponse
705
+ :raises ~azure.core.exceptions.HttpResponseError:
706
+ """
707
+
708
+ @distributed_trace_async
709
+ async def submit_simulation(
710
+ self, body: Union[_models.SimulationDTO, JSON, IO[bytes]], **kwargs: Any
711
+ ) -> _models.LongRunningResponse:
712
+ """Submit a request for simulation.
713
+
714
+ :param body: Properties of a Prompt Version. Is one of the following types: SimulationDTO,
715
+ JSON, IO[bytes] Required.
716
+ :type body: ~raiclient.models.SimulationDTO or JSON or IO[bytes]
717
+ :return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
718
+ :rtype: ~raiclient.models.LongRunningResponse
719
+ :raises ~azure.core.exceptions.HttpResponseError:
720
+ """
721
+ error_map: MutableMapping = {
722
+ 401: ClientAuthenticationError,
723
+ 404: ResourceNotFoundError,
724
+ 409: ResourceExistsError,
725
+ 304: ResourceNotModifiedError,
726
+ }
727
+ error_map.update(kwargs.pop("error_map", {}) or {})
728
+
729
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
730
+ _params = kwargs.pop("params", {}) or {}
731
+
732
+ content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
733
+ cls: ClsType[_models.LongRunningResponse] = kwargs.pop("cls", None)
734
+
735
+ content_type = content_type or "application/json"
736
+ _content = None
737
+ if isinstance(body, (IOBase, bytes)):
738
+ _content = body
739
+ else:
740
+ _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
741
+
742
+ _request = build_rai_svc_submit_simulation_request(
743
+ content_type=content_type,
744
+ api_version=self._config.api_version,
745
+ content=_content,
746
+ headers=_headers,
747
+ params=_params,
748
+ )
749
+ path_format_arguments = {
750
+ "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
751
+ "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"),
752
+ "resourceGroupName": self._serialize.url(
753
+ "self._config.resource_group_name", self._config.resource_group_name, "str"
754
+ ),
755
+ "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"),
756
+ }
757
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
758
+
759
+ _stream = kwargs.pop("stream", False)
760
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
761
+ _request, stream=_stream, **kwargs
762
+ )
763
+
764
+ response = pipeline_response.http_response
765
+
766
+ if response.status_code not in [202]:
767
+ if _stream:
768
+ try:
769
+ await response.read() # Load the body in memory and close the socket
770
+ except (StreamConsumedError, StreamClosedError):
771
+ pass
772
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
773
+ raise HttpResponseError(response=response)
774
+
775
+ if _stream:
776
+ deserialized = response.iter_bytes()
777
+ else:
778
+ deserialized = _deserialize(_models.LongRunningResponse, response.json())
779
+
780
+ if cls:
781
+ return cls(pipeline_response, deserialized, {}) # type: ignore
782
+
783
+ return deserialized # type: ignore
784
+
785
+ @overload
786
+ async def submit_aoai_evaluation(
787
+ self, body: _models.GradersDTO, *, content_type: str = "application/json", **kwargs: Any
788
+ ) -> _models.LongRunningResponse:
789
+ """Submit a request for graders.
790
+
791
+ :param body: Properties of a Prompt Version. Required.
792
+ :type body: ~raiclient.models.GradersDTO
793
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
794
+ Default value is "application/json".
795
+ :paramtype content_type: str
796
+ :return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
797
+ :rtype: ~raiclient.models.LongRunningResponse
798
+ :raises ~azure.core.exceptions.HttpResponseError:
799
+ """
800
+
801
+ @overload
802
+ async def submit_aoai_evaluation(
803
+ self, body: JSON, *, content_type: str = "application/json", **kwargs: Any
804
+ ) -> _models.LongRunningResponse:
805
+ """Submit a request for graders.
806
+
807
+ :param body: Properties of a Prompt Version. Required.
808
+ :type body: JSON
809
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
810
+ Default value is "application/json".
811
+ :paramtype content_type: str
812
+ :return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
813
+ :rtype: ~raiclient.models.LongRunningResponse
814
+ :raises ~azure.core.exceptions.HttpResponseError:
815
+ """
816
+
817
+ @overload
818
+ async def submit_aoai_evaluation(
819
+ self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
820
+ ) -> _models.LongRunningResponse:
821
+ """Submit a request for graders.
822
+
823
+ :param body: Properties of a Prompt Version. Required.
824
+ :type body: IO[bytes]
825
+ :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
826
+ Default value is "application/json".
827
+ :paramtype content_type: str
828
+ :return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
829
+ :rtype: ~raiclient.models.LongRunningResponse
830
+ :raises ~azure.core.exceptions.HttpResponseError:
831
+ """
832
+
833
+ @distributed_trace_async
834
+ async def submit_aoai_evaluation(
835
+ self, body: Union[_models.GradersDTO, JSON, IO[bytes]], **kwargs: Any
836
+ ) -> _models.LongRunningResponse:
837
+ """Submit a request for graders.
838
+
839
+ :param body: Properties of a Prompt Version. Is one of the following types: GradersDTO, JSON,
840
+ IO[bytes] Required.
841
+ :type body: ~raiclient.models.GradersDTO or JSON or IO[bytes]
842
+ :return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
843
+ :rtype: ~raiclient.models.LongRunningResponse
844
+ :raises ~azure.core.exceptions.HttpResponseError:
845
+ """
846
+ error_map: MutableMapping = {
847
+ 401: ClientAuthenticationError,
848
+ 404: ResourceNotFoundError,
849
+ 409: ResourceExistsError,
850
+ 304: ResourceNotModifiedError,
851
+ }
852
+ error_map.update(kwargs.pop("error_map", {}) or {})
853
+
854
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
855
+ _params = kwargs.pop("params", {}) or {}
856
+
857
+ content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
858
+ cls: ClsType[_models.LongRunningResponse] = kwargs.pop("cls", None)
859
+
860
+ content_type = content_type or "application/json"
861
+ _content = None
862
+ if isinstance(body, (IOBase, bytes)):
863
+ _content = body
864
+ else:
865
+ _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
866
+
867
+ _request = build_rai_svc_submit_aoai_evaluation_request(
868
+ content_type=content_type,
869
+ api_version=self._config.api_version,
870
+ content=_content,
871
+ headers=_headers,
872
+ params=_params,
873
+ )
874
+ path_format_arguments = {
875
+ "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
876
+ "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"),
877
+ "resourceGroupName": self._serialize.url(
878
+ "self._config.resource_group_name", self._config.resource_group_name, "str"
879
+ ),
880
+ "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"),
881
+ }
882
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
883
+
884
+ _stream = kwargs.pop("stream", False)
885
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
886
+ _request, stream=_stream, **kwargs
887
+ )
888
+
889
+ response = pipeline_response.http_response
890
+
891
+ if response.status_code not in [202]:
892
+ if _stream:
893
+ try:
894
+ await response.read() # Load the body in memory and close the socket
895
+ except (StreamConsumedError, StreamClosedError):
896
+ pass
897
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
898
+ raise HttpResponseError(response=response)
899
+
900
+ if _stream:
901
+ deserialized = response.iter_bytes()
902
+ else:
903
+ deserialized = _deserialize(_models.LongRunningResponse, response.json())
904
+
905
+ if cls:
906
+ return cls(pipeline_response, deserialized, {}) # type: ignore
907
+
908
+ return deserialized # type: ignore
909
+
910
+ @distributed_trace_async
911
+ async def get_operation_result(
912
+ self, operation_id: str, *, api_key: Optional[str] = None, model_endpoint: Optional[str] = None, **kwargs: Any
913
+ ) -> str:
914
+ """Get the operation result.
915
+
916
+ :param operation_id: Operation id. Required.
917
+ :type operation_id: str
918
+ :keyword api_key: Api key. Default value is None.
919
+ :paramtype api_key: str
920
+ :keyword model_endpoint: Model Endpoint. Default value is None.
921
+ :paramtype model_endpoint: str
922
+ :return: str
923
+ :rtype: str
924
+ :raises ~azure.core.exceptions.HttpResponseError:
925
+ """
926
+ error_map: MutableMapping = {
927
+ 401: ClientAuthenticationError,
928
+ 404: ResourceNotFoundError,
929
+ 409: ResourceExistsError,
930
+ 304: ResourceNotModifiedError,
931
+ }
932
+ error_map.update(kwargs.pop("error_map", {}) or {})
933
+
934
+ _headers = kwargs.pop("headers", {}) or {}
935
+ _params = kwargs.pop("params", {}) or {}
936
+
937
+ cls: ClsType[str] = kwargs.pop("cls", None)
938
+
939
+ _request = build_rai_svc_get_operation_result_request(
940
+ operation_id=operation_id,
941
+ api_key=api_key,
942
+ model_endpoint=model_endpoint,
943
+ api_version=self._config.api_version,
944
+ headers=_headers,
945
+ params=_params,
946
+ )
947
+ path_format_arguments = {
948
+ "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
949
+ "subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"),
950
+ "resourceGroupName": self._serialize.url(
951
+ "self._config.resource_group_name", self._config.resource_group_name, "str"
952
+ ),
953
+ "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"),
954
+ }
955
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
956
+
957
+ _stream = kwargs.pop("stream", False)
958
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
959
+ _request, stream=_stream, **kwargs
960
+ )
961
+
962
+ response = pipeline_response.http_response
963
+
964
+ if response.status_code not in [200]:
965
+ if _stream:
966
+ try:
967
+ await response.read() # Load the body in memory and close the socket
968
+ except (StreamConsumedError, StreamClosedError):
969
+ pass
970
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
971
+ raise HttpResponseError(response=response)
972
+
973
+ if _stream:
974
+ deserialized = response.iter_bytes()
975
+ else:
976
+ deserialized = _deserialize(str, response.json())
977
+
978
+ if cls:
979
+ return cls(pipeline_response, deserialized, {}) # type: ignore
980
+
981
+ return deserialized # type: ignore