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.

Files changed (108) hide show
  1. azure/ai/evaluation/__init__.py +4 -26
  2. azure/ai/evaluation/_common/constants.py +2 -9
  3. azure/ai/evaluation/_common/rai_service.py +122 -302
  4. azure/ai/evaluation/_common/utils.py +35 -393
  5. azure/ai/evaluation/_constants.py +6 -28
  6. azure/ai/evaluation/_evaluate/{_batch_run → _batch_run_client}/__init__.py +2 -3
  7. azure/ai/evaluation/_evaluate/{_batch_run/eval_run_context.py → _batch_run_client/batch_run_context.py} +8 -25
  8. azure/ai/evaluation/_evaluate/{_batch_run → _batch_run_client}/code_client.py +30 -68
  9. azure/ai/evaluation/_evaluate/_batch_run_client/proxy_client.py +61 -0
  10. azure/ai/evaluation/_evaluate/_eval_run.py +40 -117
  11. azure/ai/evaluation/_evaluate/_evaluate.py +255 -416
  12. azure/ai/evaluation/_evaluate/_telemetry/__init__.py +19 -24
  13. azure/ai/evaluation/_evaluate/_utils.py +47 -108
  14. azure/ai/evaluation/_evaluators/_bleu/_bleu.py +19 -18
  15. azure/ai/evaluation/_evaluators/{_retrieval → _chat}/__init__.py +2 -2
  16. azure/ai/evaluation/_evaluators/_chat/_chat.py +350 -0
  17. azure/ai/evaluation/_evaluators/{_service_groundedness → _chat/retrieval}/__init__.py +2 -2
  18. azure/ai/evaluation/_evaluators/_chat/retrieval/_retrieval.py +163 -0
  19. azure/ai/evaluation/_evaluators/_chat/retrieval/retrieval.prompty +48 -0
  20. azure/ai/evaluation/_evaluators/_coherence/_coherence.py +93 -78
  21. azure/ai/evaluation/_evaluators/_coherence/coherence.prompty +39 -76
  22. azure/ai/evaluation/_evaluators/_content_safety/__init__.py +4 -0
  23. azure/ai/evaluation/_evaluators/_content_safety/_content_safety.py +68 -104
  24. azure/ai/evaluation/_evaluators/{_multimodal/_content_safety_multimodal_base.py → _content_safety/_content_safety_base.py} +35 -24
  25. azure/ai/evaluation/_evaluators/_content_safety/_content_safety_chat.py +296 -0
  26. azure/ai/evaluation/_evaluators/_content_safety/_hate_unfairness.py +54 -105
  27. azure/ai/evaluation/_evaluators/_content_safety/_self_harm.py +52 -99
  28. azure/ai/evaluation/_evaluators/_content_safety/_sexual.py +52 -101
  29. azure/ai/evaluation/_evaluators/_content_safety/_violence.py +51 -101
  30. azure/ai/evaluation/_evaluators/_eci/_eci.py +55 -45
  31. azure/ai/evaluation/_evaluators/_f1_score/_f1_score.py +20 -36
  32. azure/ai/evaluation/_evaluators/_fluency/_fluency.py +94 -76
  33. azure/ai/evaluation/_evaluators/_fluency/fluency.prompty +41 -66
  34. azure/ai/evaluation/_evaluators/_gleu/_gleu.py +17 -15
  35. azure/ai/evaluation/_evaluators/_groundedness/_groundedness.py +92 -113
  36. azure/ai/evaluation/_evaluators/_groundedness/groundedness.prompty +54 -0
  37. azure/ai/evaluation/_evaluators/_meteor/_meteor.py +27 -21
  38. azure/ai/evaluation/_evaluators/_protected_material/_protected_material.py +80 -89
  39. azure/ai/evaluation/_evaluators/_protected_materials/__init__.py +5 -0
  40. azure/ai/evaluation/_evaluators/_protected_materials/_protected_materials.py +104 -0
  41. azure/ai/evaluation/_evaluators/_qa/_qa.py +43 -25
  42. azure/ai/evaluation/_evaluators/_relevance/_relevance.py +101 -84
  43. azure/ai/evaluation/_evaluators/_relevance/relevance.prompty +47 -78
  44. azure/ai/evaluation/_evaluators/_rouge/_rouge.py +27 -27
  45. azure/ai/evaluation/_evaluators/_similarity/_similarity.py +45 -55
  46. azure/ai/evaluation/_evaluators/_similarity/similarity.prompty +5 -0
  47. azure/ai/evaluation/_evaluators/_xpia/xpia.py +106 -91
  48. azure/ai/evaluation/_exceptions.py +7 -28
  49. azure/ai/evaluation/_http_utils.py +134 -205
  50. azure/ai/evaluation/_model_configurations.py +8 -104
  51. azure/ai/evaluation/_version.py +1 -1
  52. azure/ai/evaluation/simulator/__init__.py +2 -3
  53. azure/ai/evaluation/simulator/_adversarial_scenario.py +1 -20
  54. azure/ai/evaluation/simulator/_adversarial_simulator.py +95 -116
  55. azure/ai/evaluation/simulator/_constants.py +1 -11
  56. azure/ai/evaluation/simulator/_conversation/__init__.py +13 -14
  57. azure/ai/evaluation/simulator/_conversation/_conversation.py +20 -20
  58. azure/ai/evaluation/simulator/_direct_attack_simulator.py +68 -34
  59. azure/ai/evaluation/simulator/_helpers/__init__.py +1 -1
  60. azure/ai/evaluation/simulator/_helpers/_simulator_data_classes.py +28 -31
  61. azure/ai/evaluation/simulator/_indirect_attack_simulator.py +95 -108
  62. azure/ai/evaluation/simulator/_model_tools/_identity_manager.py +22 -70
  63. azure/ai/evaluation/simulator/_model_tools/_proxy_completion_model.py +14 -30
  64. azure/ai/evaluation/simulator/_model_tools/_rai_client.py +14 -25
  65. azure/ai/evaluation/simulator/_model_tools/_template_handler.py +24 -68
  66. azure/ai/evaluation/simulator/_model_tools/models.py +21 -19
  67. azure/ai/evaluation/simulator/_prompty/task_query_response.prompty +10 -6
  68. azure/ai/evaluation/simulator/_prompty/task_simulate.prompty +5 -6
  69. azure/ai/evaluation/simulator/_tracing.py +28 -25
  70. azure/ai/evaluation/simulator/_utils.py +13 -34
  71. azure/ai/evaluation/simulator/simulator.py +579 -0
  72. azure_ai_evaluation-1.0.0b1.dist-info/METADATA +377 -0
  73. azure_ai_evaluation-1.0.0b1.dist-info/RECORD +97 -0
  74. {azure_ai_evaluation-1.0.0.dist-info → azure_ai_evaluation-1.0.0b1.dist-info}/WHEEL +1 -1
  75. azure/ai/evaluation/_common/_experimental.py +0 -172
  76. azure/ai/evaluation/_common/math.py +0 -89
  77. azure/ai/evaluation/_evaluate/_batch_run/proxy_client.py +0 -99
  78. azure/ai/evaluation/_evaluate/_batch_run/target_run_context.py +0 -46
  79. azure/ai/evaluation/_evaluators/_common/__init__.py +0 -13
  80. azure/ai/evaluation/_evaluators/_common/_base_eval.py +0 -344
  81. azure/ai/evaluation/_evaluators/_common/_base_prompty_eval.py +0 -88
  82. azure/ai/evaluation/_evaluators/_common/_base_rai_svc_eval.py +0 -133
  83. azure/ai/evaluation/_evaluators/_groundedness/groundedness_with_query.prompty +0 -113
  84. azure/ai/evaluation/_evaluators/_groundedness/groundedness_without_query.prompty +0 -99
  85. azure/ai/evaluation/_evaluators/_multimodal/__init__.py +0 -20
  86. azure/ai/evaluation/_evaluators/_multimodal/_content_safety_multimodal.py +0 -132
  87. azure/ai/evaluation/_evaluators/_multimodal/_hate_unfairness.py +0 -100
  88. azure/ai/evaluation/_evaluators/_multimodal/_protected_material.py +0 -124
  89. azure/ai/evaluation/_evaluators/_multimodal/_self_harm.py +0 -100
  90. azure/ai/evaluation/_evaluators/_multimodal/_sexual.py +0 -100
  91. azure/ai/evaluation/_evaluators/_multimodal/_violence.py +0 -100
  92. azure/ai/evaluation/_evaluators/_retrieval/_retrieval.py +0 -112
  93. azure/ai/evaluation/_evaluators/_retrieval/retrieval.prompty +0 -93
  94. azure/ai/evaluation/_evaluators/_service_groundedness/_service_groundedness.py +0 -148
  95. azure/ai/evaluation/_vendor/__init__.py +0 -3
  96. azure/ai/evaluation/_vendor/rouge_score/__init__.py +0 -14
  97. azure/ai/evaluation/_vendor/rouge_score/rouge_scorer.py +0 -328
  98. azure/ai/evaluation/_vendor/rouge_score/scoring.py +0 -63
  99. azure/ai/evaluation/_vendor/rouge_score/tokenize.py +0 -63
  100. azure/ai/evaluation/_vendor/rouge_score/tokenizers.py +0 -53
  101. azure/ai/evaluation/simulator/_data_sources/__init__.py +0 -3
  102. azure/ai/evaluation/simulator/_data_sources/grounding.json +0 -1150
  103. azure/ai/evaluation/simulator/_prompty/__init__.py +0 -0
  104. azure/ai/evaluation/simulator/_simulator.py +0 -716
  105. azure_ai_evaluation-1.0.0.dist-info/METADATA +0 -595
  106. azure_ai_evaluation-1.0.0.dist-info/NOTICE.txt +0 -70
  107. azure_ai_evaluation-1.0.0.dist-info/RECORD +0 -119
  108. {azure_ai_evaluation-1.0.0.dist-info → azure_ai_evaluation-1.0.0b1.dist-info}/top_level.txt +0 -0
