azure-ai-evaluation 1.0.1__py3-none-any.whl → 1.13.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of azure-ai-evaluation might be problematic. Click here for more details.
- azure/ai/evaluation/__init__.py +85 -14
- azure/ai/evaluation/_aoai/__init__.py +10 -0
- azure/ai/evaluation/_aoai/aoai_grader.py +140 -0
- azure/ai/evaluation/_aoai/label_grader.py +68 -0
- azure/ai/evaluation/_aoai/python_grader.py +86 -0
- azure/ai/evaluation/_aoai/score_model_grader.py +94 -0
- azure/ai/evaluation/_aoai/string_check_grader.py +66 -0
- azure/ai/evaluation/_aoai/text_similarity_grader.py +80 -0
- azure/ai/evaluation/_azure/__init__.py +3 -0
- azure/ai/evaluation/_azure/_clients.py +204 -0
- azure/ai/evaluation/_azure/_envs.py +207 -0
- azure/ai/evaluation/_azure/_models.py +227 -0
- azure/ai/evaluation/_azure/_token_manager.py +129 -0
- azure/ai/evaluation/_common/__init__.py +9 -1
- azure/ai/evaluation/_common/constants.py +124 -2
- azure/ai/evaluation/_common/evaluation_onedp_client.py +169 -0
- azure/ai/evaluation/_common/onedp/__init__.py +32 -0
- azure/ai/evaluation/_common/onedp/_client.py +166 -0
- azure/ai/evaluation/_common/onedp/_configuration.py +72 -0
- azure/ai/evaluation/_common/onedp/_model_base.py +1232 -0
- azure/ai/evaluation/_common/onedp/_patch.py +21 -0
- azure/ai/evaluation/_common/onedp/_serialization.py +2032 -0
- azure/ai/evaluation/_common/onedp/_types.py +21 -0
- azure/ai/evaluation/_common/onedp/_utils/__init__.py +6 -0
- azure/ai/evaluation/_common/onedp/_utils/model_base.py +1232 -0
- azure/ai/evaluation/_common/onedp/_utils/serialization.py +2032 -0
- azure/ai/evaluation/_common/onedp/_validation.py +66 -0
- azure/ai/evaluation/_common/onedp/_vendor.py +50 -0
- azure/ai/evaluation/_common/onedp/_version.py +9 -0
- azure/ai/evaluation/_common/onedp/aio/__init__.py +29 -0
- azure/ai/evaluation/_common/onedp/aio/_client.py +168 -0
- azure/ai/evaluation/_common/onedp/aio/_configuration.py +72 -0
- azure/ai/evaluation/_common/onedp/aio/_patch.py +21 -0
- azure/ai/evaluation/_common/onedp/aio/operations/__init__.py +49 -0
- azure/ai/evaluation/_common/onedp/aio/operations/_operations.py +7143 -0
- azure/ai/evaluation/_common/onedp/aio/operations/_patch.py +21 -0
- azure/ai/evaluation/_common/onedp/models/__init__.py +358 -0
- azure/ai/evaluation/_common/onedp/models/_enums.py +447 -0
- azure/ai/evaluation/_common/onedp/models/_models.py +5963 -0
- azure/ai/evaluation/_common/onedp/models/_patch.py +21 -0
- azure/ai/evaluation/_common/onedp/operations/__init__.py +49 -0
- azure/ai/evaluation/_common/onedp/operations/_operations.py +8951 -0
- azure/ai/evaluation/_common/onedp/operations/_patch.py +21 -0
- azure/ai/evaluation/_common/onedp/py.typed +1 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/__init__.py +1 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/aio/__init__.py +1 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/aio/operations/__init__.py +25 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/aio/operations/_operations.py +34 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/aio/operations/_patch.py +20 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/__init__.py +1 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/aio/__init__.py +1 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/aio/operations/__init__.py +22 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/aio/operations/_operations.py +29 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/aio/operations/_patch.py +20 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/operations/__init__.py +22 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/operations/_operations.py +29 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/operations/_patch.py +20 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/operations/__init__.py +25 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/operations/_operations.py +34 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/operations/_patch.py +20 -0
- azure/ai/evaluation/_common/rai_service.py +578 -69
- azure/ai/evaluation/_common/raiclient/__init__.py +34 -0
- azure/ai/evaluation/_common/raiclient/_client.py +128 -0
- azure/ai/evaluation/_common/raiclient/_configuration.py +87 -0
- azure/ai/evaluation/_common/raiclient/_model_base.py +1235 -0
- azure/ai/evaluation/_common/raiclient/_patch.py +20 -0
- azure/ai/evaluation/_common/raiclient/_serialization.py +2050 -0
- azure/ai/evaluation/_common/raiclient/_version.py +9 -0
- azure/ai/evaluation/_common/raiclient/aio/__init__.py +29 -0
- azure/ai/evaluation/_common/raiclient/aio/_client.py +130 -0
- azure/ai/evaluation/_common/raiclient/aio/_configuration.py +87 -0
- azure/ai/evaluation/_common/raiclient/aio/_patch.py +20 -0
- azure/ai/evaluation/_common/raiclient/aio/operations/__init__.py +25 -0
- azure/ai/evaluation/_common/raiclient/aio/operations/_operations.py +981 -0
- azure/ai/evaluation/_common/raiclient/aio/operations/_patch.py +20 -0
- azure/ai/evaluation/_common/raiclient/models/__init__.py +60 -0
- azure/ai/evaluation/_common/raiclient/models/_enums.py +18 -0
- azure/ai/evaluation/_common/raiclient/models/_models.py +651 -0
- azure/ai/evaluation/_common/raiclient/models/_patch.py +20 -0
- azure/ai/evaluation/_common/raiclient/operations/__init__.py +25 -0
- azure/ai/evaluation/_common/raiclient/operations/_operations.py +1238 -0
- azure/ai/evaluation/_common/raiclient/operations/_patch.py +20 -0
- azure/ai/evaluation/_common/raiclient/py.typed +1 -0
- azure/ai/evaluation/_common/utils.py +505 -27
- azure/ai/evaluation/_constants.py +147 -0
- azure/ai/evaluation/_converters/__init__.py +3 -0
- azure/ai/evaluation/_converters/_ai_services.py +899 -0
- azure/ai/evaluation/_converters/_models.py +467 -0
- azure/ai/evaluation/_converters/_sk_services.py +495 -0
- azure/ai/evaluation/_eval_mapping.py +87 -0
- azure/ai/evaluation/_evaluate/_batch_run/__init__.py +10 -2
- azure/ai/evaluation/_evaluate/_batch_run/_run_submitter_client.py +176 -0
- azure/ai/evaluation/_evaluate/_batch_run/batch_clients.py +82 -0
- azure/ai/evaluation/_evaluate/_batch_run/code_client.py +18 -12
- azure/ai/evaluation/_evaluate/_batch_run/eval_run_context.py +19 -6
- azure/ai/evaluation/_evaluate/_batch_run/proxy_client.py +47 -22
- azure/ai/evaluation/_evaluate/_batch_run/target_run_context.py +18 -2
- azure/ai/evaluation/_evaluate/_eval_run.py +32 -46
- azure/ai/evaluation/_evaluate/_evaluate.py +1809 -142
- azure/ai/evaluation/_evaluate/_evaluate_aoai.py +992 -0
- azure/ai/evaluation/_evaluate/_telemetry/__init__.py +5 -90
- azure/ai/evaluation/_evaluate/_utils.py +237 -42
- azure/ai/evaluation/_evaluator_definition.py +76 -0
- azure/ai/evaluation/_evaluators/_bleu/_bleu.py +80 -28
- azure/ai/evaluation/_evaluators/_code_vulnerability/__init__.py +5 -0
- azure/ai/evaluation/_evaluators/_code_vulnerability/_code_vulnerability.py +119 -0
- azure/ai/evaluation/_evaluators/_coherence/_coherence.py +40 -4
- azure/ai/evaluation/_evaluators/_common/__init__.py +2 -0
- azure/ai/evaluation/_evaluators/_common/_base_eval.py +430 -29
- azure/ai/evaluation/_evaluators/_common/_base_multi_eval.py +63 -0
- azure/ai/evaluation/_evaluators/_common/_base_prompty_eval.py +269 -12
- azure/ai/evaluation/_evaluators/_common/_base_rai_svc_eval.py +74 -9
- azure/ai/evaluation/_evaluators/_common/_conversation_aggregators.py +49 -0
- azure/ai/evaluation/_evaluators/_content_safety/_content_safety.py +73 -53
- azure/ai/evaluation/_evaluators/_content_safety/_hate_unfairness.py +35 -5
- azure/ai/evaluation/_evaluators/_content_safety/_self_harm.py +26 -5
- azure/ai/evaluation/_evaluators/_content_safety/_sexual.py +35 -5
- azure/ai/evaluation/_evaluators/_content_safety/_violence.py +34 -4
- azure/ai/evaluation/_evaluators/_document_retrieval/__init__.py +7 -0
- azure/ai/evaluation/_evaluators/_document_retrieval/_document_retrieval.py +442 -0
- azure/ai/evaluation/_evaluators/_eci/_eci.py +6 -3
- azure/ai/evaluation/_evaluators/_f1_score/_f1_score.py +97 -70
- azure/ai/evaluation/_evaluators/_fluency/_fluency.py +39 -3
- azure/ai/evaluation/_evaluators/_gleu/_gleu.py +80 -25
- azure/ai/evaluation/_evaluators/_groundedness/_groundedness.py +230 -20
- azure/ai/evaluation/_evaluators/_groundedness/groundedness_with_query.prompty +30 -29
- azure/ai/evaluation/_evaluators/_groundedness/groundedness_without_query.prompty +19 -14
- azure/ai/evaluation/_evaluators/_intent_resolution/__init__.py +7 -0
- azure/ai/evaluation/_evaluators/_intent_resolution/_intent_resolution.py +196 -0
- azure/ai/evaluation/_evaluators/_intent_resolution/intent_resolution.prompty +275 -0
- azure/ai/evaluation/_evaluators/_meteor/_meteor.py +89 -36
- azure/ai/evaluation/_evaluators/_protected_material/_protected_material.py +22 -4
- azure/ai/evaluation/_evaluators/_qa/_qa.py +94 -35
- azure/ai/evaluation/_evaluators/_relevance/_relevance.py +100 -4
- azure/ai/evaluation/_evaluators/_relevance/relevance.prompty +154 -56
- azure/ai/evaluation/_evaluators/_response_completeness/__init__.py +7 -0
- azure/ai/evaluation/_evaluators/_response_completeness/_response_completeness.py +202 -0
- azure/ai/evaluation/_evaluators/_response_completeness/response_completeness.prompty +84 -0
- azure/ai/evaluation/_evaluators/_retrieval/_retrieval.py +39 -3
- azure/ai/evaluation/_evaluators/_rouge/_rouge.py +166 -26
- azure/ai/evaluation/_evaluators/_service_groundedness/_service_groundedness.py +38 -7
- azure/ai/evaluation/_evaluators/_similarity/_similarity.py +81 -85
- azure/ai/evaluation/_evaluators/_task_adherence/__init__.py +7 -0
- azure/ai/evaluation/_evaluators/_task_adherence/_task_adherence.py +226 -0
- azure/ai/evaluation/_evaluators/_task_adherence/task_adherence.prompty +101 -0
- azure/ai/evaluation/_evaluators/_task_completion/__init__.py +7 -0
- azure/ai/evaluation/_evaluators/_task_completion/_task_completion.py +177 -0
- azure/ai/evaluation/_evaluators/_task_completion/task_completion.prompty +220 -0
- azure/ai/evaluation/_evaluators/_task_navigation_efficiency/__init__.py +7 -0
- azure/ai/evaluation/_evaluators/_task_navigation_efficiency/_task_navigation_efficiency.py +384 -0
- azure/ai/evaluation/_evaluators/_tool_call_accuracy/__init__.py +9 -0
- azure/ai/evaluation/_evaluators/_tool_call_accuracy/_tool_call_accuracy.py +298 -0
- azure/ai/evaluation/_evaluators/_tool_call_accuracy/tool_call_accuracy.prompty +166 -0
- azure/ai/evaluation/_evaluators/_tool_call_success/__init__.py +7 -0
- azure/ai/evaluation/_evaluators/_tool_call_success/_tool_call_success.py +306 -0
- azure/ai/evaluation/_evaluators/_tool_call_success/tool_call_success.prompty +321 -0
- azure/ai/evaluation/_evaluators/_tool_input_accuracy/__init__.py +9 -0
- azure/ai/evaluation/_evaluators/_tool_input_accuracy/_tool_input_accuracy.py +263 -0
- azure/ai/evaluation/_evaluators/_tool_input_accuracy/tool_input_accuracy.prompty +76 -0
- azure/ai/evaluation/_evaluators/_tool_output_utilization/__init__.py +7 -0
- azure/ai/evaluation/_evaluators/_tool_output_utilization/_tool_output_utilization.py +225 -0
- azure/ai/evaluation/_evaluators/_tool_output_utilization/tool_output_utilization.prompty +221 -0
- azure/ai/evaluation/_evaluators/_tool_selection/__init__.py +9 -0
- azure/ai/evaluation/_evaluators/_tool_selection/_tool_selection.py +266 -0
- azure/ai/evaluation/_evaluators/_tool_selection/tool_selection.prompty +104 -0
- azure/ai/evaluation/_evaluators/_ungrounded_attributes/__init__.py +5 -0
- azure/ai/evaluation/_evaluators/_ungrounded_attributes/_ungrounded_attributes.py +102 -0
- azure/ai/evaluation/_evaluators/_xpia/xpia.py +20 -4
- azure/ai/evaluation/_exceptions.py +24 -1
- azure/ai/evaluation/_http_utils.py +7 -5
- azure/ai/evaluation/_legacy/__init__.py +3 -0
- azure/ai/evaluation/_legacy/_adapters/__init__.py +7 -0
- azure/ai/evaluation/_legacy/_adapters/_check.py +17 -0
- azure/ai/evaluation/_legacy/_adapters/_configuration.py +45 -0
- azure/ai/evaluation/_legacy/_adapters/_constants.py +10 -0
- azure/ai/evaluation/_legacy/_adapters/_errors.py +29 -0
- azure/ai/evaluation/_legacy/_adapters/_flows.py +28 -0
- azure/ai/evaluation/_legacy/_adapters/_service.py +16 -0
- azure/ai/evaluation/_legacy/_adapters/client.py +51 -0
- azure/ai/evaluation/_legacy/_adapters/entities.py +26 -0
- azure/ai/evaluation/_legacy/_adapters/tracing.py +28 -0
- azure/ai/evaluation/_legacy/_adapters/types.py +15 -0
- azure/ai/evaluation/_legacy/_adapters/utils.py +31 -0
- azure/ai/evaluation/_legacy/_batch_engine/__init__.py +9 -0
- azure/ai/evaluation/_legacy/_batch_engine/_config.py +48 -0
- azure/ai/evaluation/_legacy/_batch_engine/_engine.py +477 -0
- azure/ai/evaluation/_legacy/_batch_engine/_exceptions.py +88 -0
- azure/ai/evaluation/_legacy/_batch_engine/_openai_injector.py +132 -0
- azure/ai/evaluation/_legacy/_batch_engine/_result.py +107 -0
- azure/ai/evaluation/_legacy/_batch_engine/_run.py +127 -0
- azure/ai/evaluation/_legacy/_batch_engine/_run_storage.py +128 -0
- azure/ai/evaluation/_legacy/_batch_engine/_run_submitter.py +262 -0
- azure/ai/evaluation/_legacy/_batch_engine/_status.py +25 -0
- azure/ai/evaluation/_legacy/_batch_engine/_trace.py +97 -0
- azure/ai/evaluation/_legacy/_batch_engine/_utils.py +97 -0
- azure/ai/evaluation/_legacy/_batch_engine/_utils_deprecated.py +131 -0
- azure/ai/evaluation/_legacy/_common/__init__.py +3 -0
- azure/ai/evaluation/_legacy/_common/_async_token_provider.py +117 -0
- azure/ai/evaluation/_legacy/_common/_logging.py +292 -0
- azure/ai/evaluation/_legacy/_common/_thread_pool_executor_with_context.py +17 -0
- azure/ai/evaluation/_legacy/prompty/__init__.py +36 -0
- azure/ai/evaluation/_legacy/prompty/_connection.py +119 -0
- azure/ai/evaluation/_legacy/prompty/_exceptions.py +139 -0
- azure/ai/evaluation/_legacy/prompty/_prompty.py +430 -0
- azure/ai/evaluation/_legacy/prompty/_utils.py +663 -0
- azure/ai/evaluation/_legacy/prompty/_yaml_utils.py +99 -0
- azure/ai/evaluation/_model_configurations.py +26 -0
- azure/ai/evaluation/_safety_evaluation/__init__.py +3 -0
- azure/ai/evaluation/_safety_evaluation/_generated_rai_client.py +0 -0
- azure/ai/evaluation/_safety_evaluation/_safety_evaluation.py +917 -0
- azure/ai/evaluation/_user_agent.py +32 -1
- azure/ai/evaluation/_vendor/rouge_score/rouge_scorer.py +0 -4
- azure/ai/evaluation/_vendor/rouge_score/scoring.py +0 -4
- azure/ai/evaluation/_vendor/rouge_score/tokenize.py +0 -4
- azure/ai/evaluation/_version.py +2 -1
- azure/ai/evaluation/red_team/__init__.py +22 -0
- azure/ai/evaluation/red_team/_agent/__init__.py +3 -0
- azure/ai/evaluation/red_team/_agent/_agent_functions.py +261 -0
- azure/ai/evaluation/red_team/_agent/_agent_tools.py +461 -0
- azure/ai/evaluation/red_team/_agent/_agent_utils.py +89 -0
- azure/ai/evaluation/red_team/_agent/_semantic_kernel_plugin.py +228 -0
- azure/ai/evaluation/red_team/_attack_objective_generator.py +268 -0
- azure/ai/evaluation/red_team/_attack_strategy.py +49 -0
- azure/ai/evaluation/red_team/_callback_chat_target.py +115 -0
- azure/ai/evaluation/red_team/_default_converter.py +21 -0
- azure/ai/evaluation/red_team/_evaluation_processor.py +505 -0
- azure/ai/evaluation/red_team/_mlflow_integration.py +430 -0
- azure/ai/evaluation/red_team/_orchestrator_manager.py +803 -0
- azure/ai/evaluation/red_team/_red_team.py +1717 -0
- azure/ai/evaluation/red_team/_red_team_result.py +661 -0
- azure/ai/evaluation/red_team/_result_processor.py +1708 -0
- azure/ai/evaluation/red_team/_utils/__init__.py +37 -0
- azure/ai/evaluation/red_team/_utils/_rai_service_eval_chat_target.py +128 -0
- azure/ai/evaluation/red_team/_utils/_rai_service_target.py +601 -0
- azure/ai/evaluation/red_team/_utils/_rai_service_true_false_scorer.py +114 -0
- azure/ai/evaluation/red_team/_utils/constants.py +72 -0
- azure/ai/evaluation/red_team/_utils/exception_utils.py +345 -0
- azure/ai/evaluation/red_team/_utils/file_utils.py +266 -0
- azure/ai/evaluation/red_team/_utils/formatting_utils.py +365 -0
- azure/ai/evaluation/red_team/_utils/logging_utils.py +139 -0
- azure/ai/evaluation/red_team/_utils/metric_mapping.py +73 -0
- azure/ai/evaluation/red_team/_utils/objective_utils.py +46 -0
- azure/ai/evaluation/red_team/_utils/progress_utils.py +252 -0
- azure/ai/evaluation/red_team/_utils/retry_utils.py +218 -0
- azure/ai/evaluation/red_team/_utils/strategy_utils.py +218 -0
- azure/ai/evaluation/simulator/_adversarial_scenario.py +6 -0
- azure/ai/evaluation/simulator/_adversarial_simulator.py +187 -80
- azure/ai/evaluation/simulator/_constants.py +1 -0
- azure/ai/evaluation/simulator/_conversation/__init__.py +138 -11
- azure/ai/evaluation/simulator/_conversation/_conversation.py +6 -2
- azure/ai/evaluation/simulator/_conversation/constants.py +1 -1
- azure/ai/evaluation/simulator/_direct_attack_simulator.py +37 -24
- azure/ai/evaluation/simulator/_helpers/_language_suffix_mapping.py +1 -0
- azure/ai/evaluation/simulator/_indirect_attack_simulator.py +56 -28
- azure/ai/evaluation/simulator/_model_tools/__init__.py +2 -1
- azure/ai/evaluation/simulator/_model_tools/_generated_rai_client.py +225 -0
- azure/ai/evaluation/simulator/_model_tools/_identity_manager.py +12 -10
- azure/ai/evaluation/simulator/_model_tools/_proxy_completion_model.py +100 -45
- azure/ai/evaluation/simulator/_model_tools/_rai_client.py +101 -3
- azure/ai/evaluation/simulator/_model_tools/_template_handler.py +31 -11
- azure/ai/evaluation/simulator/_model_tools/models.py +20 -17
- azure/ai/evaluation/simulator/_simulator.py +43 -19
- {azure_ai_evaluation-1.0.1.dist-info → azure_ai_evaluation-1.13.5.dist-info}/METADATA +378 -27
- azure_ai_evaluation-1.13.5.dist-info/RECORD +305 -0
- {azure_ai_evaluation-1.0.1.dist-info → azure_ai_evaluation-1.13.5.dist-info}/WHEEL +1 -1
- azure/ai/evaluation/_evaluators/_multimodal/__init__.py +0 -20
- azure/ai/evaluation/_evaluators/_multimodal/_content_safety_multimodal.py +0 -132
- azure/ai/evaluation/_evaluators/_multimodal/_content_safety_multimodal_base.py +0 -55
- azure/ai/evaluation/_evaluators/_multimodal/_hate_unfairness.py +0 -100
- azure/ai/evaluation/_evaluators/_multimodal/_protected_material.py +0 -124
- azure/ai/evaluation/_evaluators/_multimodal/_self_harm.py +0 -100
- azure/ai/evaluation/_evaluators/_multimodal/_sexual.py +0 -100
- azure/ai/evaluation/_evaluators/_multimodal/_violence.py +0 -100
- azure/ai/evaluation/simulator/_tracing.py +0 -89
- azure_ai_evaluation-1.0.1.dist-info/RECORD +0 -119
- {azure_ai_evaluation-1.0.1.dist-info → azure_ai_evaluation-1.13.5.dist-info/licenses}/NOTICE.txt +0 -0
- {azure_ai_evaluation-1.0.1.dist-info → azure_ai_evaluation-1.13.5.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,981 @@
|
|
|
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
|
+
from io import IOBase
|
|
9
|
+
import json
|
|
10
|
+
import sys
|
|
11
|
+
from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, overload
|
|
12
|
+
|
|
13
|
+
from azure.core import AsyncPipelineClient
|
|
14
|
+
from azure.core.exceptions import (
|
|
15
|
+
ClientAuthenticationError,
|
|
16
|
+
HttpResponseError,
|
|
17
|
+
ResourceExistsError,
|
|
18
|
+
ResourceNotFoundError,
|
|
19
|
+
ResourceNotModifiedError,
|
|
20
|
+
StreamClosedError,
|
|
21
|
+
StreamConsumedError,
|
|
22
|
+
map_error,
|
|
23
|
+
)
|
|
24
|
+
from azure.core.pipeline import PipelineResponse
|
|
25
|
+
from azure.core.rest import AsyncHttpResponse, HttpRequest
|
|
26
|
+
from azure.core.tracing.decorator_async import distributed_trace_async
|
|
27
|
+
from azure.core.utils import case_insensitive_dict
|
|
28
|
+
|
|
29
|
+
from ... import models as _models
|
|
30
|
+
from ..._model_base import SdkJSONEncoder, _deserialize
|
|
31
|
+
from ..._serialization import Deserializer, Serializer
|
|
32
|
+
from ...operations._operations import (
|
|
33
|
+
build_rai_svc_get_annotation_request,
|
|
34
|
+
build_rai_svc_get_attack_objectives_request,
|
|
35
|
+
build_rai_svc_get_jail_break_dataset_request,
|
|
36
|
+
build_rai_svc_get_jail_break_dataset_with_type_request,
|
|
37
|
+
build_rai_svc_get_operation_result_request,
|
|
38
|
+
build_rai_svc_get_template_parameters_image_request,
|
|
39
|
+
build_rai_svc_get_template_parameters_request,
|
|
40
|
+
build_rai_svc_get_template_parameters_with_type_request,
|
|
41
|
+
build_rai_svc_submit_annotation_request,
|
|
42
|
+
build_rai_svc_submit_aoai_evaluation_request,
|
|
43
|
+
build_rai_svc_submit_simulation_request,
|
|
44
|
+
)
|
|
45
|
+
from .._configuration import MachineLearningServicesClientConfiguration
|
|
46
|
+
|
|
47
|
+
if sys.version_info >= (3, 9):
|
|
48
|
+
from collections.abc import MutableMapping
|
|
49
|
+
else:
|
|
50
|
+
from typing import MutableMapping # type: ignore
|
|
51
|
+
JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object
|
|
52
|
+
T = TypeVar("T")
|
|
53
|
+
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class RAISvcOperations:
|
|
57
|
+
"""
|
|
58
|
+
.. warning::
|
|
59
|
+
**DO NOT** instantiate this class directly.
|
|
60
|
+
|
|
61
|
+
Instead, you should access the following operations through
|
|
62
|
+
:class:`~raiclient.aio.MachineLearningServicesClient`'s
|
|
63
|
+
:attr:`rai_svc` attribute.
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
67
|
+
input_args = list(args)
|
|
68
|
+
self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
|
|
69
|
+
self._config: MachineLearningServicesClientConfiguration = (
|
|
70
|
+
input_args.pop(0) if input_args else kwargs.pop("config")
|
|
71
|
+
)
|
|
72
|
+
self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
|
|
73
|
+
self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
|
|
74
|
+
|
|
75
|
+
@distributed_trace_async
|
|
76
|
+
async def get_annotation(self, **kwargs: Any) -> List[str]:
|
|
77
|
+
"""Get the supported annotation tasks.
|
|
78
|
+
|
|
79
|
+
:return: list of str
|
|
80
|
+
:rtype: list[str]
|
|
81
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
82
|
+
"""
|
|
83
|
+
error_map: MutableMapping = {
|
|
84
|
+
401: ClientAuthenticationError,
|
|
85
|
+
404: ResourceNotFoundError,
|
|
86
|
+
409: ResourceExistsError,
|
|
87
|
+
304: ResourceNotModifiedError,
|
|
88
|
+
}
|
|
89
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
90
|
+
|
|
91
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
92
|
+
_params = kwargs.pop("params", {}) or {}
|
|
93
|
+
|
|
94
|
+
cls: ClsType[List[str]] = kwargs.pop("cls", None)
|
|
95
|
+
|
|
96
|
+
_request = build_rai_svc_get_annotation_request(
|
|
97
|
+
api_version=self._config.api_version,
|
|
98
|
+
headers=_headers,
|
|
99
|
+
params=_params,
|
|
100
|
+
)
|
|
101
|
+
path_format_arguments = {
|
|
102
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
103
|
+
"subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"),
|
|
104
|
+
"resourceGroupName": self._serialize.url(
|
|
105
|
+
"self._config.resource_group_name", self._config.resource_group_name, "str"
|
|
106
|
+
),
|
|
107
|
+
"workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"),
|
|
108
|
+
}
|
|
109
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
110
|
+
|
|
111
|
+
_stream = kwargs.pop("stream", False)
|
|
112
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
113
|
+
_request, stream=_stream, **kwargs
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
response = pipeline_response.http_response
|
|
117
|
+
|
|
118
|
+
if response.status_code not in [200]:
|
|
119
|
+
if _stream:
|
|
120
|
+
try:
|
|
121
|
+
await response.read() # Load the body in memory and close the socket
|
|
122
|
+
except (StreamConsumedError, StreamClosedError):
|
|
123
|
+
pass
|
|
124
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
125
|
+
raise HttpResponseError(response=response)
|
|
126
|
+
|
|
127
|
+
if _stream:
|
|
128
|
+
deserialized = response.iter_bytes()
|
|
129
|
+
else:
|
|
130
|
+
deserialized = _deserialize(List[str], response.json())
|
|
131
|
+
|
|
132
|
+
if cls:
|
|
133
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
134
|
+
|
|
135
|
+
return deserialized # type: ignore
|
|
136
|
+
|
|
137
|
+
@overload
|
|
138
|
+
async def submit_annotation(
|
|
139
|
+
self, body: _models.AnnotationDTO, *, content_type: str = "application/json", **kwargs: Any
|
|
140
|
+
) -> _models.LongRunningResponse:
|
|
141
|
+
"""Submit a request for annotation.
|
|
142
|
+
|
|
143
|
+
:param body: Properties of a Prompt Version. Required.
|
|
144
|
+
:type body: ~raiclient.models.AnnotationDTO
|
|
145
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
146
|
+
Default value is "application/json".
|
|
147
|
+
:paramtype content_type: str
|
|
148
|
+
:return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
|
|
149
|
+
:rtype: ~raiclient.models.LongRunningResponse
|
|
150
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
151
|
+
"""
|
|
152
|
+
|
|
153
|
+
@overload
|
|
154
|
+
async def submit_annotation(
|
|
155
|
+
self, body: JSON, *, content_type: str = "application/json", **kwargs: Any
|
|
156
|
+
) -> _models.LongRunningResponse:
|
|
157
|
+
"""Submit a request for annotation.
|
|
158
|
+
|
|
159
|
+
:param body: Properties of a Prompt Version. Required.
|
|
160
|
+
:type body: JSON
|
|
161
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
162
|
+
Default value is "application/json".
|
|
163
|
+
:paramtype content_type: str
|
|
164
|
+
:return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
|
|
165
|
+
:rtype: ~raiclient.models.LongRunningResponse
|
|
166
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
167
|
+
"""
|
|
168
|
+
|
|
169
|
+
@overload
|
|
170
|
+
async def submit_annotation(
|
|
171
|
+
self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
|
|
172
|
+
) -> _models.LongRunningResponse:
|
|
173
|
+
"""Submit a request for annotation.
|
|
174
|
+
|
|
175
|
+
:param body: Properties of a Prompt Version. Required.
|
|
176
|
+
:type body: IO[bytes]
|
|
177
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
|
|
178
|
+
Default value is "application/json".
|
|
179
|
+
:paramtype content_type: str
|
|
180
|
+
:return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
|
|
181
|
+
:rtype: ~raiclient.models.LongRunningResponse
|
|
182
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
183
|
+
"""
|
|
184
|
+
|
|
185
|
+
@distributed_trace_async
|
|
186
|
+
async def submit_annotation(
|
|
187
|
+
self, body: Union[_models.AnnotationDTO, JSON, IO[bytes]], **kwargs: Any
|
|
188
|
+
) -> _models.LongRunningResponse:
|
|
189
|
+
"""Submit a request for annotation.
|
|
190
|
+
|
|
191
|
+
:param body: Properties of a Prompt Version. Is one of the following types: AnnotationDTO,
|
|
192
|
+
JSON, IO[bytes] Required.
|
|
193
|
+
:type body: ~raiclient.models.AnnotationDTO or JSON or IO[bytes]
|
|
194
|
+
:return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
|
|
195
|
+
:rtype: ~raiclient.models.LongRunningResponse
|
|
196
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
197
|
+
"""
|
|
198
|
+
error_map: MutableMapping = {
|
|
199
|
+
401: ClientAuthenticationError,
|
|
200
|
+
404: ResourceNotFoundError,
|
|
201
|
+
409: ResourceExistsError,
|
|
202
|
+
304: ResourceNotModifiedError,
|
|
203
|
+
}
|
|
204
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
205
|
+
|
|
206
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
|
207
|
+
_params = kwargs.pop("params", {}) or {}
|
|
208
|
+
|
|
209
|
+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
|
|
210
|
+
cls: ClsType[_models.LongRunningResponse] = kwargs.pop("cls", None)
|
|
211
|
+
|
|
212
|
+
content_type = content_type or "application/json"
|
|
213
|
+
_content = None
|
|
214
|
+
if isinstance(body, (IOBase, bytes)):
|
|
215
|
+
_content = body
|
|
216
|
+
else:
|
|
217
|
+
_content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
|
|
218
|
+
|
|
219
|
+
_request = build_rai_svc_submit_annotation_request(
|
|
220
|
+
content_type=content_type,
|
|
221
|
+
api_version=self._config.api_version,
|
|
222
|
+
content=_content,
|
|
223
|
+
headers=_headers,
|
|
224
|
+
params=_params,
|
|
225
|
+
)
|
|
226
|
+
path_format_arguments = {
|
|
227
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
228
|
+
"subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"),
|
|
229
|
+
"resourceGroupName": self._serialize.url(
|
|
230
|
+
"self._config.resource_group_name", self._config.resource_group_name, "str"
|
|
231
|
+
),
|
|
232
|
+
"workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"),
|
|
233
|
+
}
|
|
234
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
235
|
+
|
|
236
|
+
_stream = kwargs.pop("stream", False)
|
|
237
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
238
|
+
_request, stream=_stream, **kwargs
|
|
239
|
+
)
|
|
240
|
+
|
|
241
|
+
response = pipeline_response.http_response
|
|
242
|
+
|
|
243
|
+
if response.status_code not in [202]:
|
|
244
|
+
if _stream:
|
|
245
|
+
try:
|
|
246
|
+
await response.read() # Load the body in memory and close the socket
|
|
247
|
+
except (StreamConsumedError, StreamClosedError):
|
|
248
|
+
pass
|
|
249
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
250
|
+
raise HttpResponseError(response=response)
|
|
251
|
+
|
|
252
|
+
if _stream:
|
|
253
|
+
deserialized = response.iter_bytes()
|
|
254
|
+
else:
|
|
255
|
+
deserialized = _deserialize(_models.LongRunningResponse, response.json())
|
|
256
|
+
|
|
257
|
+
if cls:
|
|
258
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
259
|
+
|
|
260
|
+
return deserialized # type: ignore
|
|
261
|
+
|
|
262
|
+
@distributed_trace_async
|
|
263
|
+
async def get_jail_break_dataset_with_type(self, type: str, **kwargs: Any) -> List[str]:
|
|
264
|
+
"""Get the jailbreak dataset with type.
|
|
265
|
+
|
|
266
|
+
:param type: Type of jailbreak dataset. Required.
|
|
267
|
+
:type type: str
|
|
268
|
+
:return: list of str
|
|
269
|
+
:rtype: list[str]
|
|
270
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
271
|
+
"""
|
|
272
|
+
error_map: MutableMapping = {
|
|
273
|
+
401: ClientAuthenticationError,
|
|
274
|
+
404: ResourceNotFoundError,
|
|
275
|
+
409: ResourceExistsError,
|
|
276
|
+
304: ResourceNotModifiedError,
|
|
277
|
+
}
|
|
278
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
279
|
+
|
|
280
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
281
|
+
_params = kwargs.pop("params", {}) or {}
|
|
282
|
+
|
|
283
|
+
cls: ClsType[List[str]] = kwargs.pop("cls", None)
|
|
284
|
+
|
|
285
|
+
_request = build_rai_svc_get_jail_break_dataset_with_type_request(
|
|
286
|
+
type=type,
|
|
287
|
+
api_version=self._config.api_version,
|
|
288
|
+
headers=_headers,
|
|
289
|
+
params=_params,
|
|
290
|
+
)
|
|
291
|
+
path_format_arguments = {
|
|
292
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
293
|
+
"subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"),
|
|
294
|
+
"resourceGroupName": self._serialize.url(
|
|
295
|
+
"self._config.resource_group_name", self._config.resource_group_name, "str"
|
|
296
|
+
),
|
|
297
|
+
"workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"),
|
|
298
|
+
}
|
|
299
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
300
|
+
|
|
301
|
+
_stream = kwargs.pop("stream", False)
|
|
302
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
303
|
+
_request, stream=_stream, **kwargs
|
|
304
|
+
)
|
|
305
|
+
|
|
306
|
+
response = pipeline_response.http_response
|
|
307
|
+
|
|
308
|
+
if response.status_code not in [200]:
|
|
309
|
+
if _stream:
|
|
310
|
+
try:
|
|
311
|
+
await response.read() # Load the body in memory and close the socket
|
|
312
|
+
except (StreamConsumedError, StreamClosedError):
|
|
313
|
+
pass
|
|
314
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
315
|
+
raise HttpResponseError(response=response)
|
|
316
|
+
|
|
317
|
+
if _stream:
|
|
318
|
+
deserialized = response.iter_bytes()
|
|
319
|
+
else:
|
|
320
|
+
deserialized = _deserialize(List[str], response.json())
|
|
321
|
+
|
|
322
|
+
if cls:
|
|
323
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
324
|
+
|
|
325
|
+
return deserialized # type: ignore
|
|
326
|
+
|
|
327
|
+
@distributed_trace_async
|
|
328
|
+
async def get_attack_objectives(
|
|
329
|
+
self,
|
|
330
|
+
*,
|
|
331
|
+
risk_types: Optional[List[str]] = None,
|
|
332
|
+
lang: Optional[str] = None,
|
|
333
|
+
strategy: Optional[str] = None,
|
|
334
|
+
**kwargs: Any
|
|
335
|
+
) -> List[_models.AttackObjective]:
|
|
336
|
+
"""Get the attack objectives.
|
|
337
|
+
|
|
338
|
+
:keyword risk_types: Risk types for the attack objectives dataset. Default value is None.
|
|
339
|
+
:paramtype risk_types: list[str]
|
|
340
|
+
:keyword lang: The language for the attack objectives dataset, defaults to 'en'. Default value
|
|
341
|
+
is None.
|
|
342
|
+
:paramtype lang: str
|
|
343
|
+
:keyword strategy: The strategy. Default value is None.
|
|
344
|
+
:paramtype strategy: str
|
|
345
|
+
:return: list of AttackObjective
|
|
346
|
+
:rtype: list[~raiclient.models.AttackObjective]
|
|
347
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
348
|
+
"""
|
|
349
|
+
error_map: MutableMapping = {
|
|
350
|
+
401: ClientAuthenticationError,
|
|
351
|
+
404: ResourceNotFoundError,
|
|
352
|
+
409: ResourceExistsError,
|
|
353
|
+
304: ResourceNotModifiedError,
|
|
354
|
+
}
|
|
355
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
356
|
+
|
|
357
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
358
|
+
_params = kwargs.pop("params", {}) or {}
|
|
359
|
+
|
|
360
|
+
cls: ClsType[List[_models.AttackObjective]] = kwargs.pop("cls", None)
|
|
361
|
+
|
|
362
|
+
_request = build_rai_svc_get_attack_objectives_request(
|
|
363
|
+
risk_types=risk_types,
|
|
364
|
+
lang=lang,
|
|
365
|
+
strategy=strategy,
|
|
366
|
+
api_version=self._config.api_version,
|
|
367
|
+
headers=_headers,
|
|
368
|
+
params=_params,
|
|
369
|
+
)
|
|
370
|
+
path_format_arguments = {
|
|
371
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
372
|
+
"subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"),
|
|
373
|
+
"resourceGroupName": self._serialize.url(
|
|
374
|
+
"self._config.resource_group_name", self._config.resource_group_name, "str"
|
|
375
|
+
),
|
|
376
|
+
"workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"),
|
|
377
|
+
}
|
|
378
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
379
|
+
|
|
380
|
+
_stream = kwargs.pop("stream", False)
|
|
381
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
382
|
+
_request, stream=_stream, **kwargs
|
|
383
|
+
)
|
|
384
|
+
|
|
385
|
+
response = pipeline_response.http_response
|
|
386
|
+
|
|
387
|
+
if response.status_code not in [200]:
|
|
388
|
+
if _stream:
|
|
389
|
+
try:
|
|
390
|
+
await response.read() # Load the body in memory and close the socket
|
|
391
|
+
except (StreamConsumedError, StreamClosedError):
|
|
392
|
+
pass
|
|
393
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
394
|
+
raise HttpResponseError(response=response)
|
|
395
|
+
|
|
396
|
+
if _stream:
|
|
397
|
+
deserialized = response.iter_bytes()
|
|
398
|
+
else:
|
|
399
|
+
deserialized = _deserialize(List[_models.AttackObjective], response.json())
|
|
400
|
+
|
|
401
|
+
if cls:
|
|
402
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
403
|
+
|
|
404
|
+
return deserialized # type: ignore
|
|
405
|
+
|
|
406
|
+
@distributed_trace_async
|
|
407
|
+
async def get_jail_break_dataset(self, **kwargs: Any) -> List[str]:
|
|
408
|
+
"""Get the jailbreak dataset.
|
|
409
|
+
|
|
410
|
+
:return: list of str
|
|
411
|
+
:rtype: list[str]
|
|
412
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
413
|
+
"""
|
|
414
|
+
error_map: MutableMapping = {
|
|
415
|
+
401: ClientAuthenticationError,
|
|
416
|
+
404: ResourceNotFoundError,
|
|
417
|
+
409: ResourceExistsError,
|
|
418
|
+
304: ResourceNotModifiedError,
|
|
419
|
+
}
|
|
420
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
421
|
+
|
|
422
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
423
|
+
_params = kwargs.pop("params", {}) or {}
|
|
424
|
+
|
|
425
|
+
cls: ClsType[List[str]] = kwargs.pop("cls", None)
|
|
426
|
+
|
|
427
|
+
_request = build_rai_svc_get_jail_break_dataset_request(
|
|
428
|
+
api_version=self._config.api_version,
|
|
429
|
+
headers=_headers,
|
|
430
|
+
params=_params,
|
|
431
|
+
)
|
|
432
|
+
path_format_arguments = {
|
|
433
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
434
|
+
"subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"),
|
|
435
|
+
"resourceGroupName": self._serialize.url(
|
|
436
|
+
"self._config.resource_group_name", self._config.resource_group_name, "str"
|
|
437
|
+
),
|
|
438
|
+
"workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"),
|
|
439
|
+
}
|
|
440
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
441
|
+
|
|
442
|
+
_stream = kwargs.pop("stream", False)
|
|
443
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
444
|
+
_request, stream=_stream, **kwargs
|
|
445
|
+
)
|
|
446
|
+
|
|
447
|
+
response = pipeline_response.http_response
|
|
448
|
+
|
|
449
|
+
if response.status_code not in [200]:
|
|
450
|
+
if _stream:
|
|
451
|
+
try:
|
|
452
|
+
await response.read() # Load the body in memory and close the socket
|
|
453
|
+
except (StreamConsumedError, StreamClosedError):
|
|
454
|
+
pass
|
|
455
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
456
|
+
raise HttpResponseError(response=response)
|
|
457
|
+
|
|
458
|
+
if _stream:
|
|
459
|
+
deserialized = response.iter_bytes()
|
|
460
|
+
else:
|
|
461
|
+
deserialized = _deserialize(List[str], response.json())
|
|
462
|
+
|
|
463
|
+
if cls:
|
|
464
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
465
|
+
|
|
466
|
+
return deserialized # type: ignore
|
|
467
|
+
|
|
468
|
+
@distributed_trace_async
|
|
469
|
+
async def get_template_parameters_with_type(self, type: str, **kwargs: Any) -> str:
|
|
470
|
+
"""Get template parameters with type.
|
|
471
|
+
|
|
472
|
+
:param type: Type for the template parameters. Required.
|
|
473
|
+
:type type: str
|
|
474
|
+
:return: str
|
|
475
|
+
:rtype: str
|
|
476
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
477
|
+
"""
|
|
478
|
+
error_map: MutableMapping = {
|
|
479
|
+
401: ClientAuthenticationError,
|
|
480
|
+
404: ResourceNotFoundError,
|
|
481
|
+
409: ResourceExistsError,
|
|
482
|
+
304: ResourceNotModifiedError,
|
|
483
|
+
}
|
|
484
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
485
|
+
|
|
486
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
487
|
+
_params = kwargs.pop("params", {}) or {}
|
|
488
|
+
|
|
489
|
+
cls: ClsType[str] = kwargs.pop("cls", None)
|
|
490
|
+
|
|
491
|
+
_request = build_rai_svc_get_template_parameters_with_type_request(
|
|
492
|
+
type=type,
|
|
493
|
+
api_version=self._config.api_version,
|
|
494
|
+
headers=_headers,
|
|
495
|
+
params=_params,
|
|
496
|
+
)
|
|
497
|
+
path_format_arguments = {
|
|
498
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
499
|
+
"subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"),
|
|
500
|
+
"resourceGroupName": self._serialize.url(
|
|
501
|
+
"self._config.resource_group_name", self._config.resource_group_name, "str"
|
|
502
|
+
),
|
|
503
|
+
"workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"),
|
|
504
|
+
}
|
|
505
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
506
|
+
|
|
507
|
+
_stream = kwargs.pop("stream", False)
|
|
508
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
509
|
+
_request, stream=_stream, **kwargs
|
|
510
|
+
)
|
|
511
|
+
|
|
512
|
+
response = pipeline_response.http_response
|
|
513
|
+
|
|
514
|
+
if response.status_code not in [200]:
|
|
515
|
+
if _stream:
|
|
516
|
+
try:
|
|
517
|
+
await response.read() # Load the body in memory and close the socket
|
|
518
|
+
except (StreamConsumedError, StreamClosedError):
|
|
519
|
+
pass
|
|
520
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
521
|
+
raise HttpResponseError(response=response)
|
|
522
|
+
|
|
523
|
+
if _stream:
|
|
524
|
+
deserialized = response.iter_bytes()
|
|
525
|
+
else:
|
|
526
|
+
deserialized = _deserialize(str, response.json())
|
|
527
|
+
|
|
528
|
+
if cls:
|
|
529
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
530
|
+
|
|
531
|
+
return deserialized # type: ignore
|
|
532
|
+
|
|
533
|
+
@distributed_trace_async
|
|
534
|
+
async def get_template_parameters(self, **kwargs: Any) -> str:
|
|
535
|
+
"""Get template parameters.
|
|
536
|
+
|
|
537
|
+
:return: str
|
|
538
|
+
:rtype: str
|
|
539
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
540
|
+
"""
|
|
541
|
+
error_map: MutableMapping = {
|
|
542
|
+
401: ClientAuthenticationError,
|
|
543
|
+
404: ResourceNotFoundError,
|
|
544
|
+
409: ResourceExistsError,
|
|
545
|
+
304: ResourceNotModifiedError,
|
|
546
|
+
}
|
|
547
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
548
|
+
|
|
549
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
550
|
+
_params = kwargs.pop("params", {}) or {}
|
|
551
|
+
|
|
552
|
+
cls: ClsType[str] = kwargs.pop("cls", None)
|
|
553
|
+
|
|
554
|
+
_request = build_rai_svc_get_template_parameters_request(
|
|
555
|
+
api_version=self._config.api_version,
|
|
556
|
+
headers=_headers,
|
|
557
|
+
params=_params,
|
|
558
|
+
)
|
|
559
|
+
path_format_arguments = {
|
|
560
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
561
|
+
"subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"),
|
|
562
|
+
"resourceGroupName": self._serialize.url(
|
|
563
|
+
"self._config.resource_group_name", self._config.resource_group_name, "str"
|
|
564
|
+
),
|
|
565
|
+
"workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"),
|
|
566
|
+
}
|
|
567
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
568
|
+
|
|
569
|
+
_stream = kwargs.pop("stream", False)
|
|
570
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
571
|
+
_request, stream=_stream, **kwargs
|
|
572
|
+
)
|
|
573
|
+
|
|
574
|
+
response = pipeline_response.http_response
|
|
575
|
+
|
|
576
|
+
if response.status_code not in [200]:
|
|
577
|
+
if _stream:
|
|
578
|
+
try:
|
|
579
|
+
await response.read() # Load the body in memory and close the socket
|
|
580
|
+
except (StreamConsumedError, StreamClosedError):
|
|
581
|
+
pass
|
|
582
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
583
|
+
raise HttpResponseError(response=response)
|
|
584
|
+
|
|
585
|
+
if _stream:
|
|
586
|
+
deserialized = response.iter_bytes()
|
|
587
|
+
else:
|
|
588
|
+
deserialized = _deserialize(str, response.json())
|
|
589
|
+
|
|
590
|
+
if cls:
|
|
591
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
592
|
+
|
|
593
|
+
return deserialized # type: ignore
|
|
594
|
+
|
|
595
|
+
@distributed_trace_async
|
|
596
|
+
async def get_template_parameters_image(self, *, path: str, **kwargs: Any) -> str:
|
|
597
|
+
"""Get the template parameters image.
|
|
598
|
+
|
|
599
|
+
:keyword path: Image path. Required.
|
|
600
|
+
:paramtype path: str
|
|
601
|
+
:return: str
|
|
602
|
+
:rtype: str
|
|
603
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
604
|
+
"""
|
|
605
|
+
error_map: MutableMapping = {
|
|
606
|
+
401: ClientAuthenticationError,
|
|
607
|
+
404: ResourceNotFoundError,
|
|
608
|
+
409: ResourceExistsError,
|
|
609
|
+
304: ResourceNotModifiedError,
|
|
610
|
+
}
|
|
611
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
612
|
+
|
|
613
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
614
|
+
_params = kwargs.pop("params", {}) or {}
|
|
615
|
+
|
|
616
|
+
cls: ClsType[str] = kwargs.pop("cls", None)
|
|
617
|
+
|
|
618
|
+
_request = build_rai_svc_get_template_parameters_image_request(
|
|
619
|
+
path=path,
|
|
620
|
+
api_version=self._config.api_version,
|
|
621
|
+
headers=_headers,
|
|
622
|
+
params=_params,
|
|
623
|
+
)
|
|
624
|
+
path_format_arguments = {
|
|
625
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
626
|
+
"subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"),
|
|
627
|
+
"resourceGroupName": self._serialize.url(
|
|
628
|
+
"self._config.resource_group_name", self._config.resource_group_name, "str"
|
|
629
|
+
),
|
|
630
|
+
"workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"),
|
|
631
|
+
}
|
|
632
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
633
|
+
|
|
634
|
+
_stream = kwargs.pop("stream", False)
|
|
635
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
636
|
+
_request, stream=_stream, **kwargs
|
|
637
|
+
)
|
|
638
|
+
|
|
639
|
+
response = pipeline_response.http_response
|
|
640
|
+
|
|
641
|
+
if response.status_code not in [200]:
|
|
642
|
+
if _stream:
|
|
643
|
+
try:
|
|
644
|
+
await response.read() # Load the body in memory and close the socket
|
|
645
|
+
except (StreamConsumedError, StreamClosedError):
|
|
646
|
+
pass
|
|
647
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
648
|
+
raise HttpResponseError(response=response)
|
|
649
|
+
|
|
650
|
+
if _stream:
|
|
651
|
+
deserialized = response.iter_bytes()
|
|
652
|
+
else:
|
|
653
|
+
deserialized = _deserialize(str, response.json())
|
|
654
|
+
|
|
655
|
+
if cls:
|
|
656
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
657
|
+
|
|
658
|
+
return deserialized # type: ignore
|
|
659
|
+
|
|
660
|
+
@overload
|
|
661
|
+
async def submit_simulation(
|
|
662
|
+
self, body: _models.SimulationDTO, *, content_type: str = "application/json", **kwargs: Any
|
|
663
|
+
) -> _models.LongRunningResponse:
|
|
664
|
+
"""Submit a request for simulation.
|
|
665
|
+
|
|
666
|
+
:param body: Properties of a Prompt Version. Required.
|
|
667
|
+
:type body: ~raiclient.models.SimulationDTO
|
|
668
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
669
|
+
Default value is "application/json".
|
|
670
|
+
:paramtype content_type: str
|
|
671
|
+
:return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
|
|
672
|
+
:rtype: ~raiclient.models.LongRunningResponse
|
|
673
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
674
|
+
"""
|
|
675
|
+
|
|
676
|
+
@overload
|
|
677
|
+
async def submit_simulation(
|
|
678
|
+
self, body: JSON, *, content_type: str = "application/json", **kwargs: Any
|
|
679
|
+
) -> _models.LongRunningResponse:
|
|
680
|
+
"""Submit a request for simulation.
|
|
681
|
+
|
|
682
|
+
:param body: Properties of a Prompt Version. Required.
|
|
683
|
+
:type body: JSON
|
|
684
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
685
|
+
Default value is "application/json".
|
|
686
|
+
:paramtype content_type: str
|
|
687
|
+
:return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
|
|
688
|
+
:rtype: ~raiclient.models.LongRunningResponse
|
|
689
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
690
|
+
"""
|
|
691
|
+
|
|
692
|
+
@overload
|
|
693
|
+
async def submit_simulation(
|
|
694
|
+
self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
|
|
695
|
+
) -> _models.LongRunningResponse:
|
|
696
|
+
"""Submit a request for simulation.
|
|
697
|
+
|
|
698
|
+
:param body: Properties of a Prompt Version. Required.
|
|
699
|
+
:type body: IO[bytes]
|
|
700
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
|
|
701
|
+
Default value is "application/json".
|
|
702
|
+
:paramtype content_type: str
|
|
703
|
+
:return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
|
|
704
|
+
:rtype: ~raiclient.models.LongRunningResponse
|
|
705
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
706
|
+
"""
|
|
707
|
+
|
|
708
|
+
@distributed_trace_async
|
|
709
|
+
async def submit_simulation(
|
|
710
|
+
self, body: Union[_models.SimulationDTO, JSON, IO[bytes]], **kwargs: Any
|
|
711
|
+
) -> _models.LongRunningResponse:
|
|
712
|
+
"""Submit a request for simulation.
|
|
713
|
+
|
|
714
|
+
:param body: Properties of a Prompt Version. Is one of the following types: SimulationDTO,
|
|
715
|
+
JSON, IO[bytes] Required.
|
|
716
|
+
:type body: ~raiclient.models.SimulationDTO or JSON or IO[bytes]
|
|
717
|
+
:return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
|
|
718
|
+
:rtype: ~raiclient.models.LongRunningResponse
|
|
719
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
720
|
+
"""
|
|
721
|
+
error_map: MutableMapping = {
|
|
722
|
+
401: ClientAuthenticationError,
|
|
723
|
+
404: ResourceNotFoundError,
|
|
724
|
+
409: ResourceExistsError,
|
|
725
|
+
304: ResourceNotModifiedError,
|
|
726
|
+
}
|
|
727
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
728
|
+
|
|
729
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
|
730
|
+
_params = kwargs.pop("params", {}) or {}
|
|
731
|
+
|
|
732
|
+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
|
|
733
|
+
cls: ClsType[_models.LongRunningResponse] = kwargs.pop("cls", None)
|
|
734
|
+
|
|
735
|
+
content_type = content_type or "application/json"
|
|
736
|
+
_content = None
|
|
737
|
+
if isinstance(body, (IOBase, bytes)):
|
|
738
|
+
_content = body
|
|
739
|
+
else:
|
|
740
|
+
_content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
|
|
741
|
+
|
|
742
|
+
_request = build_rai_svc_submit_simulation_request(
|
|
743
|
+
content_type=content_type,
|
|
744
|
+
api_version=self._config.api_version,
|
|
745
|
+
content=_content,
|
|
746
|
+
headers=_headers,
|
|
747
|
+
params=_params,
|
|
748
|
+
)
|
|
749
|
+
path_format_arguments = {
|
|
750
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
751
|
+
"subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"),
|
|
752
|
+
"resourceGroupName": self._serialize.url(
|
|
753
|
+
"self._config.resource_group_name", self._config.resource_group_name, "str"
|
|
754
|
+
),
|
|
755
|
+
"workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"),
|
|
756
|
+
}
|
|
757
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
758
|
+
|
|
759
|
+
_stream = kwargs.pop("stream", False)
|
|
760
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
761
|
+
_request, stream=_stream, **kwargs
|
|
762
|
+
)
|
|
763
|
+
|
|
764
|
+
response = pipeline_response.http_response
|
|
765
|
+
|
|
766
|
+
if response.status_code not in [202]:
|
|
767
|
+
if _stream:
|
|
768
|
+
try:
|
|
769
|
+
await response.read() # Load the body in memory and close the socket
|
|
770
|
+
except (StreamConsumedError, StreamClosedError):
|
|
771
|
+
pass
|
|
772
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
773
|
+
raise HttpResponseError(response=response)
|
|
774
|
+
|
|
775
|
+
if _stream:
|
|
776
|
+
deserialized = response.iter_bytes()
|
|
777
|
+
else:
|
|
778
|
+
deserialized = _deserialize(_models.LongRunningResponse, response.json())
|
|
779
|
+
|
|
780
|
+
if cls:
|
|
781
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
782
|
+
|
|
783
|
+
return deserialized # type: ignore
|
|
784
|
+
|
|
785
|
+
@overload
|
|
786
|
+
async def submit_aoai_evaluation(
|
|
787
|
+
self, body: _models.GradersDTO, *, content_type: str = "application/json", **kwargs: Any
|
|
788
|
+
) -> _models.LongRunningResponse:
|
|
789
|
+
"""Submit a request for graders.
|
|
790
|
+
|
|
791
|
+
:param body: Properties of a Prompt Version. Required.
|
|
792
|
+
:type body: ~raiclient.models.GradersDTO
|
|
793
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
794
|
+
Default value is "application/json".
|
|
795
|
+
:paramtype content_type: str
|
|
796
|
+
:return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
|
|
797
|
+
:rtype: ~raiclient.models.LongRunningResponse
|
|
798
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
799
|
+
"""
|
|
800
|
+
|
|
801
|
+
@overload
|
|
802
|
+
async def submit_aoai_evaluation(
|
|
803
|
+
self, body: JSON, *, content_type: str = "application/json", **kwargs: Any
|
|
804
|
+
) -> _models.LongRunningResponse:
|
|
805
|
+
"""Submit a request for graders.
|
|
806
|
+
|
|
807
|
+
:param body: Properties of a Prompt Version. Required.
|
|
808
|
+
:type body: JSON
|
|
809
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
810
|
+
Default value is "application/json".
|
|
811
|
+
:paramtype content_type: str
|
|
812
|
+
:return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
|
|
813
|
+
:rtype: ~raiclient.models.LongRunningResponse
|
|
814
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
815
|
+
"""
|
|
816
|
+
|
|
817
|
+
@overload
|
|
818
|
+
async def submit_aoai_evaluation(
|
|
819
|
+
self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
|
|
820
|
+
) -> _models.LongRunningResponse:
|
|
821
|
+
"""Submit a request for graders.
|
|
822
|
+
|
|
823
|
+
:param body: Properties of a Prompt Version. Required.
|
|
824
|
+
:type body: IO[bytes]
|
|
825
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
|
|
826
|
+
Default value is "application/json".
|
|
827
|
+
:paramtype content_type: str
|
|
828
|
+
:return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
|
|
829
|
+
:rtype: ~raiclient.models.LongRunningResponse
|
|
830
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
831
|
+
"""
|
|
832
|
+
|
|
833
|
+
@distributed_trace_async
|
|
834
|
+
async def submit_aoai_evaluation(
|
|
835
|
+
self, body: Union[_models.GradersDTO, JSON, IO[bytes]], **kwargs: Any
|
|
836
|
+
) -> _models.LongRunningResponse:
|
|
837
|
+
"""Submit a request for graders.
|
|
838
|
+
|
|
839
|
+
:param body: Properties of a Prompt Version. Is one of the following types: GradersDTO, JSON,
|
|
840
|
+
IO[bytes] Required.
|
|
841
|
+
:type body: ~raiclient.models.GradersDTO or JSON or IO[bytes]
|
|
842
|
+
:return: LongRunningResponse. The LongRunningResponse is compatible with MutableMapping
|
|
843
|
+
:rtype: ~raiclient.models.LongRunningResponse
|
|
844
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
845
|
+
"""
|
|
846
|
+
error_map: MutableMapping = {
|
|
847
|
+
401: ClientAuthenticationError,
|
|
848
|
+
404: ResourceNotFoundError,
|
|
849
|
+
409: ResourceExistsError,
|
|
850
|
+
304: ResourceNotModifiedError,
|
|
851
|
+
}
|
|
852
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
853
|
+
|
|
854
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
|
855
|
+
_params = kwargs.pop("params", {}) or {}
|
|
856
|
+
|
|
857
|
+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
|
|
858
|
+
cls: ClsType[_models.LongRunningResponse] = kwargs.pop("cls", None)
|
|
859
|
+
|
|
860
|
+
content_type = content_type or "application/json"
|
|
861
|
+
_content = None
|
|
862
|
+
if isinstance(body, (IOBase, bytes)):
|
|
863
|
+
_content = body
|
|
864
|
+
else:
|
|
865
|
+
_content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
|
|
866
|
+
|
|
867
|
+
_request = build_rai_svc_submit_aoai_evaluation_request(
|
|
868
|
+
content_type=content_type,
|
|
869
|
+
api_version=self._config.api_version,
|
|
870
|
+
content=_content,
|
|
871
|
+
headers=_headers,
|
|
872
|
+
params=_params,
|
|
873
|
+
)
|
|
874
|
+
path_format_arguments = {
|
|
875
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
876
|
+
"subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"),
|
|
877
|
+
"resourceGroupName": self._serialize.url(
|
|
878
|
+
"self._config.resource_group_name", self._config.resource_group_name, "str"
|
|
879
|
+
),
|
|
880
|
+
"workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"),
|
|
881
|
+
}
|
|
882
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
883
|
+
|
|
884
|
+
_stream = kwargs.pop("stream", False)
|
|
885
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
886
|
+
_request, stream=_stream, **kwargs
|
|
887
|
+
)
|
|
888
|
+
|
|
889
|
+
response = pipeline_response.http_response
|
|
890
|
+
|
|
891
|
+
if response.status_code not in [202]:
|
|
892
|
+
if _stream:
|
|
893
|
+
try:
|
|
894
|
+
await response.read() # Load the body in memory and close the socket
|
|
895
|
+
except (StreamConsumedError, StreamClosedError):
|
|
896
|
+
pass
|
|
897
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
898
|
+
raise HttpResponseError(response=response)
|
|
899
|
+
|
|
900
|
+
if _stream:
|
|
901
|
+
deserialized = response.iter_bytes()
|
|
902
|
+
else:
|
|
903
|
+
deserialized = _deserialize(_models.LongRunningResponse, response.json())
|
|
904
|
+
|
|
905
|
+
if cls:
|
|
906
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
907
|
+
|
|
908
|
+
return deserialized # type: ignore
|
|
909
|
+
|
|
910
|
+
@distributed_trace_async
|
|
911
|
+
async def get_operation_result(
|
|
912
|
+
self, operation_id: str, *, api_key: Optional[str] = None, model_endpoint: Optional[str] = None, **kwargs: Any
|
|
913
|
+
) -> str:
|
|
914
|
+
"""Get the operation result.
|
|
915
|
+
|
|
916
|
+
:param operation_id: Operation id. Required.
|
|
917
|
+
:type operation_id: str
|
|
918
|
+
:keyword api_key: Api key. Default value is None.
|
|
919
|
+
:paramtype api_key: str
|
|
920
|
+
:keyword model_endpoint: Model Endpoint. Default value is None.
|
|
921
|
+
:paramtype model_endpoint: str
|
|
922
|
+
:return: str
|
|
923
|
+
:rtype: str
|
|
924
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
925
|
+
"""
|
|
926
|
+
error_map: MutableMapping = {
|
|
927
|
+
401: ClientAuthenticationError,
|
|
928
|
+
404: ResourceNotFoundError,
|
|
929
|
+
409: ResourceExistsError,
|
|
930
|
+
304: ResourceNotModifiedError,
|
|
931
|
+
}
|
|
932
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
933
|
+
|
|
934
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
935
|
+
_params = kwargs.pop("params", {}) or {}
|
|
936
|
+
|
|
937
|
+
cls: ClsType[str] = kwargs.pop("cls", None)
|
|
938
|
+
|
|
939
|
+
_request = build_rai_svc_get_operation_result_request(
|
|
940
|
+
operation_id=operation_id,
|
|
941
|
+
api_key=api_key,
|
|
942
|
+
model_endpoint=model_endpoint,
|
|
943
|
+
api_version=self._config.api_version,
|
|
944
|
+
headers=_headers,
|
|
945
|
+
params=_params,
|
|
946
|
+
)
|
|
947
|
+
path_format_arguments = {
|
|
948
|
+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
|
|
949
|
+
"subscriptionId": self._serialize.url("self._config.subscription_id", self._config.subscription_id, "str"),
|
|
950
|
+
"resourceGroupName": self._serialize.url(
|
|
951
|
+
"self._config.resource_group_name", self._config.resource_group_name, "str"
|
|
952
|
+
),
|
|
953
|
+
"workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"),
|
|
954
|
+
}
|
|
955
|
+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
|
|
956
|
+
|
|
957
|
+
_stream = kwargs.pop("stream", False)
|
|
958
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
|
|
959
|
+
_request, stream=_stream, **kwargs
|
|
960
|
+
)
|
|
961
|
+
|
|
962
|
+
response = pipeline_response.http_response
|
|
963
|
+
|
|
964
|
+
if response.status_code not in [200]:
|
|
965
|
+
if _stream:
|
|
966
|
+
try:
|
|
967
|
+
await response.read() # Load the body in memory and close the socket
|
|
968
|
+
except (StreamConsumedError, StreamClosedError):
|
|
969
|
+
pass
|
|
970
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
|
971
|
+
raise HttpResponseError(response=response)
|
|
972
|
+
|
|
973
|
+
if _stream:
|
|
974
|
+
deserialized = response.iter_bytes()
|
|
975
|
+
else:
|
|
976
|
+
deserialized = _deserialize(str, response.json())
|
|
977
|
+
|
|
978
|
+
if cls:
|
|
979
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
|
980
|
+
|
|
981
|
+
return deserialized # type: ignore
|