azure-ai-evaluation 1.0.0b3__py3-none-any.whl → 1.0.0b5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of azure-ai-evaluation might be problematic. Click here for more details.
- azure/ai/evaluation/__init__.py +23 -1
- azure/ai/evaluation/{simulator/_helpers → _common}/_experimental.py +20 -9
- azure/ai/evaluation/_common/constants.py +9 -2
- azure/ai/evaluation/_common/math.py +29 -0
- azure/ai/evaluation/_common/rai_service.py +222 -93
- azure/ai/evaluation/_common/utils.py +328 -19
- azure/ai/evaluation/_constants.py +16 -8
- azure/ai/evaluation/_evaluate/{_batch_run_client → _batch_run}/__init__.py +3 -2
- azure/ai/evaluation/_evaluate/{_batch_run_client → _batch_run}/code_client.py +33 -17
- azure/ai/evaluation/_evaluate/{_batch_run_client/batch_run_context.py → _batch_run/eval_run_context.py} +14 -7
- azure/ai/evaluation/_evaluate/{_batch_run_client → _batch_run}/proxy_client.py +22 -4
- azure/ai/evaluation/_evaluate/_batch_run/target_run_context.py +35 -0
- azure/ai/evaluation/_evaluate/_eval_run.py +47 -14
- azure/ai/evaluation/_evaluate/_evaluate.py +370 -188
- azure/ai/evaluation/_evaluate/_telemetry/__init__.py +15 -16
- azure/ai/evaluation/_evaluate/_utils.py +77 -25
- azure/ai/evaluation/_evaluators/_bleu/_bleu.py +1 -1
- azure/ai/evaluation/_evaluators/_coherence/_coherence.py +16 -10
- azure/ai/evaluation/_evaluators/_coherence/coherence.prompty +76 -34
- azure/ai/evaluation/_evaluators/_common/_base_eval.py +76 -46
- azure/ai/evaluation/_evaluators/_common/_base_prompty_eval.py +26 -19
- azure/ai/evaluation/_evaluators/_common/_base_rai_svc_eval.py +62 -25
- azure/ai/evaluation/_evaluators/_content_safety/_content_safety.py +68 -36
- azure/ai/evaluation/_evaluators/_content_safety/_content_safety_chat.py +67 -46
- azure/ai/evaluation/_evaluators/_content_safety/_hate_unfairness.py +33 -4
- azure/ai/evaluation/_evaluators/_content_safety/_self_harm.py +33 -4
- azure/ai/evaluation/_evaluators/_content_safety/_sexual.py +33 -4
- azure/ai/evaluation/_evaluators/_content_safety/_violence.py +33 -4
- azure/ai/evaluation/_evaluators/_eci/_eci.py +7 -5
- azure/ai/evaluation/_evaluators/_f1_score/_f1_score.py +14 -6
- azure/ai/evaluation/_evaluators/_fluency/_fluency.py +22 -21
- azure/ai/evaluation/_evaluators/_fluency/fluency.prompty +66 -36
- azure/ai/evaluation/_evaluators/_gleu/_gleu.py +1 -1
- azure/ai/evaluation/_evaluators/_groundedness/_groundedness.py +51 -16
- azure/ai/evaluation/_evaluators/_groundedness/groundedness_with_query.prompty +113 -0
- azure/ai/evaluation/_evaluators/_groundedness/groundedness_without_query.prompty +99 -0
- azure/ai/evaluation/_evaluators/_meteor/_meteor.py +3 -7
- azure/ai/evaluation/_evaluators/_multimodal/__init__.py +20 -0
- azure/ai/evaluation/_evaluators/_multimodal/_content_safety_multimodal.py +130 -0
- azure/ai/evaluation/_evaluators/_multimodal/_content_safety_multimodal_base.py +57 -0
- azure/ai/evaluation/_evaluators/_multimodal/_hate_unfairness.py +96 -0
- azure/ai/evaluation/_evaluators/_multimodal/_protected_material.py +120 -0
- azure/ai/evaluation/_evaluators/_multimodal/_self_harm.py +96 -0
- azure/ai/evaluation/_evaluators/_multimodal/_sexual.py +96 -0
- azure/ai/evaluation/_evaluators/_multimodal/_violence.py +96 -0
- azure/ai/evaluation/_evaluators/_protected_material/_protected_material.py +46 -13
- azure/ai/evaluation/_evaluators/_qa/_qa.py +11 -6
- azure/ai/evaluation/_evaluators/_relevance/_relevance.py +23 -20
- azure/ai/evaluation/_evaluators/_relevance/relevance.prompty +78 -42
- azure/ai/evaluation/_evaluators/_retrieval/_retrieval.py +126 -80
- azure/ai/evaluation/_evaluators/_retrieval/retrieval.prompty +74 -24
- azure/ai/evaluation/_evaluators/_rouge/_rouge.py +2 -2
- azure/ai/evaluation/_evaluators/_service_groundedness/__init__.py +9 -0
- azure/ai/evaluation/_evaluators/_service_groundedness/_service_groundedness.py +150 -0
- azure/ai/evaluation/_evaluators/_similarity/_similarity.py +32 -15
- azure/ai/evaluation/_evaluators/_xpia/xpia.py +36 -10
- azure/ai/evaluation/_exceptions.py +26 -6
- azure/ai/evaluation/_http_utils.py +203 -132
- azure/ai/evaluation/_model_configurations.py +23 -6
- azure/ai/evaluation/_vendor/__init__.py +3 -0
- azure/ai/evaluation/_vendor/rouge_score/__init__.py +14 -0
- azure/ai/evaluation/_vendor/rouge_score/rouge_scorer.py +328 -0
- azure/ai/evaluation/_vendor/rouge_score/scoring.py +63 -0
- azure/ai/evaluation/_vendor/rouge_score/tokenize.py +63 -0
- azure/ai/evaluation/_vendor/rouge_score/tokenizers.py +53 -0
- azure/ai/evaluation/_version.py +1 -1
- azure/ai/evaluation/simulator/__init__.py +2 -1
- azure/ai/evaluation/simulator/_adversarial_scenario.py +5 -0
- azure/ai/evaluation/simulator/_adversarial_simulator.py +88 -60
- azure/ai/evaluation/simulator/_conversation/__init__.py +13 -12
- azure/ai/evaluation/simulator/_conversation/_conversation.py +4 -4
- azure/ai/evaluation/simulator/_data_sources/__init__.py +3 -0
- azure/ai/evaluation/simulator/_data_sources/grounding.json +1150 -0
- azure/ai/evaluation/simulator/_direct_attack_simulator.py +24 -66
- azure/ai/evaluation/simulator/_helpers/__init__.py +1 -2
- azure/ai/evaluation/simulator/_helpers/_simulator_data_classes.py +26 -5
- azure/ai/evaluation/simulator/_indirect_attack_simulator.py +98 -95
- azure/ai/evaluation/simulator/_model_tools/_identity_manager.py +67 -21
- azure/ai/evaluation/simulator/_model_tools/_proxy_completion_model.py +28 -11
- azure/ai/evaluation/simulator/_model_tools/_template_handler.py +68 -24
- azure/ai/evaluation/simulator/_model_tools/models.py +10 -10
- azure/ai/evaluation/simulator/_prompty/task_query_response.prompty +4 -9
- azure/ai/evaluation/simulator/_prompty/task_simulate.prompty +6 -5
- azure/ai/evaluation/simulator/_simulator.py +222 -169
- azure/ai/evaluation/simulator/_tracing.py +4 -4
- azure/ai/evaluation/simulator/_utils.py +6 -6
- {azure_ai_evaluation-1.0.0b3.dist-info → azure_ai_evaluation-1.0.0b5.dist-info}/METADATA +237 -52
- azure_ai_evaluation-1.0.0b5.dist-info/NOTICE.txt +70 -0
- azure_ai_evaluation-1.0.0b5.dist-info/RECORD +120 -0
- {azure_ai_evaluation-1.0.0b3.dist-info → azure_ai_evaluation-1.0.0b5.dist-info}/WHEEL +1 -1
- azure/ai/evaluation/_evaluators/_groundedness/groundedness.prompty +0 -49
- azure_ai_evaluation-1.0.0b3.dist-info/RECORD +0 -98
- {azure_ai_evaluation-1.0.0b3.dist-info → azure_ai_evaluation-1.0.0b5.dist-info}/top_level.txt +0 -0
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
# ---------------------------------------------------------
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
from
|
|
7
|
-
from typing import Any, Awaitable, Callable, Dict, MutableMapping, Optional
|
|
6
|
+
from typing import Any, Dict, MutableMapping, Optional, TypedDict, cast
|
|
8
7
|
|
|
9
|
-
from typing_extensions import Self
|
|
8
|
+
from typing_extensions import Self, Unpack
|
|
10
9
|
|
|
11
10
|
from azure.ai.evaluation._user_agent import USER_AGENT
|
|
12
11
|
from azure.core.configuration import Configuration
|
|
@@ -33,78 +32,25 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest, HttpResponse
|
|
|
33
32
|
from azure.core.rest._rest_py3 import ContentType, FilesType, ParamsType
|
|
34
33
|
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
"""
|
|
35
|
+
class RequestKwargs(TypedDict, total=False):
|
|
36
|
+
"""Keyword arguments for request-style http request functions
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
The f.__name__ is the HTTP method used
|
|
41
|
-
:return: A wrapped callable that sends a `f.__name__` request
|
|
42
|
-
:rtype: Callable
|
|
43
|
-
"""
|
|
38
|
+
.. note::
|
|
44
39
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
)
|
|
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.
|
|
69
43
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
def _async_request_fn(f: Callable[["AsyncHttpPipeline"], Awaitable[None]]):
|
|
74
|
-
"""Decorator to generate convenience methods for HTTP method.
|
|
75
|
-
|
|
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
|
|
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.
|
|
80
46
|
"""
|
|
81
47
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
|
48
|
+
params: ParamsType
|
|
49
|
+
headers: MutableMapping[str, str]
|
|
50
|
+
json: Any
|
|
51
|
+
content: ContentType
|
|
52
|
+
data: Dict[str, Any]
|
|
53
|
+
files: FilesType
|
|
108
54
|
|
|
109
55
|
|
|
110
56
|
class HttpPipeline(Pipeline):
|
|
@@ -145,14 +91,32 @@ class HttpPipeline(Pipeline):
|
|
|
145
91
|
:param RedirectPolicy redirect_policy:
|
|
146
92
|
"""
|
|
147
93
|
config = config or Configuration()
|
|
148
|
-
config.headers_policy =
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
config.
|
|
152
|
-
config.
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
config.
|
|
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
|
+
)
|
|
156
120
|
config.polling_interval = kwargs.get("polling_interval", 30)
|
|
157
121
|
|
|
158
122
|
super().__init__(
|
|
@@ -166,7 +130,6 @@ class HttpPipeline(Pipeline):
|
|
|
166
130
|
config.proxy_policy,
|
|
167
131
|
config.redirect_policy,
|
|
168
132
|
config.retry_policy,
|
|
169
|
-
config.authentication_policy,
|
|
170
133
|
config.custom_hook_policy,
|
|
171
134
|
config.logging_policy,
|
|
172
135
|
],
|
|
@@ -199,7 +162,6 @@ class HttpPipeline(Pipeline):
|
|
|
199
162
|
files: Optional[FilesType] = None,
|
|
200
163
|
**kwargs,
|
|
201
164
|
) -> HttpResponse:
|
|
202
|
-
|
|
203
165
|
request = HttpRequest(
|
|
204
166
|
method,
|
|
205
167
|
url,
|
|
@@ -213,33 +175,78 @@ class HttpPipeline(Pipeline):
|
|
|
213
175
|
|
|
214
176
|
return self.run(request, **kwargs).http_response
|
|
215
177
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
"""Send a DELETE request."""
|
|
178
|
+
def delete(self: "HttpPipeline", url: str, **kwargs: Unpack[RequestKwargs]) -> HttpResponse:
|
|
179
|
+
"""Send a DELETE request.
|
|
219
180
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
181
|
+
:param str url: The request url
|
|
182
|
+
:returns: The request response
|
|
183
|
+
:rtype: HttpResponse
|
|
184
|
+
"""
|
|
223
185
|
|
|
224
|
-
|
|
225
|
-
def get(self) -> None:
|
|
226
|
-
"""Send a GET request."""
|
|
186
|
+
return self.request(self.delete.__name__.upper(), url, **kwargs)
|
|
227
187
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
"""Send a POST request."""
|
|
188
|
+
def put(self: "HttpPipeline", url: str, **kwargs: Unpack[RequestKwargs]) -> HttpResponse:
|
|
189
|
+
"""Send a PUT request.
|
|
231
190
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
191
|
+
:param str url: The request url
|
|
192
|
+
:returns: The request response
|
|
193
|
+
:rtype: HttpResponse
|
|
194
|
+
"""
|
|
235
195
|
|
|
236
|
-
|
|
237
|
-
def options(self) -> None:
|
|
238
|
-
"""Send a OPTIONS request."""
|
|
196
|
+
return self.request(self.put.__name__.upper(), url, **kwargs)
|
|
239
197
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
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
|
+
"""
|
|
215
|
+
|
|
216
|
+
return self.request(self.post.__name__.upper(), url, **kwargs)
|
|
217
|
+
|
|
218
|
+
def head(self: "HttpPipeline", url: str, **kwargs: Unpack[RequestKwargs]) -> HttpResponse:
|
|
219
|
+
"""Send a HEAD request.
|
|
220
|
+
|
|
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)
|
|
227
|
+
|
|
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
|
+
"""
|
|
235
|
+
|
|
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__())
|
|
243
250
|
|
|
244
251
|
|
|
245
252
|
class AsyncHttpPipeline(AsyncPipeline):
|
|
@@ -280,14 +287,36 @@ class AsyncHttpPipeline(AsyncPipeline):
|
|
|
280
287
|
:param AsyncRedirectPolicy redirect_policy:
|
|
281
288
|
"""
|
|
282
289
|
config = config or Configuration()
|
|
283
|
-
config.headers_policy =
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
config.
|
|
287
|
-
config.
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
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
|
+
)
|
|
291
320
|
config.polling_interval = kwargs.get("polling_interval", 30)
|
|
292
321
|
|
|
293
322
|
super().__init__(
|
|
@@ -301,7 +330,6 @@ class AsyncHttpPipeline(AsyncPipeline):
|
|
|
301
330
|
config.proxy_policy,
|
|
302
331
|
config.redirect_policy,
|
|
303
332
|
config.retry_policy,
|
|
304
|
-
config.authentication_policy,
|
|
305
333
|
config.custom_hook_policy,
|
|
306
334
|
config.logging_policy,
|
|
307
335
|
],
|
|
@@ -334,7 +362,6 @@ class AsyncHttpPipeline(AsyncPipeline):
|
|
|
334
362
|
files: Optional[FilesType] = None,
|
|
335
363
|
**kwargs,
|
|
336
364
|
) -> AsyncHttpResponse:
|
|
337
|
-
|
|
338
365
|
request = HttpRequest(
|
|
339
366
|
method,
|
|
340
367
|
url,
|
|
@@ -348,33 +375,77 @@ class AsyncHttpPipeline(AsyncPipeline):
|
|
|
348
375
|
|
|
349
376
|
return (await self.run(request, **kwargs)).http_response
|
|
350
377
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
378
|
+
async def delete(self: "AsyncHttpPipeline", url: str, **kwargs: Unpack[RequestKwargs]) -> AsyncHttpResponse:
|
|
379
|
+
"""Send a DELETE request.
|
|
380
|
+
|
|
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.
|
|
389
|
+
|
|
390
|
+
:param str url: The request url
|
|
391
|
+
:returns: The request response
|
|
392
|
+
:rtype: AsyncHttpResponse
|
|
393
|
+
"""
|
|
394
|
+
|
|
395
|
+
return await self.request(self.put.__name__.upper(), url, **kwargs)
|
|
396
|
+
|
|
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.
|
|
354
419
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
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.
|
|
358
429
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
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)
|
|
362
436
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
"""Send a POST request."""
|
|
437
|
+
async def patch(self: "AsyncHttpPipeline", url: str, **kwargs: Unpack[RequestKwargs]) -> AsyncHttpResponse:
|
|
438
|
+
"""Send a PATCH request.
|
|
366
439
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
440
|
+
:param str url: The request url
|
|
441
|
+
:returns: The request response
|
|
442
|
+
:rtype: AsyncHttpResponse
|
|
443
|
+
"""
|
|
370
444
|
|
|
371
|
-
|
|
372
|
-
async def options(self) -> None:
|
|
373
|
-
"""Send a OPTIONS request."""
|
|
445
|
+
return await self.request(self.patch.__name__.upper(), url, **kwargs)
|
|
374
446
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
"""Send a PATCH request."""
|
|
447
|
+
async def __aenter__(self) -> Self:
|
|
448
|
+
return cast(Self, await super().__aenter__())
|
|
378
449
|
|
|
379
450
|
|
|
380
451
|
def get_http_client() -> HttpPipeline:
|
|
@@ -2,30 +2,30 @@
|
|
|
2
2
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
3
|
# ---------------------------------------------------------
|
|
4
4
|
|
|
5
|
-
from typing import Dict, Literal, TypedDict
|
|
5
|
+
from typing import Any, Dict, List, Literal, TypedDict, Union
|
|
6
6
|
|
|
7
7
|
from typing_extensions import NotRequired
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
class AzureOpenAIModelConfiguration(TypedDict
|
|
10
|
+
class AzureOpenAIModelConfiguration(TypedDict):
|
|
11
11
|
"""Model Configuration for Azure OpenAI Model"""
|
|
12
12
|
|
|
13
|
-
type: Literal["azure_openai"]
|
|
13
|
+
type: NotRequired[Literal["azure_openai"]]
|
|
14
14
|
"""The type of the model configuration. Should be 'azure_openai' for AzureOpenAIModelConfiguration"""
|
|
15
15
|
azure_deployment: str
|
|
16
16
|
"""Name of Azure OpenAI deployment to make request to"""
|
|
17
17
|
azure_endpoint: str
|
|
18
18
|
"""Endpoint of Azure OpenAI resource to make request to"""
|
|
19
|
-
api_key: str
|
|
19
|
+
api_key: NotRequired[str]
|
|
20
20
|
"""API key of Azure OpenAI resource"""
|
|
21
21
|
api_version: NotRequired[str]
|
|
22
22
|
"""(Optional) API version to use in request to Azure OpenAI deployment"""
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
class OpenAIModelConfiguration(TypedDict
|
|
25
|
+
class OpenAIModelConfiguration(TypedDict):
|
|
26
26
|
"""Model Configuration for OpenAI Model"""
|
|
27
27
|
|
|
28
|
-
type: Literal["openai"]
|
|
28
|
+
type: NotRequired[Literal["openai"]]
|
|
29
29
|
"""The type of the model configuration. Should be 'openai' for OpenAIModelConfiguration"""
|
|
30
30
|
api_key: str
|
|
31
31
|
"API key needed to make request to model"
|
|
@@ -53,3 +53,20 @@ class EvaluatorConfig(TypedDict, total=False):
|
|
|
53
53
|
|
|
54
54
|
column_mapping: Dict[str, str]
|
|
55
55
|
"""Dictionary mapping evaluator input name to column in data"""
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class Message(TypedDict):
|
|
59
|
+
role: str
|
|
60
|
+
content: Union[str, List[Dict]]
|
|
61
|
+
context: NotRequired[Dict[str, Any]]
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class Conversation(TypedDict):
|
|
65
|
+
messages: Union[List[Message], List[Dict]]
|
|
66
|
+
context: NotRequired[Dict[str, Any]]
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class EvaluationResult(TypedDict):
|
|
70
|
+
metrics: Dict
|
|
71
|
+
studio_url: NotRequired[str]
|
|
72
|
+
rows: List[Dict]
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
# Copyright 2024 The Google Research Authors.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|