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.

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