77from azure .core .credentials import AzureKeyCredential , TokenCredential
88from azure .ai .evaluation ._common .onedp import AIProjectClient as RestEvaluationServiceClient
99from azure .ai .evaluation ._common .onedp .models import (PendingUploadRequest , PendingUploadType , EvaluationResult ,
10- ResultType , AssetCredentialRequest , EvaluationUpload , InputDataset )
10+ ResultType , AssetCredentialRequest , EvaluationUpload , InputDataset , RedTeamUpload )
1111from azure .storage .blob import ContainerClient
1212from .utils import upload
1313
@@ -22,7 +22,8 @@ def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCr
2222 ** kwargs ,
2323 )
2424
25- def create_evaluation_result (self , * , name : str , path : str , version = 1 , metrics : Dict [str , int ]= None , ** kwargs ) -> EvaluationResult :
25+ def create_evaluation_result (
26+ self , * , name : str , path : str , version = 1 , metrics : Dict [str , int ]= None , result_type : ResultType = ResultType .EVALUATION , ** kwargs ) -> EvaluationResult :
2627 """Create and upload evaluation results to Azure evaluation service.
2728
2829 This method uploads evaluation results from a local path to Azure Blob Storage
@@ -39,14 +40,16 @@ def create_evaluation_result(self, *, name: str, path: str, version=1, metrics:
3940 :param version: The version number for the evaluation results, defaults to 1
4041 :type version: int, optional
4142 :param metrics: Metrics to be added to evaluation result
42- :type version: Dict[str, int], optional
43+ :type metrics: Dict[str, int], optional
44+ :param result_type: Evaluation Result Type to create
45+ :type result_type: ResultType, optional
4346 :param kwargs: Additional keyword arguments to pass to the underlying API calls
4447 :return: The response from creating the evaluation result version
4548 :rtype: EvaluationResult
4649 :raises: Various exceptions from the underlying API calls or upload process
4750 """
4851
49- LOGGER .debug (f"Creating evaluation result for { name } with version { version } from path { path } " )
52+ LOGGER .debug (f"Creating evaluation result for { name } with version { version } type { result_type } from path { path } " )
5053 start_pending_upload_response = self .rest_client .evaluation_results .start_pending_upload (
5154 name = name ,
5255 version = version ,
@@ -63,7 +66,7 @@ def create_evaluation_result(self, *, name: str, path: str, version=1, metrics:
6366 create_version_response = self .rest_client .evaluation_results .create_or_update_version (
6467 body = EvaluationResult (
6568 blob_uri = start_pending_upload_response .blob_reference_for_consumption .blob_uri ,
66- result_type = ResultType . EVALUATION ,
69+ result_type = result_type ,
6770 name = name ,
6871 version = version ,
6972 metrics = metrics ,
@@ -115,4 +118,46 @@ def update_evaluation_run(self, *, name: str, evaluation: EvaluationUpload, **kw
115118 ** kwargs
116119 )
117120
121+ return update_run_response
122+
123+ def start_red_team_run (self , * , red_team : RedTeamUpload , ** kwargs ):
124+ """Start a new red team run in the Azure evaluation service.
125+
126+ This method creates a new red team run with the provided configuration details.
127+
128+ :param red_team: The red team configuration to upload
129+ :type red_team: ~azure.ai.evaluation._common.onedp.models.RedTeamUpload
130+ :param kwargs: Additional keyword arguments to pass to the underlying API calls
131+ :return: The created red team run object
132+ :rtype: ~azure.ai.evaluation._common.onedp.models.RedTeamUpload
133+ :raises: Various exceptions from the underlying API calls
134+ """
135+ upload_run_response = self .rest_client .red_teams .upload_run (
136+ redteam = red_team ,
137+ ** kwargs
138+ )
139+
140+ return upload_run_response
141+
142+ def update_red_team_run (self , * , name : str , red_team : RedTeamUpload , ** kwargs ):
143+ """Update an existing red team run in the Azure evaluation service.
144+
145+ This method updates a red team run with new information such as status changes,
146+ result references, or other metadata.
147+
148+ :param name: The identifier of the red team run to update
149+ :type name: str
150+ :param red_team: The updated red team configuration
151+ :type red_team: ~azure.ai.evaluation._common.onedp.models.RedTeamUpload
152+ :param kwargs: Additional keyword arguments to pass to the underlying API calls
153+ :return: The updated red team run object
154+ :rtype: ~azure.ai.evaluation._common.onedp.models.RedTeamUpload
155+ :raises: Various exceptions from the underlying API calls
156+ """
157+ update_run_response = self .rest_client .red_teams .upload_update_run (
158+ name = name ,
159+ redteam = red_team ,
160+ ** kwargs
161+ )
162+
118163 return update_run_response
0 commit comments