azure-ai-evaluation 1.8.0__py3-none-any.whl → 1.10.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.
- azure/ai/evaluation/__init__.py +51 -6
- azure/ai/evaluation/_aoai/__init__.py +1 -1
- azure/ai/evaluation/_aoai/aoai_grader.py +21 -11
- azure/ai/evaluation/_aoai/label_grader.py +3 -2
- azure/ai/evaluation/_aoai/python_grader.py +84 -0
- azure/ai/evaluation/_aoai/score_model_grader.py +91 -0
- azure/ai/evaluation/_aoai/string_check_grader.py +3 -2
- azure/ai/evaluation/_aoai/text_similarity_grader.py +3 -2
- azure/ai/evaluation/_azure/_envs.py +9 -10
- azure/ai/evaluation/_azure/_token_manager.py +7 -1
- azure/ai/evaluation/_common/constants.py +11 -2
- azure/ai/evaluation/_common/evaluation_onedp_client.py +32 -26
- azure/ai/evaluation/_common/onedp/__init__.py +32 -32
- azure/ai/evaluation/_common/onedp/_client.py +136 -139
- azure/ai/evaluation/_common/onedp/_configuration.py +70 -73
- azure/ai/evaluation/_common/onedp/_patch.py +21 -21
- azure/ai/evaluation/_common/onedp/_utils/__init__.py +6 -0
- azure/ai/evaluation/_common/onedp/_utils/model_base.py +1232 -0
- azure/ai/evaluation/_common/onedp/_utils/serialization.py +2032 -0
- azure/ai/evaluation/_common/onedp/_validation.py +50 -50
- azure/ai/evaluation/_common/onedp/_version.py +9 -9
- azure/ai/evaluation/_common/onedp/aio/__init__.py +29 -29
- azure/ai/evaluation/_common/onedp/aio/_client.py +138 -143
- azure/ai/evaluation/_common/onedp/aio/_configuration.py +70 -75
- azure/ai/evaluation/_common/onedp/aio/_patch.py +21 -21
- azure/ai/evaluation/_common/onedp/aio/operations/__init__.py +37 -39
- azure/ai/evaluation/_common/onedp/aio/operations/_operations.py +4832 -4494
- azure/ai/evaluation/_common/onedp/aio/operations/_patch.py +21 -21
- azure/ai/evaluation/_common/onedp/models/__init__.py +168 -142
- azure/ai/evaluation/_common/onedp/models/_enums.py +230 -162
- azure/ai/evaluation/_common/onedp/models/_models.py +2685 -2228
- azure/ai/evaluation/_common/onedp/models/_patch.py +21 -21
- azure/ai/evaluation/_common/onedp/operations/__init__.py +37 -39
- azure/ai/evaluation/_common/onedp/operations/_operations.py +6106 -5657
- azure/ai/evaluation/_common/onedp/operations/_patch.py +21 -21
- azure/ai/evaluation/_common/rai_service.py +88 -52
- azure/ai/evaluation/_common/raiclient/__init__.py +1 -1
- azure/ai/evaluation/_common/raiclient/operations/_operations.py +14 -1
- azure/ai/evaluation/_common/utils.py +188 -10
- azure/ai/evaluation/_constants.py +2 -1
- azure/ai/evaluation/_converters/__init__.py +1 -1
- azure/ai/evaluation/_converters/_ai_services.py +9 -8
- azure/ai/evaluation/_converters/_models.py +46 -0
- azure/ai/evaluation/_converters/_sk_services.py +495 -0
- azure/ai/evaluation/_eval_mapping.py +2 -2
- azure/ai/evaluation/_evaluate/_batch_run/_run_submitter_client.py +73 -25
- azure/ai/evaluation/_evaluate/_batch_run/eval_run_context.py +2 -2
- azure/ai/evaluation/_evaluate/_evaluate.py +210 -94
- azure/ai/evaluation/_evaluate/_evaluate_aoai.py +132 -89
- azure/ai/evaluation/_evaluate/_telemetry/__init__.py +0 -1
- azure/ai/evaluation/_evaluate/_utils.py +25 -17
- azure/ai/evaluation/_evaluators/_bleu/_bleu.py +4 -4
- azure/ai/evaluation/_evaluators/_code_vulnerability/_code_vulnerability.py +20 -12
- azure/ai/evaluation/_evaluators/_coherence/_coherence.py +6 -6
- azure/ai/evaluation/_evaluators/_common/_base_eval.py +45 -11
- azure/ai/evaluation/_evaluators/_common/_base_prompty_eval.py +24 -9
- azure/ai/evaluation/_evaluators/_common/_base_rai_svc_eval.py +24 -9
- azure/ai/evaluation/_evaluators/_content_safety/_content_safety.py +28 -18
- azure/ai/evaluation/_evaluators/_content_safety/_hate_unfairness.py +11 -8
- azure/ai/evaluation/_evaluators/_content_safety/_self_harm.py +11 -8
- azure/ai/evaluation/_evaluators/_content_safety/_sexual.py +12 -9
- azure/ai/evaluation/_evaluators/_content_safety/_violence.py +10 -7
- azure/ai/evaluation/_evaluators/_document_retrieval/__init__.py +1 -5
- azure/ai/evaluation/_evaluators/_document_retrieval/_document_retrieval.py +37 -64
- azure/ai/evaluation/_evaluators/_eci/_eci.py +6 -3
- azure/ai/evaluation/_evaluators/_f1_score/_f1_score.py +5 -5
- azure/ai/evaluation/_evaluators/_fluency/_fluency.py +3 -3
- azure/ai/evaluation/_evaluators/_gleu/_gleu.py +4 -4
- azure/ai/evaluation/_evaluators/_groundedness/_groundedness.py +12 -8
- azure/ai/evaluation/_evaluators/_intent_resolution/_intent_resolution.py +31 -26
- azure/ai/evaluation/_evaluators/_intent_resolution/intent_resolution.prompty +210 -96
- azure/ai/evaluation/_evaluators/_meteor/_meteor.py +3 -4
- azure/ai/evaluation/_evaluators/_protected_material/_protected_material.py +14 -7
- azure/ai/evaluation/_evaluators/_qa/_qa.py +5 -5
- azure/ai/evaluation/_evaluators/_relevance/_relevance.py +62 -15
- azure/ai/evaluation/_evaluators/_relevance/relevance.prompty +140 -59
- azure/ai/evaluation/_evaluators/_response_completeness/_response_completeness.py +21 -26
- azure/ai/evaluation/_evaluators/_retrieval/_retrieval.py +5 -5
- azure/ai/evaluation/_evaluators/_rouge/_rouge.py +22 -22
- azure/ai/evaluation/_evaluators/_service_groundedness/_service_groundedness.py +7 -6
- azure/ai/evaluation/_evaluators/_similarity/_similarity.py +4 -4
- azure/ai/evaluation/_evaluators/_task_adherence/_task_adherence.py +27 -24
- azure/ai/evaluation/_evaluators/_task_adherence/task_adherence.prompty +354 -66
- azure/ai/evaluation/_evaluators/_tool_call_accuracy/_tool_call_accuracy.py +175 -183
- azure/ai/evaluation/_evaluators/_tool_call_accuracy/tool_call_accuracy.prompty +99 -21
- azure/ai/evaluation/_evaluators/_ungrounded_attributes/_ungrounded_attributes.py +20 -12
- azure/ai/evaluation/_evaluators/_xpia/xpia.py +10 -7
- azure/ai/evaluation/_exceptions.py +10 -0
- azure/ai/evaluation/_http_utils.py +3 -3
- azure/ai/evaluation/_legacy/_batch_engine/_config.py +6 -3
- azure/ai/evaluation/_legacy/_batch_engine/_engine.py +117 -32
- azure/ai/evaluation/_legacy/_batch_engine/_openai_injector.py +5 -2
- azure/ai/evaluation/_legacy/_batch_engine/_result.py +2 -0
- azure/ai/evaluation/_legacy/_batch_engine/_run.py +2 -2
- azure/ai/evaluation/_legacy/_batch_engine/_run_submitter.py +33 -41
- azure/ai/evaluation/_legacy/_batch_engine/_utils.py +1 -4
- azure/ai/evaluation/_legacy/_common/_async_token_provider.py +12 -19
- azure/ai/evaluation/_legacy/_common/_thread_pool_executor_with_context.py +2 -0
- azure/ai/evaluation/_legacy/prompty/_prompty.py +11 -5
- azure/ai/evaluation/_safety_evaluation/__init__.py +1 -1
- azure/ai/evaluation/_safety_evaluation/_safety_evaluation.py +195 -111
- azure/ai/evaluation/_user_agent.py +32 -1
- azure/ai/evaluation/_version.py +1 -1
- azure/ai/evaluation/red_team/__init__.py +3 -1
- azure/ai/evaluation/red_team/_agent/__init__.py +1 -1
- azure/ai/evaluation/red_team/_agent/_agent_functions.py +68 -71
- azure/ai/evaluation/red_team/_agent/_agent_tools.py +103 -145
- azure/ai/evaluation/red_team/_agent/_agent_utils.py +26 -6
- azure/ai/evaluation/red_team/_agent/_semantic_kernel_plugin.py +62 -71
- azure/ai/evaluation/red_team/_attack_objective_generator.py +94 -52
- azure/ai/evaluation/red_team/_attack_strategy.py +2 -1
- azure/ai/evaluation/red_team/_callback_chat_target.py +4 -9
- azure/ai/evaluation/red_team/_default_converter.py +1 -1
- azure/ai/evaluation/red_team/_red_team.py +1947 -1040
- azure/ai/evaluation/red_team/_red_team_result.py +49 -38
- azure/ai/evaluation/red_team/_utils/__init__.py +1 -1
- azure/ai/evaluation/red_team/_utils/_rai_service_eval_chat_target.py +39 -34
- azure/ai/evaluation/red_team/_utils/_rai_service_target.py +163 -138
- azure/ai/evaluation/red_team/_utils/_rai_service_true_false_scorer.py +14 -14
- azure/ai/evaluation/red_team/_utils/constants.py +1 -13
- azure/ai/evaluation/red_team/_utils/formatting_utils.py +41 -44
- azure/ai/evaluation/red_team/_utils/logging_utils.py +17 -17
- azure/ai/evaluation/red_team/_utils/metric_mapping.py +31 -4
- azure/ai/evaluation/red_team/_utils/strategy_utils.py +33 -25
- azure/ai/evaluation/simulator/_adversarial_scenario.py +2 -0
- azure/ai/evaluation/simulator/_adversarial_simulator.py +31 -17
- azure/ai/evaluation/simulator/_conversation/__init__.py +2 -2
- azure/ai/evaluation/simulator/_direct_attack_simulator.py +8 -8
- azure/ai/evaluation/simulator/_indirect_attack_simulator.py +18 -6
- azure/ai/evaluation/simulator/_model_tools/_generated_rai_client.py +54 -24
- azure/ai/evaluation/simulator/_model_tools/_identity_manager.py +7 -1
- azure/ai/evaluation/simulator/_model_tools/_proxy_completion_model.py +30 -10
- azure/ai/evaluation/simulator/_model_tools/_rai_client.py +19 -31
- azure/ai/evaluation/simulator/_model_tools/_template_handler.py +20 -6
- azure/ai/evaluation/simulator/_model_tools/models.py +1 -1
- azure/ai/evaluation/simulator/_simulator.py +21 -8
- {azure_ai_evaluation-1.8.0.dist-info → azure_ai_evaluation-1.10.0.dist-info}/METADATA +46 -3
- {azure_ai_evaluation-1.8.0.dist-info → azure_ai_evaluation-1.10.0.dist-info}/RECORD +141 -136
- azure/ai/evaluation/_common/onedp/aio/_vendor.py +0 -40
- {azure_ai_evaluation-1.8.0.dist-info → azure_ai_evaluation-1.10.0.dist-info}/NOTICE.txt +0 -0
- {azure_ai_evaluation-1.8.0.dist-info → azure_ai_evaluation-1.10.0.dist-info}/WHEEL +0 -0
- {azure_ai_evaluation-1.8.0.dist-info → azure_ai_evaluation-1.10.0.dist-info}/top_level.txt +0 -0
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
# --------------------------------------------------------------------------
|
|
2
|
-
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
# Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
-
# Code generated by Microsoft (R) Python Code Generator.
|
|
5
|
-
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
6
|
-
# --------------------------------------------------------------------------
|
|
7
|
-
import functools
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def api_version_validation(**kwargs):
|
|
11
|
-
params_added_on = kwargs.pop("params_added_on", {})
|
|
12
|
-
method_added_on = kwargs.pop("method_added_on", "")
|
|
13
|
-
|
|
14
|
-
def decorator(func):
|
|
15
|
-
@functools.wraps(func)
|
|
16
|
-
def wrapper(*args, **kwargs):
|
|
17
|
-
try:
|
|
18
|
-
# this assumes the client has an _api_version attribute
|
|
19
|
-
client = args[0]
|
|
20
|
-
client_api_version = client._config.api_version # pylint: disable=protected-access
|
|
21
|
-
except AttributeError:
|
|
22
|
-
return func(*args, **kwargs)
|
|
23
|
-
|
|
24
|
-
if method_added_on > client_api_version:
|
|
25
|
-
raise ValueError(
|
|
26
|
-
f"'{func.__name__}' is not available in API version "
|
|
27
|
-
f"{client_api_version}. Pass service API version {method_added_on} or newer to your client."
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
unsupported = {
|
|
31
|
-
parameter: api_version
|
|
32
|
-
for api_version, parameters in params_added_on.items()
|
|
33
|
-
for parameter in parameters
|
|
34
|
-
if parameter in kwargs and api_version > client_api_version
|
|
35
|
-
}
|
|
36
|
-
if unsupported:
|
|
37
|
-
raise ValueError(
|
|
38
|
-
"".join(
|
|
39
|
-
[
|
|
40
|
-
f"'{param}' is not available in API version {client_api_version}. "
|
|
41
|
-
f"Use service API version {version} or newer.\n"
|
|
42
|
-
for param, version in unsupported.items()
|
|
43
|
-
]
|
|
44
|
-
)
|
|
45
|
-
)
|
|
46
|
-
return func(*args, **kwargs)
|
|
47
|
-
|
|
48
|
-
return wrapper
|
|
49
|
-
|
|
50
|
-
return decorator
|
|
1
|
+
# --------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
# Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
# Code generated by Microsoft (R) Python Code Generator.
|
|
5
|
+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
6
|
+
# --------------------------------------------------------------------------
|
|
7
|
+
import functools
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def api_version_validation(**kwargs):
|
|
11
|
+
params_added_on = kwargs.pop("params_added_on", {})
|
|
12
|
+
method_added_on = kwargs.pop("method_added_on", "")
|
|
13
|
+
|
|
14
|
+
def decorator(func):
|
|
15
|
+
@functools.wraps(func)
|
|
16
|
+
def wrapper(*args, **kwargs):
|
|
17
|
+
try:
|
|
18
|
+
# this assumes the client has an _api_version attribute
|
|
19
|
+
client = args[0]
|
|
20
|
+
client_api_version = client._config.api_version # pylint: disable=protected-access
|
|
21
|
+
except AttributeError:
|
|
22
|
+
return func(*args, **kwargs)
|
|
23
|
+
|
|
24
|
+
if method_added_on > client_api_version:
|
|
25
|
+
raise ValueError(
|
|
26
|
+
f"'{func.__name__}' is not available in API version "
|
|
27
|
+
f"{client_api_version}. Pass service API version {method_added_on} or newer to your client."
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
unsupported = {
|
|
31
|
+
parameter: api_version
|
|
32
|
+
for api_version, parameters in params_added_on.items()
|
|
33
|
+
for parameter in parameters
|
|
34
|
+
if parameter in kwargs and api_version > client_api_version
|
|
35
|
+
}
|
|
36
|
+
if unsupported:
|
|
37
|
+
raise ValueError(
|
|
38
|
+
"".join(
|
|
39
|
+
[
|
|
40
|
+
f"'{param}' is not available in API version {client_api_version}. "
|
|
41
|
+
f"Use service API version {version} or newer.\n"
|
|
42
|
+
for param, version in unsupported.items()
|
|
43
|
+
]
|
|
44
|
+
)
|
|
45
|
+
)
|
|
46
|
+
return func(*args, **kwargs)
|
|
47
|
+
|
|
48
|
+
return wrapper
|
|
49
|
+
|
|
50
|
+
return decorator
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# coding=utf-8
|
|
2
|
-
# --------------------------------------------------------------------------
|
|
3
|
-
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
-
# Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
-
# Code generated by Microsoft (R) Python Code Generator.
|
|
6
|
-
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
7
|
-
# --------------------------------------------------------------------------
|
|
8
|
-
|
|
9
|
-
VERSION = "1.0.0b1"
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
# --------------------------------------------------------------------------
|
|
3
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
# Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
# Code generated by Microsoft (R) Python Code Generator.
|
|
6
|
+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
7
|
+
# --------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
VERSION = "1.0.0b1"
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
# coding=utf-8
|
|
2
|
-
# --------------------------------------------------------------------------
|
|
3
|
-
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
-
# Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
-
# Code generated by Microsoft (R) Python Code Generator.
|
|
6
|
-
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
7
|
-
# --------------------------------------------------------------------------
|
|
8
|
-
# pylint: disable=wrong-import-position
|
|
9
|
-
|
|
10
|
-
from typing import TYPE_CHECKING
|
|
11
|
-
|
|
12
|
-
if TYPE_CHECKING:
|
|
13
|
-
from ._patch import * # pylint: disable=unused-wildcard-import
|
|
14
|
-
|
|
15
|
-
from ._client import AIProjectClient # type: ignore
|
|
16
|
-
|
|
17
|
-
try:
|
|
18
|
-
from ._patch import __all__ as _patch_all
|
|
19
|
-
from ._patch import *
|
|
20
|
-
except ImportError:
|
|
21
|
-
_patch_all = []
|
|
22
|
-
from ._patch import patch_sdk as _patch_sdk
|
|
23
|
-
|
|
24
|
-
__all__ = [
|
|
25
|
-
"AIProjectClient",
|
|
26
|
-
]
|
|
27
|
-
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
|
|
28
|
-
|
|
29
|
-
_patch_sdk()
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
# --------------------------------------------------------------------------
|
|
3
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
# Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
# Code generated by Microsoft (R) Python Code Generator.
|
|
6
|
+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
7
|
+
# --------------------------------------------------------------------------
|
|
8
|
+
# pylint: disable=wrong-import-position
|
|
9
|
+
|
|
10
|
+
from typing import TYPE_CHECKING
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from ._patch import * # pylint: disable=unused-wildcard-import
|
|
14
|
+
|
|
15
|
+
from ._client import AIProjectClient # type: ignore
|
|
16
|
+
|
|
17
|
+
try:
|
|
18
|
+
from ._patch import __all__ as _patch_all
|
|
19
|
+
from ._patch import *
|
|
20
|
+
except ImportError:
|
|
21
|
+
_patch_all = []
|
|
22
|
+
from ._patch import patch_sdk as _patch_sdk
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
"AIProjectClient",
|
|
26
|
+
]
|
|
27
|
+
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
|
|
28
|
+
|
|
29
|
+
_patch_sdk()
|
|
@@ -1,143 +1,138 @@
|
|
|
1
|
-
# coding=utf-8
|
|
2
|
-
# --------------------------------------------------------------------------
|
|
3
|
-
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
-
# Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
-
# Code generated by Microsoft (R) Python Code Generator.
|
|
6
|
-
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
7
|
-
# --------------------------------------------------------------------------
|
|
8
|
-
|
|
9
|
-
from copy import deepcopy
|
|
10
|
-
from typing import Any, Awaitable, TYPE_CHECKING
|
|
11
|
-
from typing_extensions import Self
|
|
12
|
-
|
|
13
|
-
from azure.core import AsyncPipelineClient
|
|
14
|
-
from azure.core.
|
|
15
|
-
from azure.core.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
from
|
|
19
|
-
from .
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
:ivar
|
|
39
|
-
:vartype
|
|
40
|
-
:ivar
|
|
41
|
-
:vartype
|
|
42
|
-
:ivar
|
|
43
|
-
:vartype
|
|
44
|
-
:ivar
|
|
45
|
-
:vartype
|
|
46
|
-
:ivar
|
|
47
|
-
:vartype
|
|
48
|
-
:ivar
|
|
49
|
-
:vartype
|
|
50
|
-
:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
:
|
|
58
|
-
|
|
59
|
-
:type credential: ~azure.core.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
self
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
self._config.
|
|
77
|
-
|
|
78
|
-
self._config.
|
|
79
|
-
|
|
80
|
-
self._config.
|
|
81
|
-
self._config.
|
|
82
|
-
self._config.
|
|
83
|
-
|
|
84
|
-
self._config.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
self.
|
|
90
|
-
|
|
91
|
-
self._serialize =
|
|
92
|
-
self.
|
|
93
|
-
self.
|
|
94
|
-
self.
|
|
95
|
-
|
|
96
|
-
)
|
|
97
|
-
self.
|
|
98
|
-
self.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
self
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
request_copy =
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
await self._client.__aenter__()
|
|
140
|
-
return self
|
|
141
|
-
|
|
142
|
-
async def __aexit__(self, *exc_details: Any) -> None:
|
|
143
|
-
await self._client.__aexit__(*exc_details)
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
# --------------------------------------------------------------------------
|
|
3
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
# Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
# Code generated by Microsoft (R) Python Code Generator.
|
|
6
|
+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
7
|
+
# --------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
from copy import deepcopy
|
|
10
|
+
from typing import Any, Awaitable, TYPE_CHECKING
|
|
11
|
+
from typing_extensions import Self
|
|
12
|
+
|
|
13
|
+
from azure.core import AsyncPipelineClient
|
|
14
|
+
from azure.core.pipeline import policies
|
|
15
|
+
from azure.core.rest import AsyncHttpResponse, HttpRequest
|
|
16
|
+
|
|
17
|
+
from .._utils.serialization import Deserializer, Serializer
|
|
18
|
+
from ._configuration import AIProjectClientConfiguration
|
|
19
|
+
from .operations import (
|
|
20
|
+
ConnectionsOperations,
|
|
21
|
+
DatasetsOperations,
|
|
22
|
+
DeploymentsOperations,
|
|
23
|
+
EvaluationResultsOperations,
|
|
24
|
+
EvaluationsOperations,
|
|
25
|
+
IndexesOperations,
|
|
26
|
+
RedTeamsOperations,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
if TYPE_CHECKING:
|
|
30
|
+
from azure.core.credentials_async import AsyncTokenCredential
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class AIProjectClient: # pylint: disable=too-many-instance-attributes
|
|
34
|
+
"""AIProjectClient.
|
|
35
|
+
|
|
36
|
+
:ivar connections: ConnectionsOperations operations
|
|
37
|
+
:vartype connections: azure.ai.projects.onedp.aio.operations.ConnectionsOperations
|
|
38
|
+
:ivar evaluations: EvaluationsOperations operations
|
|
39
|
+
:vartype evaluations: azure.ai.projects.onedp.aio.operations.EvaluationsOperations
|
|
40
|
+
:ivar datasets: DatasetsOperations operations
|
|
41
|
+
:vartype datasets: azure.ai.projects.onedp.aio.operations.DatasetsOperations
|
|
42
|
+
:ivar indexes: IndexesOperations operations
|
|
43
|
+
:vartype indexes: azure.ai.projects.onedp.aio.operations.IndexesOperations
|
|
44
|
+
:ivar deployments: DeploymentsOperations operations
|
|
45
|
+
:vartype deployments: azure.ai.projects.onedp.aio.operations.DeploymentsOperations
|
|
46
|
+
:ivar red_teams: RedTeamsOperations operations
|
|
47
|
+
:vartype red_teams: azure.ai.projects.onedp.aio.operations.RedTeamsOperations
|
|
48
|
+
:ivar evaluation_results: EvaluationResultsOperations operations
|
|
49
|
+
:vartype evaluation_results: azure.ai.projects.onedp.aio.operations.EvaluationResultsOperations
|
|
50
|
+
:param endpoint: Project endpoint. In the form
|
|
51
|
+
"https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/_project"
|
|
52
|
+
if your Foundry Hub has only one Project, or to use the default Project in your Hub. Or in the
|
|
53
|
+
form
|
|
54
|
+
"https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/<your-project-name>"
|
|
55
|
+
if you want to explicitly
|
|
56
|
+
specify the Foundry Project name. Required.
|
|
57
|
+
:type endpoint: str
|
|
58
|
+
:param credential: Credential used to authenticate requests to the service. Required.
|
|
59
|
+
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
|
|
60
|
+
:keyword api_version: The API version to use for this operation. Default value is
|
|
61
|
+
"2025-05-15-preview". Note that overriding this default value may result in unsupported
|
|
62
|
+
behavior.
|
|
63
|
+
:paramtype api_version: str
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: Any) -> None:
|
|
67
|
+
_endpoint = "{endpoint}"
|
|
68
|
+
self._config = AIProjectClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
|
|
69
|
+
|
|
70
|
+
_policies = kwargs.pop("policies", None)
|
|
71
|
+
if _policies is None:
|
|
72
|
+
_policies = [
|
|
73
|
+
policies.RequestIdPolicy(**kwargs),
|
|
74
|
+
self._config.headers_policy,
|
|
75
|
+
self._config.user_agent_policy,
|
|
76
|
+
self._config.proxy_policy,
|
|
77
|
+
policies.ContentDecodePolicy(**kwargs),
|
|
78
|
+
self._config.redirect_policy,
|
|
79
|
+
self._config.retry_policy,
|
|
80
|
+
self._config.authentication_policy,
|
|
81
|
+
self._config.custom_hook_policy,
|
|
82
|
+
self._config.logging_policy,
|
|
83
|
+
policies.DistributedTracingPolicy(**kwargs),
|
|
84
|
+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
|
|
85
|
+
self._config.http_logging_policy,
|
|
86
|
+
]
|
|
87
|
+
self._client: AsyncPipelineClient = AsyncPipelineClient(base_url=_endpoint, policies=_policies, **kwargs)
|
|
88
|
+
|
|
89
|
+
self._serialize = Serializer()
|
|
90
|
+
self._deserialize = Deserializer()
|
|
91
|
+
self._serialize.client_side_validation = False
|
|
92
|
+
self.connections = ConnectionsOperations(self._client, self._config, self._serialize, self._deserialize)
|
|
93
|
+
self.evaluations = EvaluationsOperations(self._client, self._config, self._serialize, self._deserialize)
|
|
94
|
+
self.datasets = DatasetsOperations(self._client, self._config, self._serialize, self._deserialize)
|
|
95
|
+
self.indexes = IndexesOperations(self._client, self._config, self._serialize, self._deserialize)
|
|
96
|
+
self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize)
|
|
97
|
+
self.red_teams = RedTeamsOperations(self._client, self._config, self._serialize, self._deserialize)
|
|
98
|
+
self.evaluation_results = EvaluationResultsOperations(
|
|
99
|
+
self._client, self._config, self._serialize, self._deserialize
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
def send_request(
|
|
103
|
+
self, request: HttpRequest, *, stream: bool = False, **kwargs: Any
|
|
104
|
+
) -> Awaitable[AsyncHttpResponse]:
|
|
105
|
+
"""Runs the network request through the client's chained policies.
|
|
106
|
+
|
|
107
|
+
>>> from azure.core.rest import HttpRequest
|
|
108
|
+
>>> request = HttpRequest("GET", "https://www.example.org/")
|
|
109
|
+
<HttpRequest [GET], url: 'https://www.example.org/'>
|
|
110
|
+
>>> response = await client.send_request(request)
|
|
111
|
+
<AsyncHttpResponse: 200 OK>
|
|
112
|
+
|
|
113
|
+
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
|
|
114
|
+
|
|
115
|
+
:param request: The network request you want to make. Required.
|
|
116
|
+
:type request: ~azure.core.rest.HttpRequest
|
|
117
|
+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
|
|
118
|
+
:return: The response of your network call. Does not do error handling on your response.
|
|
119
|
+
:rtype: ~azure.core.rest.AsyncHttpResponse
|
|
120
|
+
"""
|
|
121
|
+
|
|
122
|
+
request_copy = deepcopy(request)
|
|
123
|
+
path_format_arguments = {
|
|
124
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
|
|
128
|
+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
|
|
129
|
+
|
|
130
|
+
async def close(self) -> None:
|
|
131
|
+
await self._client.close()
|
|
132
|
+
|
|
133
|
+
async def __aenter__(self) -> Self:
|
|
134
|
+
await self._client.__aenter__()
|
|
135
|
+
return self
|
|
136
|
+
|
|
137
|
+
async def __aexit__(self, *exc_details: Any) -> None:
|
|
138
|
+
await self._client.__aexit__(*exc_details)
|
|
@@ -1,75 +1,70 @@
|
|
|
1
|
-
# coding=utf-8
|
|
2
|
-
# --------------------------------------------------------------------------
|
|
3
|
-
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
-
# Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
-
# Code generated by Microsoft (R) Python Code Generator.
|
|
6
|
-
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
7
|
-
# --------------------------------------------------------------------------
|
|
8
|
-
|
|
9
|
-
from typing import Any, TYPE_CHECKING
|
|
10
|
-
|
|
11
|
-
from azure.core.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
) -> None:
|
|
42
|
-
api_version: str = kwargs.pop("api_version", "2025-05-15-preview")
|
|
43
|
-
|
|
44
|
-
if endpoint is None:
|
|
45
|
-
raise ValueError("Parameter 'endpoint' must not be None.")
|
|
46
|
-
if credential is None:
|
|
47
|
-
raise ValueError("Parameter 'credential' must not be None.")
|
|
48
|
-
|
|
49
|
-
self.endpoint = endpoint
|
|
50
|
-
self.credential = credential
|
|
51
|
-
self.api_version = api_version
|
|
52
|
-
self.credential_scopes = kwargs.pop("credential_scopes", ["https://ai.azure.com/.default"])
|
|
53
|
-
kwargs.setdefault("sdk_moniker", "ai-projects-onedp/{}".format(VERSION))
|
|
54
|
-
self.polling_interval = kwargs.get("polling_interval", 30)
|
|
55
|
-
self._configure(**kwargs)
|
|
56
|
-
|
|
57
|
-
def
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
self.
|
|
66
|
-
self.
|
|
67
|
-
self.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs)
|
|
72
|
-
self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs)
|
|
73
|
-
self.authentication_policy = kwargs.get("authentication_policy")
|
|
74
|
-
if self.credential and not self.authentication_policy:
|
|
75
|
-
self.authentication_policy = self._infer_policy(**kwargs)
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
# --------------------------------------------------------------------------
|
|
3
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
# Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
# Code generated by Microsoft (R) Python Code Generator.
|
|
6
|
+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
7
|
+
# --------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
from typing import Any, TYPE_CHECKING
|
|
10
|
+
|
|
11
|
+
from azure.core.pipeline import policies
|
|
12
|
+
|
|
13
|
+
from .._version import VERSION
|
|
14
|
+
|
|
15
|
+
if TYPE_CHECKING:
|
|
16
|
+
from azure.core.credentials_async import AsyncTokenCredential
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class AIProjectClientConfiguration: # pylint: disable=too-many-instance-attributes
|
|
20
|
+
"""Configuration for AIProjectClient.
|
|
21
|
+
|
|
22
|
+
Note that all parameters used to create this instance are saved as instance
|
|
23
|
+
attributes.
|
|
24
|
+
|
|
25
|
+
:param endpoint: Project endpoint. In the form
|
|
26
|
+
"https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/_project"
|
|
27
|
+
if your Foundry Hub has only one Project, or to use the default Project in your Hub. Or in the
|
|
28
|
+
form
|
|
29
|
+
"https://<your-ai-services-account-name>.services.ai.azure.com/api/projects/<your-project-name>"
|
|
30
|
+
if you want to explicitly
|
|
31
|
+
specify the Foundry Project name. Required.
|
|
32
|
+
:type endpoint: str
|
|
33
|
+
:param credential: Credential used to authenticate requests to the service. Required.
|
|
34
|
+
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
|
|
35
|
+
:keyword api_version: The API version to use for this operation. Default value is
|
|
36
|
+
"2025-05-15-preview". Note that overriding this default value may result in unsupported
|
|
37
|
+
behavior.
|
|
38
|
+
:paramtype api_version: str
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: Any) -> None:
|
|
42
|
+
api_version: str = kwargs.pop("api_version", "2025-05-15-preview")
|
|
43
|
+
|
|
44
|
+
if endpoint is None:
|
|
45
|
+
raise ValueError("Parameter 'endpoint' must not be None.")
|
|
46
|
+
if credential is None:
|
|
47
|
+
raise ValueError("Parameter 'credential' must not be None.")
|
|
48
|
+
|
|
49
|
+
self.endpoint = endpoint
|
|
50
|
+
self.credential = credential
|
|
51
|
+
self.api_version = api_version
|
|
52
|
+
self.credential_scopes = kwargs.pop("credential_scopes", ["https://ai.azure.com/.default"])
|
|
53
|
+
kwargs.setdefault("sdk_moniker", "ai-projects-onedp/{}".format(VERSION))
|
|
54
|
+
self.polling_interval = kwargs.get("polling_interval", 30)
|
|
55
|
+
self._configure(**kwargs)
|
|
56
|
+
|
|
57
|
+
def _configure(self, **kwargs: Any) -> None:
|
|
58
|
+
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
|
|
59
|
+
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
|
|
60
|
+
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
|
|
61
|
+
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
|
|
62
|
+
self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs)
|
|
63
|
+
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
|
|
64
|
+
self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs)
|
|
65
|
+
self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs)
|
|
66
|
+
self.authentication_policy = kwargs.get("authentication_policy")
|
|
67
|
+
if self.credential and not self.authentication_policy:
|
|
68
|
+
self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(
|
|
69
|
+
self.credential, *self.credential_scopes, **kwargs
|
|
70
|
+
)
|