@@ -3,11 +3,9 @@
3
3
  # ---------------------------------------------------------
4
4
 
5
5
 
6
- from typing import Any, Dict, MutableMapping, Optional, TypedDict, cast
6
+ from functools import wraps
7
+ from typing import Any, Awaitable, Callable, Dict, MutableMapping, Optional
7
8
 
8
- from typing_extensions import Self, Unpack
9
-
10
- from azure.ai.evaluation._user_agent import USER_AGENT
11
9
  from azure.core.configuration import Configuration
12
10
  from azure.core.pipeline import AsyncPipeline, Pipeline
13
11
  from azure.core.pipeline.policies import (
@@ -30,27 +28,83 @@ from azure.core.pipeline.transport import ( # pylint: disable=non-abstract-tran
30
28
  )
31
29
  from azure.core.rest import AsyncHttpResponse, HttpRequest, HttpResponse
32
30
  from azure.core.rest._rest_py3 import ContentType, FilesType, ParamsType
31
+ from typing_extensions import Self
32
+
33
+ from azure.ai.evaluation._user_agent import USER_AGENT
33
34
 
34
35
 
35
- class RequestKwargs(TypedDict, total=False):
36
- """Keyword arguments for request-style http request functions
36
+ def _request_fn(f: Callable[["HttpPipeline"], None]):
37
+ """Decorator to generate convenience methods for HTTP method.
38
+
39
+ :param Callable[["HttpPipeline"],None] f: A HttpPipeline classmethod to wrap.
40
+ The f.__name__ is the HTTP method used
41
+ :return: A wrapped callable that sends a `f.__name__` request
42
+ :rtype: Callable
43
+ """
44
+
45
+ @wraps(f)
46
+ def request_fn(
47
+ self: "HttpPipeline",
48
+ url: str,
49
+ *,
50
+ params: Optional[ParamsType] = None,
51
+ headers: Optional[MutableMapping[str, str]] = None,
52
+ json: Any = None,
53
+ content: Optional[ContentType] = None,
54
+ data: Optional[Dict[str, Any]] = None,
55
+ files: Optional[FilesType] = None,
56
+ **kwargs,
57
+ ) -> HttpResponse:
58
+ return self.request(
59
+ f.__name__.upper(),
60
+ url,
61
+ params=params,
62
+ headers=headers,
63
+ json=json,
64
+ content=content,
65
+ data=data,
66
+ files=files,
67
+ **kwargs,
68
+ )
69
+
70
+ return request_fn
37
71
 
38
- .. note::
39
72
 
40
- Ideally, we'd be able to express that these are the known subset of kwargs, but it's possible to provide
41
- others. But that currently isn't possible; there's no way currently to express a TypedDict that expects
42
- a known set of keys and an unknown set of keys.
73
+ def _async_request_fn(f: Callable[["AsyncHttpPipeline"], Awaitable[None]]):
74
+ """Decorator to generate convenience methods for HTTP method.
43
75
 
44
- PEP 728 - TypedDict with Typed Extra Items (https://peps.python.org/pep-0728/) would rectify this but it's
45
- still in Draft status.
76
+ :param Callable[["HttpPipeline"],None] f: A HttpPipeline classmethod to wrap.
77
+ The f.__name__ is the HTTP method used
78
+ :return: A wrapped callable that sends a `f.__name__` request
79
+ :rtype: Callable
46
80
  """
47
81
 
48
- params: ParamsType
49
- headers: MutableMapping[str, str]
50
- json: Any
51
- content: ContentType
52
- data: Dict[str, Any]
53
- files: FilesType
82
+ @wraps(f)
83
+ async def request_fn(
84
+ self: "AsyncHttpPipeline",
85
+ url: str,
86
+ *,
87
+ params: Optional[ParamsType] = None,
88
+ headers: Optional[MutableMapping[str, str]] = None,
89
+ json: Any = None,
90
+ content: Optional[ContentType] = None,
91
+ data: Optional[Dict[str, Any]] = None,
92
+ files: Optional[FilesType] = None,
93
+ **kwargs,
94
+ ) -> AsyncHttpResponse:
95
+ return await self.request(
96
+ f.__name__.upper(),
97
+ url,
98
+ params=params,
99
+ headers=headers,
100
+ json=json,
101
+ content=content,
102
+ data=data,
103
+ files=files,
104
+ **kwargs,
105
+ )
106
+
107
+ return request_fn
54
108
 
55
109
 
56
110
  class HttpPipeline(Pipeline):
@@ -91,32 +145,14 @@ class HttpPipeline(Pipeline):
91
145
  :param RedirectPolicy redirect_policy:
92
146
  """
93
147
  config = config or Configuration()
94
- config.headers_policy = (
95
- headers_policy or cast(Optional[HeadersPolicy], config.headers_policy) or HeadersPolicy(**kwargs)
96
- )
97
- config.proxy_policy = proxy_policy or cast(Optional[ProxyPolicy], config.proxy_policy) or ProxyPolicy(**kwargs)
98
- config.redirect_policy = (
99
- redirect_policy or cast(Optional[RedirectPolicy], config.redirect_policy) or RedirectPolicy(**kwargs)
100
- )
101
- config.retry_policy = retry_policy or cast(Optional[RetryPolicy], config.retry_policy) or RetryPolicy(**kwargs)
102
- config.custom_hook_policy = (
103
- custom_hook_policy
104
- or cast(Optional[CustomHookPolicy], config.custom_hook_policy)
105
- or CustomHookPolicy(**kwargs)
106
- )
107
- config.logging_policy = (
108
- logging_policy
109
- or cast(Optional[NetworkTraceLoggingPolicy], config.logging_policy)
110
- or NetworkTraceLoggingPolicy(**kwargs)
111
- )
112
- config.http_logging_policy = (
113
- http_logging_policy
114
- or cast(Optional[HttpLoggingPolicy], config.http_logging_policy)
115
- or HttpLoggingPolicy(**kwargs)
116
- )
117
- config.user_agent_policy = (
118
- user_agent_policy or cast(Optional[UserAgentPolicy], config.user_agent_policy) or UserAgentPolicy(**kwargs)
119
- )
148
+ config.headers_policy = headers_policy or config.headers_policy or HeadersPolicy(**kwargs)
149
+ config.proxy_policy = proxy_policy or config.proxy_policy or ProxyPolicy(**kwargs)
150
+ config.redirect_policy = redirect_policy or config.redirect_policy or RedirectPolicy(**kwargs)
151
+ config.retry_policy = retry_policy or config.retry_policy or RetryPolicy(**kwargs)
152
+ config.custom_hook_policy = custom_hook_policy or config.custom_hook_policy or CustomHookPolicy(**kwargs)
153
+ config.logging_policy = logging_policy or config.logging_policy or NetworkTraceLoggingPolicy(**kwargs)
154
+ config.http_logging_policy = http_logging_policy or config.http_logging_policy or HttpLoggingPolicy(**kwargs)
155
+ config.user_agent_policy = user_agent_policy or config.user_agent_policy or UserAgentPolicy(**kwargs)
120
156
  config.polling_interval = kwargs.get("polling_interval", 30)
121
157
 
122
158
  super().__init__(
@@ -130,6 +166,7 @@ class HttpPipeline(Pipeline):
130
166
  config.proxy_policy,
131
167
  config.redirect_policy,
132
168
  config.retry_policy,
169
+ config.authentication_policy,
133
170
  config.custom_hook_policy,
134
171
  config.logging_policy,
135
172
  ],
@@ -162,6 +199,7 @@ class HttpPipeline(Pipeline):
162
199
  files: Optional[FilesType] = None,
163
200
  **kwargs,
164
201
  ) -> HttpResponse:
202
+
165
203
  request = HttpRequest(
166
204
  method,
167
205
  url,
@@ -175,78 +213,33 @@ class HttpPipeline(Pipeline):
175
213
 
176
214
  return self.run(request, **kwargs).http_response
177
215
 
178
- def delete(self: "HttpPipeline", url: str, **kwargs: Unpack[RequestKwargs]) -> HttpResponse:
179
- """Send a DELETE request.
216
+ @_request_fn
217
+ def delete(self) -> None:
218
+ """Send a DELETE request."""
180
219
 
181
- :param str url: The request url
182
- :returns: The request response
183
- :rtype: HttpResponse
184
- """
185
-
186
- return self.request(self.delete.__name__.upper(), url, **kwargs)
187
-
188
- def put(self: "HttpPipeline", url: str, **kwargs: Unpack[RequestKwargs]) -> HttpResponse:
189
- """Send a PUT request.
190
-
191
- :param str url: The request url
192
- :returns: The request response
193
- :rtype: HttpResponse
194
- """
195
-
196
- return self.request(self.put.__name__.upper(), url, **kwargs)
197
-
198
- def get(self: "HttpPipeline", url: str, **kwargs: Unpack[RequestKwargs]) -> HttpResponse:
199
- """Send a GET request.
200
-
201
- :param str url: The request url
202
- :returns: The request response
203
- :rtype: HttpResponse
204
- """
205
-
206
- return self.request(self.get.__name__.upper(), url, **kwargs)
207
-
208
- def post(self: "HttpPipeline", url: str, **kwargs: Unpack[RequestKwargs]) -> HttpResponse:
209
- """Send a POST request.
210
-
211
- :param str url: The request url
212
- :returns: The request response
213
- :rtype: HttpResponse
214
- """
220
+ @_request_fn
221
+ def put(self) -> None:
222
+ """Send a PUT request."""
215
223
 
216
- return self.request(self.post.__name__.upper(), url, **kwargs)
224
+ @_request_fn
225
+ def get(self) -> None:
226
+ """Send a GET request."""
217
227
 
218
- def head(self: "HttpPipeline", url: str, **kwargs: Unpack[RequestKwargs]) -> HttpResponse:
219
- """Send a HEAD request.
228
+ @_request_fn
229
+ def post(self) -> None:
230
+ """Send a POST request."""
220
231
 
221
- :param str url: The request url
222
- :returns: The request response
223
- :rtype: HttpResponse
224
- """
225
-
226
- return self.request(self.head.__name__.upper(), url, **kwargs)
232
+ @_request_fn
233
+ def head(self) -> None:
234
+ """Send a HEAD request."""
227
235
 
228
- def options(self: "HttpPipeline", url: str, **kwargs: Unpack[RequestKwargs]) -> HttpResponse:
229
- """Send a OPTIONS request.
230
-
231
- :param str url: The request url
232
- :returns: The request response
233
- :rtype: HttpResponse
234
- """
236
+ @_request_fn
237
+ def options(self) -> None:
238
+ """Send a OPTIONS request."""
235
239
 
236
- return self.request(self.options.__name__.upper(), url, **kwargs)
237
-
238
- def patch(self: "HttpPipeline", url: str, **kwargs: Unpack[RequestKwargs]) -> HttpResponse:
239
- """Send a PATCH request.
240
-
241
- :param str url: The request url
242
- :returns: The request response
243
- :rtype: HttpResponse
244
- """
245
-
246
- return self.request(self.patch.__name__.upper(), url, **kwargs)
247
-
248
- def __enter__(self) -> Self:
249
- return cast(Self, super().__enter__())
240
+ @_request_fn
241
+ def patch(self) -> None:
242
+ """Send a PATCH request."""
250
243
 
251
244
 
252
245
  class AsyncHttpPipeline(AsyncPipeline):
@@ -287,36 +280,14 @@ class AsyncHttpPipeline(AsyncPipeline):
287
280
  :param AsyncRedirectPolicy redirect_policy:
288
281
  """
289
282
  config = config or Configuration()
290
- config.headers_policy = (
291
- headers_policy or cast(Optional[HeadersPolicy], config.headers_policy) or HeadersPolicy(**kwargs)
292
- )
293
- config.proxy_policy = proxy_policy or cast(Optional[ProxyPolicy], config.proxy_policy) or ProxyPolicy(**kwargs)
294
- config.redirect_policy = (
295
- redirect_policy
296
- or cast(Optional[AsyncRedirectPolicy], config.redirect_policy)
297
- or AsyncRedirectPolicy(**kwargs)
298
- )
299
- config.retry_policy = (
300
- retry_policy or cast(Optional[AsyncRetryPolicy], config.retry_policy) or AsyncRetryPolicy(**kwargs)
301
- )
302
- config.custom_hook_policy = (
303
- custom_hook_policy
304
- or cast(Optional[CustomHookPolicy], config.custom_hook_policy)
305
- or CustomHookPolicy(**kwargs)
306
- )
307
- config.logging_policy = (
308
- logging_policy
309
- or cast(Optional[NetworkTraceLoggingPolicy], config.logging_policy)
310
- or NetworkTraceLoggingPolicy(**kwargs)
311
- )
312
- config.http_logging_policy = (
313
- http_logging_policy
314
- or cast(Optional[HttpLoggingPolicy], config.http_logging_policy)
315
- or HttpLoggingPolicy(**kwargs)
316
- )
317
- config.user_agent_policy = (
318
- user_agent_policy or cast(Optional[UserAgentPolicy], config.user_agent_policy) or UserAgentPolicy(**kwargs)
319
- )
283
+ config.headers_policy = headers_policy or config.headers_policy or HeadersPolicy(**kwargs)
284
+ config.proxy_policy = proxy_policy or config.proxy_policy or ProxyPolicy(**kwargs)
285
+ config.redirect_policy = redirect_policy or config.redirect_policy or AsyncRedirectPolicy(**kwargs)
286
+ config.retry_policy = retry_policy or config.retry_policy or AsyncRetryPolicy(**kwargs)
287
+ config.custom_hook_policy = custom_hook_policy or config.custom_hook_policy or CustomHookPolicy(**kwargs)
288
+ config.logging_policy = logging_policy or config.logging_policy or NetworkTraceLoggingPolicy(**kwargs)
289
+ config.http_logging_policy = http_logging_policy or config.http_logging_policy or HttpLoggingPolicy(**kwargs)
290
+ config.user_agent_policy = user_agent_policy or config.user_agent_policy or UserAgentPolicy(**kwargs)
320
291
  config.polling_interval = kwargs.get("polling_interval", 30)
321
292
 
322
293
  super().__init__(
@@ -330,6 +301,7 @@ class AsyncHttpPipeline(AsyncPipeline):
330
301
  config.proxy_policy,
331
302
  config.redirect_policy,
332
303
  config.retry_policy,
304
+ config.authentication_policy,
333
305
  config.custom_hook_policy,
334
306
  config.logging_policy,
335
307
  ],
@@ -362,6 +334,7 @@ class AsyncHttpPipeline(AsyncPipeline):
362
334
  files: Optional[FilesType] = None,
363
335
  **kwargs,
364
336
  ) -> AsyncHttpResponse:
337
+
365
338
  request = HttpRequest(
366
339
  method,
367
340
  url,
@@ -375,77 +348,33 @@ class AsyncHttpPipeline(AsyncPipeline):
375
348
 
376
349
  return (await self.run(request, **kwargs)).http_response
377
350
 
378
- async def delete(self: "AsyncHttpPipeline", url: str, **kwargs: Unpack[RequestKwargs]) -> AsyncHttpResponse:
379
- """Send a DELETE request.
351
+ @_async_request_fn
352
+ async def delete(self) -> None:
353
+ """Send a DELETE request."""
380
354
 
381
- :param str url: The request url
382
- :returns: The request response
383
- :rtype: AsyncHttpResponse
384
- """
385
- return await self.request(self.delete.__name__.upper(), url, **kwargs)
386
-
387
- async def put(self: "AsyncHttpPipeline", url: str, **kwargs: Unpack[RequestKwargs]) -> AsyncHttpResponse:
388
- """Send a PUT request.
355
+ @_async_request_fn
356
+ async def put(self) -> None:
357
+ """Send a PUT request."""
389
358
 
390
- :param str url: The request url
391
- :returns: The request response
392
- :rtype: AsyncHttpResponse
393
- """
359
+ @_async_request_fn
360
+ async def get(self) -> None:
361
+ """Send a GET request."""
394
362
 
395
- return await self.request(self.put.__name__.upper(), url, **kwargs)
363
+ @_async_request_fn
364
+ async def post(self) -> None:
365
+ """Send a POST request."""
396
366
 
397
- async def get(self: "AsyncHttpPipeline", url: str, **kwargs: Unpack[RequestKwargs]) -> AsyncHttpResponse:
398
- """Send a GET request.
399
-
400
- :param str url: The request url
401
- :returns: The request response
402
- :rtype: AsyncHttpResponse
403
- """
404
-
405
- return await self.request(self.get.__name__.upper(), url, **kwargs)
406
-
407
- async def post(self: "AsyncHttpPipeline", url: str, **kwargs: Unpack[RequestKwargs]) -> AsyncHttpResponse:
408
- """Send a POST request.
409
-
410
- :param str url: The request url
411
- :returns: The request response
412
- :rtype: AsyncHttpResponse
413
- """
414
-
415
- return await self.request(self.post.__name__.upper(), url, **kwargs)
416
-
417
- async def head(self: "AsyncHttpPipeline", url: str, **kwargs: Unpack[RequestKwargs]) -> AsyncHttpResponse:
418
- """Send a HEAD request.
419
-
420
- :param str url: The request url
421
- :returns: The request response
422
- :rtype: AsyncHttpResponse
423
- """
424
-
425
- return await self.request(self.head.__name__.upper(), url, **kwargs)
426
-
427
- async def options(self: "AsyncHttpPipeline", url: str, **kwargs: Unpack[RequestKwargs]) -> AsyncHttpResponse:
428
- """Send a OPTIONS request.
429
-
430
- :param str url: The request url
431
- :returns: The request response
432
- :rtype: AsyncHttpResponse
433
- """
434
-
435
- return await self.request(self.options.__name__.upper(), url, **kwargs)
436
-
437
- async def patch(self: "AsyncHttpPipeline", url: str, **kwargs: Unpack[RequestKwargs]) -> AsyncHttpResponse:
438
- """Send a PATCH request.
439
-
440
- :param str url: The request url
441
- :returns: The request response
442
- :rtype: AsyncHttpResponse
443
- """
367
+ @_async_request_fn
368
+ async def head(self) -> None:
369
+ """Send a HEAD request."""
444
370
 
445
- return await self.request(self.patch.__name__.upper(), url, **kwargs)
371
+ @_async_request_fn
372
+ async def options(self) -> None:
373
+ """Send a OPTIONS request."""
446
374
 
447
- async def __aenter__(self) -> Self:
448
- return cast(Self, await super().__aenter__())
375
+ @_async_request_fn
376
+ async def patch(self) -> None:
377
+ """Send a PATCH request."""
449
378
 
450
379
 
451
380
  def get_http_client() -> HttpPipeline:
@@ -2,122 +2,26 @@
2
2
  # Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  # ---------------------------------------------------------
4
4
 
5
- from typing import Any, Dict, List, Literal, TypedDict, Union
5
+ from typing import TypedDict
6
6
 
7
- from typing_extensions import NotRequired
8
7
 
9
-
10
- class AzureOpenAIModelConfiguration(TypedDict):
11
- """Model configuration for Azure OpenAI models
12
-
13
- :param type: The type of the model configuration. Should be 'azure_openai' for AzureOpenAIModelConfiguration
14
- :type type: NotRequired[Literal["azure_openai"]]
15
- :param azure_deployment: Name of Azure OpenAI deployment to make requests to
16
- :type azure_deployment: str
17
- :param azure_endpoint: Endpoint of Azure OpenAI resource to make requests to
18
- :type azure_endpoint: str
19
- :param api_key: API key of Azure OpenAI resource
20
- :type api_key: str
21
- :param api_version: API version to use in request to Azure OpenAI deployment. Optional.
22
- :type api_version: NotRequired[str]
23
-
24
- .. admonition:: Example:
25
-
26
- .. literalinclude:: ../samples/evaluation_samples_common.py
27
- :start-after: [START create_AOAI_model_config]
28
- :end-before: [END create_AOAI_model_config]
29
- :language: python
30
- :dedent: 8
31
- :caption: Creating an AzureOpenAIModelConfiguration object.
32
-
33
- """
34
-
35
- type: NotRequired[Literal["azure_openai"]]
8
+ class AzureOpenAIModelConfigurationBase(TypedDict):
36
9
  azure_deployment: str
37
10
  azure_endpoint: str
38
- """Endpoint of Azure OpenAI resource to make request to"""
39
- api_key: NotRequired[str]
40
- """API key of Azure OpenAI resource"""
41
- api_version: NotRequired[str]
42
-
43
-
44
- class OpenAIModelConfiguration(TypedDict):
45
- """Model configuration for OpenAI models
46
-
47
- :param type: The type of the model configuration. Should be 'openai' for OpenAIModelConfiguration
48
- :type type: NotRequired[Literal["openai"]]
49
- :param api_key: API key needed to make requests to model
50
- :type api_key: str
51
- :param model: Name of model to be used in OpenAI request
52
- :type model: str
53
- :param base_url: Base URL to be used in OpenAI request. Optional.
54
- :type base_url: NotRequired[str]
55
- :param organization: OpenAI organization. Optional.
56
- :type organization: NotRequired[str]
11
+ api_key: str
57
12
 
58
- .. admonition:: Example:
59
13
 
60
- .. literalinclude:: ../samples/evaluation_samples_common.py
61
- :start-after: [START create_OAI_model_config]
62
- :end-before: [END create_OAI_model_config]
63
- :language: python
64
- :dedent: 8
65
- :caption: Creating an OpenAIModelConfiguration object.
14
+ class AzureOpenAIModelConfiguration(AzureOpenAIModelConfigurationBase, total=False):
15
+ api_version: str
66
16
 
67
- """
68
17
 
69
- type: NotRequired[Literal["openai"]]
18
+ class OpenAIModelConfiguration(TypedDict):
70
19
  api_key: str
71
- model: str
72
- base_url: NotRequired[str]
73
- organization: NotRequired[str]
20
+ base_url: str
21
+ organization: str
74
22
 
75
23
 
76
24
  class AzureAIProject(TypedDict):
77
- """Information about the Azure AI project
78
-
79
- :param subscription_id: ID of the Azure subscription the project is in
80
- :type subscription_id: str
81
- :param resource_group_name: Name of the Azure resource group the project is in
82
- :type resource_group_name: str
83
- :param project_name: Name of the Azure project
84
- :type project_name: str
85
-
86
- .. admonition:: Example:
87
-
88
- .. literalinclude:: ../samples/evaluation_samples_common.py
89
- :start-after: [START create_azure_ai_project_object]
90
- :end-before: [END create_azure_ai_project_object]
91
- :language: python
92
- :dedent: 8
93
- :caption: Creating an AzureAIProject object.
94
-
95
- """
96
-
97
25
  subscription_id: str
98
26
  resource_group_name: str
99
27
  project_name: str
100
-
101
-
102
- class EvaluatorConfig(TypedDict, total=False):
103
- """Configuration for an evaluator"""
104
-
105
- column_mapping: Dict[str, str]
106
- """Dictionary mapping evaluator input name to column in data"""
107
-
108
-
109
- class Message(TypedDict):
110
- role: str
111
- content: Union[str, List[Dict]]
112
- context: NotRequired[Dict[str, Any]]
113
-
114
-
115
- class Conversation(TypedDict):
116
- messages: Union[List[Message], List[Dict]]
117
- context: NotRequired[Dict[str, Any]]
118
-
119
-
120
- class EvaluationResult(TypedDict):
121
- metrics: Dict
122
- studio_url: NotRequired[str]
123
- rows: List[Dict]
@@ -2,4 +2,4 @@
2
2
  # Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  # ---------------------------------------------------------
4
4
 
5
- VERSION = "1.0.0"
5
+ VERSION = "1.0.0b1"
@@ -1,14 +1,13 @@
1
- from ._adversarial_scenario import AdversarialScenario, AdversarialScenarioJailbreak
1
+ from ._adversarial_scenario import AdversarialScenario
2
2
  from ._adversarial_simulator import AdversarialSimulator
3
3
  from ._constants import SupportedLanguages
4
4
  from ._direct_attack_simulator import DirectAttackSimulator
5
5
  from ._indirect_attack_simulator import IndirectAttackSimulator
6
- from ._simulator import Simulator
6
+ from .simulator import Simulator
7
7
 
8
8
  __all__ = [
9
9
  "AdversarialSimulator",
10
10
  "AdversarialScenario",
11
- "AdversarialScenarioJailbreak",
12
11
  "DirectAttackSimulator",
13
12
  "IndirectAttackSimulator",
14
13
  "SupportedLanguages",
@@ -3,22 +3,10 @@
3
3
  # ---------------------------------------------------------
4
4
 
5
5
  from enum import Enum
6
- from azure.ai.evaluation._common._experimental import experimental
7
6
 
8
7
 
9
- @experimental
10
8
  class AdversarialScenario(Enum):
11
- """Adversarial scenario types
12
-
13
- .. admonition:: Example:
14
-
15
- .. literalinclude:: ../samples/evaluation_samples_simulate.py
16
- :start-after: [START adversarial_scenario]
17
- :end-before: [END adversarial_scenario]
18
- :language: python
19
- :dedent: 8
20
- :caption: Configure an AdversarialSimulator with an Adversarial Conversation scenario.
21
- """
9
+ """Adversarial scenario types"""
22
10
 
23
11
  ADVERSARIAL_QA = "adv_qa"
24
12
  ADVERSARIAL_CONVERSATION = "adv_conversation"
@@ -28,16 +16,9 @@ class AdversarialScenario(Enum):
28
16
  ADVERSARIAL_CONTENT_GEN_UNGROUNDED = "adv_content_gen_ungrounded"
29
17
  ADVERSARIAL_CONTENT_GEN_GROUNDED = "adv_content_gen_grounded"
30
18
  ADVERSARIAL_CONTENT_PROTECTED_MATERIAL = "adv_content_protected_material"
31
-
32
-
33
- @experimental
34
- class AdversarialScenarioJailbreak(Enum):
35
- """Adversarial scenario types for XPIA Jailbreak"""
36
-
37
19
  ADVERSARIAL_INDIRECT_JAILBREAK = "adv_xpia"
38
20
 
39
21
 
40
- @experimental
41
22
  class _UnstableAdversarialScenario(Enum):
42
23
  """Adversarial scenario types that we haven't published, but still want available for internal use
43
24
  Values listed here are subject to potential change, and/or migration to the main enum over time.