azure-ai-evaluation 1.4.0__py3-none-any.whl → 1.6.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 (150) hide show
  1. azure/ai/evaluation/__init__.py +9 -16
  2. azure/ai/evaluation/_aoai/__init__.py +10 -0
  3. azure/ai/evaluation/_aoai/aoai_grader.py +89 -0
  4. azure/ai/evaluation/_aoai/label_grader.py +66 -0
  5. azure/ai/evaluation/_aoai/string_check_grader.py +65 -0
  6. azure/ai/evaluation/_aoai/text_similarity_grader.py +88 -0
  7. azure/ai/evaluation/_azure/_clients.py +4 -4
  8. azure/ai/evaluation/_azure/_envs.py +208 -0
  9. azure/ai/evaluation/_azure/_token_manager.py +12 -7
  10. azure/ai/evaluation/_common/__init__.py +5 -0
  11. azure/ai/evaluation/_common/evaluation_onedp_client.py +118 -0
  12. azure/ai/evaluation/_common/onedp/__init__.py +32 -0
  13. azure/ai/evaluation/_common/onedp/_client.py +139 -0
  14. azure/ai/evaluation/_common/onedp/_configuration.py +73 -0
  15. azure/ai/evaluation/_common/onedp/_model_base.py +1232 -0
  16. azure/ai/evaluation/_common/onedp/_patch.py +21 -0
  17. azure/ai/evaluation/_common/onedp/_serialization.py +2032 -0
  18. azure/ai/evaluation/_common/onedp/_types.py +21 -0
  19. azure/ai/evaluation/_common/onedp/_validation.py +50 -0
  20. azure/ai/evaluation/_common/onedp/_vendor.py +50 -0
  21. azure/ai/evaluation/_common/onedp/_version.py +9 -0
  22. azure/ai/evaluation/_common/onedp/aio/__init__.py +29 -0
  23. azure/ai/evaluation/_common/onedp/aio/_client.py +143 -0
  24. azure/ai/evaluation/_common/onedp/aio/_configuration.py +75 -0
  25. azure/ai/evaluation/_common/onedp/aio/_patch.py +21 -0
  26. azure/ai/evaluation/_common/onedp/aio/_vendor.py +40 -0
  27. azure/ai/evaluation/_common/onedp/aio/operations/__init__.py +39 -0
  28. azure/ai/evaluation/_common/onedp/aio/operations/_operations.py +4494 -0
  29. azure/ai/evaluation/_common/onedp/aio/operations/_patch.py +21 -0
  30. azure/ai/evaluation/_common/onedp/models/__init__.py +142 -0
  31. azure/ai/evaluation/_common/onedp/models/_enums.py +162 -0
  32. azure/ai/evaluation/_common/onedp/models/_models.py +2228 -0
  33. azure/ai/evaluation/_common/onedp/models/_patch.py +21 -0
  34. azure/ai/evaluation/_common/onedp/operations/__init__.py +39 -0
  35. azure/ai/evaluation/_common/onedp/operations/_operations.py +5655 -0
  36. azure/ai/evaluation/_common/onedp/operations/_patch.py +21 -0
  37. azure/ai/evaluation/_common/onedp/py.typed +1 -0
  38. azure/ai/evaluation/_common/onedp/servicepatterns/__init__.py +1 -0
  39. azure/ai/evaluation/_common/onedp/servicepatterns/aio/__init__.py +1 -0
  40. azure/ai/evaluation/_common/onedp/servicepatterns/aio/operations/__init__.py +25 -0
  41. azure/ai/evaluation/_common/onedp/servicepatterns/aio/operations/_operations.py +34 -0
  42. azure/ai/evaluation/_common/onedp/servicepatterns/aio/operations/_patch.py +20 -0
  43. azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/__init__.py +1 -0
  44. azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/aio/__init__.py +1 -0
  45. azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/aio/operations/__init__.py +22 -0
  46. azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/aio/operations/_operations.py +29 -0
  47. azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/aio/operations/_patch.py +20 -0
  48. azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/operations/__init__.py +22 -0
  49. azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/operations/_operations.py +29 -0
  50. azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/operations/_patch.py +20 -0
  51. azure/ai/evaluation/_common/onedp/servicepatterns/operations/__init__.py +25 -0
  52. azure/ai/evaluation/_common/onedp/servicepatterns/operations/_operations.py +34 -0
  53. azure/ai/evaluation/_common/onedp/servicepatterns/operations/_patch.py +20 -0
  54. azure/ai/evaluation/_common/rai_service.py +159 -29
  55. azure/ai/evaluation/_common/raiclient/_version.py +1 -1
  56. azure/ai/evaluation/_common/utils.py +80 -2
  57. azure/ai/evaluation/_constants.py +16 -0
  58. azure/ai/evaluation/_converters/__init__.py +1 -1
  59. azure/ai/evaluation/_converters/_ai_services.py +4 -4
  60. azure/ai/evaluation/_eval_mapping.py +71 -0
  61. azure/ai/evaluation/_evaluate/_batch_run/_run_submitter_client.py +30 -16
  62. azure/ai/evaluation/_evaluate/_batch_run/code_client.py +18 -12
  63. azure/ai/evaluation/_evaluate/_batch_run/eval_run_context.py +17 -4
  64. azure/ai/evaluation/_evaluate/_batch_run/proxy_client.py +47 -22
  65. azure/ai/evaluation/_evaluate/_batch_run/target_run_context.py +18 -2
  66. azure/ai/evaluation/_evaluate/_eval_run.py +2 -2
  67. azure/ai/evaluation/_evaluate/_evaluate.py +372 -105
  68. azure/ai/evaluation/_evaluate/_evaluate_aoai.py +534 -0
  69. azure/ai/evaluation/_evaluate/_telemetry/__init__.py +5 -89
  70. azure/ai/evaluation/_evaluate/_utils.py +120 -7
  71. azure/ai/evaluation/_evaluators/_common/_base_eval.py +9 -4
  72. azure/ai/evaluation/_evaluators/_common/_base_multi_eval.py +1 -1
  73. azure/ai/evaluation/_evaluators/_common/_base_prompty_eval.py +12 -3
  74. azure/ai/evaluation/_evaluators/_common/_base_rai_svc_eval.py +2 -2
  75. azure/ai/evaluation/_evaluators/_document_retrieval/__init__.py +11 -0
  76. azure/ai/evaluation/_evaluators/_document_retrieval/_document_retrieval.py +467 -0
  77. azure/ai/evaluation/_evaluators/_fluency/_fluency.py +1 -1
  78. azure/ai/evaluation/_evaluators/_groundedness/_groundedness.py +2 -2
  79. azure/ai/evaluation/_evaluators/_intent_resolution/_intent_resolution.py +6 -2
  80. azure/ai/evaluation/_evaluators/_relevance/_relevance.py +1 -1
  81. azure/ai/evaluation/_evaluators/_response_completeness/_response_completeness.py +8 -2
  82. azure/ai/evaluation/_evaluators/_response_completeness/response_completeness.prompty +31 -46
  83. azure/ai/evaluation/_evaluators/_similarity/_similarity.py +1 -1
  84. azure/ai/evaluation/_evaluators/_task_adherence/_task_adherence.py +5 -2
  85. azure/ai/evaluation/_evaluators/_tool_call_accuracy/_tool_call_accuracy.py +6 -2
  86. azure/ai/evaluation/_exceptions.py +2 -0
  87. azure/ai/evaluation/_legacy/_adapters/__init__.py +7 -0
  88. azure/ai/evaluation/_legacy/_adapters/_check.py +17 -0
  89. azure/ai/evaluation/_legacy/_adapters/_configuration.py +45 -0
  90. azure/ai/evaluation/_legacy/_adapters/_constants.py +10 -0
  91. azure/ai/evaluation/_legacy/_adapters/_errors.py +29 -0
  92. azure/ai/evaluation/_legacy/_adapters/_flows.py +28 -0
  93. azure/ai/evaluation/_legacy/_adapters/_service.py +16 -0
  94. azure/ai/evaluation/_legacy/_adapters/client.py +51 -0
  95. azure/ai/evaluation/_legacy/_adapters/entities.py +26 -0
  96. azure/ai/evaluation/_legacy/_adapters/tracing.py +28 -0
  97. azure/ai/evaluation/_legacy/_adapters/types.py +15 -0
  98. azure/ai/evaluation/_legacy/_adapters/utils.py +31 -0
  99. azure/ai/evaluation/_legacy/_batch_engine/_engine.py +51 -32
  100. azure/ai/evaluation/_legacy/_batch_engine/_openai_injector.py +114 -8
  101. azure/ai/evaluation/_legacy/_batch_engine/_result.py +7 -1
  102. azure/ai/evaluation/_legacy/_batch_engine/_run.py +6 -0
  103. azure/ai/evaluation/_legacy/_batch_engine/_run_submitter.py +69 -29
  104. azure/ai/evaluation/_legacy/_batch_engine/_status.py +1 -1
  105. azure/ai/evaluation/_legacy/_batch_engine/_trace.py +54 -62
  106. azure/ai/evaluation/_legacy/_batch_engine/_utils.py +19 -1
  107. azure/ai/evaluation/{_red_team/_utils → _legacy/_common}/__init__.py +1 -1
  108. azure/ai/evaluation/_legacy/_common/_async_token_provider.py +124 -0
  109. azure/ai/evaluation/_legacy/_common/_thread_pool_executor_with_context.py +15 -0
  110. azure/ai/evaluation/_legacy/prompty/_connection.py +11 -74
  111. azure/ai/evaluation/_legacy/prompty/_exceptions.py +80 -0
  112. azure/ai/evaluation/_legacy/prompty/_prompty.py +119 -9
  113. azure/ai/evaluation/_legacy/prompty/_utils.py +72 -2
  114. azure/ai/evaluation/_safety_evaluation/_safety_evaluation.py +90 -17
  115. azure/ai/evaluation/_version.py +1 -1
  116. azure/ai/evaluation/red_team/__init__.py +19 -0
  117. azure/ai/evaluation/{_red_team → red_team}/_attack_objective_generator.py +3 -0
  118. azure/ai/evaluation/{_red_team → red_team}/_attack_strategy.py +4 -1
  119. azure/ai/evaluation/{_red_team → red_team}/_red_team.py +885 -481
  120. azure/ai/evaluation/red_team/_red_team_result.py +382 -0
  121. azure/ai/evaluation/{_red_team → red_team}/_utils/constants.py +2 -1
  122. azure/ai/evaluation/{_red_team → red_team}/_utils/formatting_utils.py +23 -22
  123. azure/ai/evaluation/{_red_team → red_team}/_utils/logging_utils.py +1 -1
  124. azure/ai/evaluation/red_team/_utils/metric_mapping.py +23 -0
  125. azure/ai/evaluation/{_red_team → red_team}/_utils/strategy_utils.py +9 -5
  126. azure/ai/evaluation/simulator/_adversarial_simulator.py +63 -39
  127. azure/ai/evaluation/simulator/_constants.py +1 -0
  128. azure/ai/evaluation/simulator/_conversation/__init__.py +13 -6
  129. azure/ai/evaluation/simulator/_conversation/_conversation.py +2 -1
  130. azure/ai/evaluation/simulator/_direct_attack_simulator.py +35 -22
  131. azure/ai/evaluation/simulator/_helpers/_language_suffix_mapping.py +1 -0
  132. azure/ai/evaluation/simulator/_indirect_attack_simulator.py +40 -25
  133. azure/ai/evaluation/simulator/_model_tools/__init__.py +2 -1
  134. azure/ai/evaluation/simulator/_model_tools/_generated_rai_client.py +24 -18
  135. azure/ai/evaluation/simulator/_model_tools/_identity_manager.py +5 -10
  136. azure/ai/evaluation/simulator/_model_tools/_proxy_completion_model.py +65 -41
  137. azure/ai/evaluation/simulator/_model_tools/_template_handler.py +9 -5
  138. azure/ai/evaluation/simulator/_model_tools/models.py +20 -17
  139. azure/ai/evaluation/simulator/_simulator.py +1 -1
  140. {azure_ai_evaluation-1.4.0.dist-info → azure_ai_evaluation-1.6.0.dist-info}/METADATA +36 -2
  141. {azure_ai_evaluation-1.4.0.dist-info → azure_ai_evaluation-1.6.0.dist-info}/RECORD +148 -80
  142. azure/ai/evaluation/_red_team/_red_team_result.py +0 -246
  143. azure/ai/evaluation/simulator/_tracing.py +0 -89
  144. /azure/ai/evaluation/_legacy/{_batch_engine → _common}/_logging.py +0 -0
  145. /azure/ai/evaluation/{_red_team → red_team}/_callback_chat_target.py +0 -0
  146. /azure/ai/evaluation/{_red_team → red_team}/_default_converter.py +0 -0
  147. /azure/ai/evaluation/{_red_team → red_team/_utils}/__init__.py +0 -0
  148. {azure_ai_evaluation-1.4.0.dist-info → azure_ai_evaluation-1.6.0.dist-info}/NOTICE.txt +0 -0
  149. {azure_ai_evaluation-1.4.0.dist-info → azure_ai_evaluation-1.6.0.dist-info}/WHEEL +0 -0
  150. {azure_ai_evaluation-1.4.0.dist-info → azure_ai_evaluation-1.6.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,21 @@
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 TYPE_CHECKING, Union
10
+
11
+ if TYPE_CHECKING:
12
+ from . import models as _models
13
+ AgentsApiResponseFormatOption = Union[
14
+ str,
15
+ str,
16
+ "_models.AgentsApiResponseFormatMode",
17
+ "_models.AgentsApiResponseFormat",
18
+ "_models.ResponseFormatJsonSchemaType",
19
+ ]
20
+ MessageAttachmentToolDefinition = Union["_models.CodeInterpreterToolDefinition", "_models.FileSearchToolDefinition"]
21
+ AgentsApiToolChoiceOption = Union[str, str, "_models.AgentsApiToolChoiceOptionMode", "_models.AgentsNamedToolChoice"]
@@ -0,0 +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
@@ -0,0 +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
+
8
+ import json
9
+ from typing import Any, Dict, IO, List, Mapping, Optional, Tuple, Union
10
+
11
+ from ._model_base import Model, SdkJSONEncoder
12
+
13
+
14
+ # file-like tuple could be `(filename, IO (or bytes))` or `(filename, IO (or bytes), content_type)`
15
+ FileContent = Union[str, bytes, IO[str], IO[bytes]]
16
+
17
+ FileType = Union[
18
+ # file (or bytes)
19
+ FileContent,
20
+ # (filename, file (or bytes))
21
+ Tuple[Optional[str], FileContent],
22
+ # (filename, file (or bytes), content_type)
23
+ Tuple[Optional[str], FileContent, Optional[str]],
24
+ ]
25
+
26
+
27
+ def serialize_multipart_data_entry(data_entry: Any) -> Any:
28
+ if isinstance(data_entry, (list, tuple, dict, Model)):
29
+ return json.dumps(data_entry, cls=SdkJSONEncoder, exclude_readonly=True)
30
+ return data_entry
31
+
32
+
33
+ def prepare_multipart_form_data(
34
+ body: Mapping[str, Any], multipart_fields: List[str], data_fields: List[str]
35
+ ) -> Tuple[List[FileType], Dict[str, Any]]:
36
+ files: List[FileType] = []
37
+ data: Dict[str, Any] = {}
38
+ for multipart_field in multipart_fields:
39
+ multipart_entry = body.get(multipart_field)
40
+ if isinstance(multipart_entry, list):
41
+ files.extend([(multipart_field, e) for e in multipart_entry])
42
+ elif multipart_entry:
43
+ files.append((multipart_field, multipart_entry))
44
+
45
+ for data_field in data_fields:
46
+ data_entry = body.get(data_field)
47
+ if data_entry:
48
+ data[data_field] = serialize_multipart_data_entry(data_entry)
49
+
50
+ return files, data
@@ -0,0 +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"
@@ -0,0 +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()
@@ -0,0 +1,143 @@
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)
@@ -0,0 +1,75 @@
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)
@@ -0,0 +1,21 @@
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
+ # --------------------------------------------------------------------------
6
+ """Customize generated code here.
7
+
8
+ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize
9
+ """
10
+ from typing import List
11
+
12
+ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level
13
+
14
+
15
+ def patch_sdk():
16
+ """Do not remove from this file.
17
+
18
+ `patch_sdk` is a last resort escape hatch that allows you to do customizations
19
+ you can't accomplish using the techniques described in
20
+ https://aka.ms/azsdk/python/dpcodegen/python/customize
21
+ """
@@ -0,0 +1,40 @@
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
+
8
+ from typing import Optional
9
+
10
+ from azure.core import MatchConditions
11
+
12
+
13
+ def quote_etag(etag: Optional[str]) -> Optional[str]:
14
+ if not etag or etag == "*":
15
+ return etag
16
+ if etag.startswith("W/"):
17
+ return etag
18
+ if etag.startswith('"') and etag.endswith('"'):
19
+ return etag
20
+ if etag.startswith("'") and etag.endswith("'"):
21
+ return etag
22
+ return '"' + etag + '"'
23
+
24
+
25
+ def prep_if_match(etag: Optional[str], match_condition: Optional[MatchConditions]) -> Optional[str]:
26
+ if match_condition == MatchConditions.IfNotModified:
27
+ if_match = quote_etag(etag) if etag else None
28
+ return if_match
29
+ if match_condition == MatchConditions.IfPresent:
30
+ return "*"
31
+ return None
32
+
33
+
34
+ def prep_if_none_match(etag: Optional[str], match_condition: Optional[MatchConditions]) -> Optional[str]:
35
+ if match_condition == MatchConditions.IfModified:
36
+ if_none_match = quote_etag(etag) if etag else None
37
+ return if_none_match
38
+ if match_condition == MatchConditions.IfMissing:
39
+ return "*"
40
+ return None
@@ -0,0 +1,39 @@
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 ._operations import ServicePatternsOperations # type: ignore
16
+ from ._operations import ConnectionsOperations # type: ignore
17
+ from ._operations import EvaluationsOperations # type: ignore
18
+ from ._operations import DatasetsOperations # type: ignore
19
+ from ._operations import IndexesOperations # type: ignore
20
+ from ._operations import DeploymentsOperations # type: ignore
21
+ from ._operations import RedTeamsOperations # type: ignore
22
+ from ._operations import EvaluationResultsOperations # type: ignore
23
+
24
+ from ._patch import __all__ as _patch_all
25
+ from ._patch import *
26
+ from ._patch import patch_sdk as _patch_sdk
27
+
28
+ __all__ = [
29
+ "ServicePatternsOperations",
30
+ "ConnectionsOperations",
31
+ "EvaluationsOperations",
32
+ "DatasetsOperations",
33
+ "IndexesOperations",
34
+ "DeploymentsOperations",
35
+ "RedTeamsOperations",
36
+ "EvaluationResultsOperations",
37
+ ]
38
+ __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
39
+ _patch_sdk()