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,32 +1,32 @@
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
- from ._version import VERSION
17
-
18
- __version__ = VERSION
19
-
20
- try:
21
- from ._patch import __all__ as _patch_all
22
- from ._patch import *
23
- except ImportError:
24
- _patch_all = []
25
- from ._patch import patch_sdk as _patch_sdk
26
-
27
- __all__ = [
28
- "AIProjectClient",
29
- ]
30
- __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
31
-
32
- _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
+ from ._version import VERSION
17
+
18
+ __version__ = VERSION
19
+
20
+ try:
21
+ from ._patch import __all__ as _patch_all
22
+ from ._patch import *
23
+ except ImportError:
24
+ _patch_all = []
25
+ from ._patch import patch_sdk as _patch_sdk
26
+
27
+ __all__ = [
28
+ "AIProjectClient",
29
+ ]
30
+ __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
31
+
32
+ _patch_sdk()
@@ -1,139 +1,136 @@
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, TYPE_CHECKING, Union
11
- from typing_extensions import Self
12
-
13
- from azure.core import PipelineClient
14
- from azure.core.credentials import AzureKeyCredential
15
- from azure.core.pipeline import policies
16
- from azure.core.rest import HttpRequest, HttpResponse
17
-
18
- from ._configuration import AIProjectClientConfiguration
19
- from ._serialization import Deserializer, Serializer
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 import TokenCredential
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.operations.ServicePatternsOperations
40
- :ivar connections: ConnectionsOperations operations
41
- :vartype connections: azure.ai.projects.onedp.operations.ConnectionsOperations
42
- :ivar evaluations: EvaluationsOperations operations
43
- :vartype evaluations: azure.ai.projects.onedp.operations.EvaluationsOperations
44
- :ivar datasets: DatasetsOperations operations
45
- :vartype datasets: azure.ai.projects.onedp.operations.DatasetsOperations
46
- :ivar indexes: IndexesOperations operations
47
- :vartype indexes: azure.ai.projects.onedp.operations.IndexesOperations
48
- :ivar deployments: DeploymentsOperations operations
49
- :vartype deployments: azure.ai.projects.onedp.operations.DeploymentsOperations
50
- :ivar red_teams: RedTeamsOperations operations
51
- :vartype red_teams: azure.ai.projects.onedp.operations.RedTeamsOperations
52
- :ivar evaluation_results: EvaluationResultsOperations operations
53
- :vartype evaluation_results: azure.ai.projects.onedp.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.TokenCredential
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__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None:
68
- _endpoint = "{endpoint}"
69
- self._config = AIProjectClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
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: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)
88
-
89
- self._serialize = Serializer()
90
- self._deserialize = Deserializer()
91
- self._serialize.client_side_validation = False
92
- self.service_patterns = ServicePatternsOperations(
93
- self._client, self._config, self._serialize, self._deserialize
94
- )
95
- self.connections = ConnectionsOperations(self._client, self._config, self._serialize, self._deserialize)
96
- self.evaluations = EvaluationsOperations(self._client, self._config, self._serialize, self._deserialize)
97
- self.datasets = DatasetsOperations(self._client, self._config, self._serialize, self._deserialize)
98
- self.indexes = IndexesOperations(self._client, self._config, self._serialize, self._deserialize)
99
- self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize)
100
- self.red_teams = RedTeamsOperations(self._client, self._config, self._serialize, self._deserialize)
101
- self.evaluation_results = EvaluationResultsOperations(
102
- self._client, self._config, self._serialize, self._deserialize
103
- )
104
-
105
- def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
106
- """Runs the network request through the client's chained policies.
107
-
108
- >>> from azure.core.rest import HttpRequest
109
- >>> request = HttpRequest("GET", "https://www.example.org/")
110
- <HttpRequest [GET], url: 'https://www.example.org/'>
111
- >>> response = client.send_request(request)
112
- <HttpResponse: 200 OK>
113
-
114
- For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
115
-
116
- :param request: The network request you want to make. Required.
117
- :type request: ~azure.core.rest.HttpRequest
118
- :keyword bool stream: Whether the response payload will be streamed. Defaults to False.
119
- :return: The response of your network call. Does not do error handling on your response.
120
- :rtype: ~azure.core.rest.HttpResponse
121
- """
122
-
123
- request_copy = deepcopy(request)
124
- path_format_arguments = {
125
- "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
126
- }
127
-
128
- request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
129
- return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
130
-
131
- def close(self) -> None:
132
- self._client.close()
133
-
134
- def __enter__(self) -> Self:
135
- self._client.__enter__()
136
- return self
137
-
138
- def __exit__(self, *exc_details: Any) -> None:
139
- self._client.__exit__(*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, TYPE_CHECKING
11
+ from typing_extensions import Self
12
+
13
+ from azure.core import PipelineClient
14
+ from azure.core.pipeline import policies
15
+ from azure.core.rest import HttpRequest, HttpResponse
16
+
17
+ from ._configuration import AIProjectClientConfiguration
18
+ from ._utils.serialization import Deserializer, Serializer
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 import TokenCredential
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.operations.ConnectionsOperations
38
+ :ivar evaluations: EvaluationsOperations operations
39
+ :vartype evaluations: azure.ai.projects.onedp.operations.EvaluationsOperations
40
+ :ivar datasets: DatasetsOperations operations
41
+ :vartype datasets: azure.ai.projects.onedp.operations.DatasetsOperations
42
+ :ivar indexes: IndexesOperations operations
43
+ :vartype indexes: azure.ai.projects.onedp.operations.IndexesOperations
44
+ :ivar deployments: DeploymentsOperations operations
45
+ :vartype deployments: azure.ai.projects.onedp.operations.DeploymentsOperations
46
+ :ivar red_teams: RedTeamsOperations operations
47
+ :vartype red_teams: azure.ai.projects.onedp.operations.RedTeamsOperations
48
+ :ivar evaluation_results: EvaluationResultsOperations operations
49
+ :vartype evaluation_results: azure.ai.projects.onedp.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.TokenCredential
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: "TokenCredential", **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: PipelineClient = PipelineClient(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(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
103
+ """Runs the network request through the client's chained policies.
104
+
105
+ >>> from azure.core.rest import HttpRequest
106
+ >>> request = HttpRequest("GET", "https://www.example.org/")
107
+ <HttpRequest [GET], url: 'https://www.example.org/'>
108
+ >>> response = client.send_request(request)
109
+ <HttpResponse: 200 OK>
110
+
111
+ For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
112
+
113
+ :param request: The network request you want to make. Required.
114
+ :type request: ~azure.core.rest.HttpRequest
115
+ :keyword bool stream: Whether the response payload will be streamed. Defaults to False.
116
+ :return: The response of your network call. Does not do error handling on your response.
117
+ :rtype: ~azure.core.rest.HttpResponse
118
+ """
119
+
120
+ request_copy = deepcopy(request)
121
+ path_format_arguments = {
122
+ "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
123
+ }
124
+
125
+ request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
126
+ return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
127
+
128
+ def close(self) -> None:
129
+ self._client.close()
130
+
131
+ def __enter__(self) -> Self:
132
+ self._client.__enter__()
133
+ return self
134
+
135
+ def __exit__(self, *exc_details: Any) -> None:
136
+ self._client.__exit__(*exc_details)
@@ -1,73 +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 import TokenCredential
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.TokenCredential
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__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None:
40
- api_version: str = kwargs.pop("api_version", "2025-05-15-preview")
41
-
42
- if endpoint is None:
43
- raise ValueError("Parameter 'endpoint' must not be None.")
44
- if credential is None:
45
- raise ValueError("Parameter 'credential' must not be None.")
46
-
47
- self.endpoint = endpoint
48
- self.credential = credential
49
- self.api_version = api_version
50
- self.credential_scopes = kwargs.pop("credential_scopes", ["https://ai.azure.com/.default"])
51
- kwargs.setdefault("sdk_moniker", "ai-projects-onedp/{}".format(VERSION))
52
- self.polling_interval = kwargs.get("polling_interval", 30)
53
- self._configure(**kwargs)
54
-
55
- def _infer_policy(self, **kwargs):
56
- if isinstance(self.credential, AzureKeyCredential):
57
- return policies.AzureKeyCredentialPolicy(self.credential, "Authorization", prefix="Bearer", **kwargs)
58
- if hasattr(self.credential, "get_token"):
59
- return policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
60
- raise TypeError(f"Unsupported credential: {self.credential}")
61
-
62
- def _configure(self, **kwargs: Any) -> None:
63
- self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
64
- self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
65
- self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
66
- self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
67
- self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs)
68
- self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
69
- self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
70
- self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
71
- self.authentication_policy = kwargs.get("authentication_policy")
72
- if self.credential and not self.authentication_policy:
73
- 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 import TokenCredential
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.TokenCredential
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: "TokenCredential", **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.RedirectPolicy(**kwargs)
65
+ self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
66
+ self.authentication_policy = kwargs.get("authentication_policy")
67
+ if self.credential and not self.authentication_policy:
68
+ self.authentication_policy = policies.BearerTokenCredentialPolicy(
69
+ self.credential, *self.credential_scopes, **kwargs
70
+ )
@@ -1,21 +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
- """
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,6 @@
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
+ # --------------------------------------------------------------------------