diff --git a/sdk/ai/azure-ai-client/azure/ai/client/_client.py b/sdk/ai/azure-ai-client/azure/ai/client/_client.py index bd5efc4521b1..39545e19ad8d 100644 --- a/sdk/ai/azure-ai-client/azure/ai/client/_client.py +++ b/sdk/ai/azure-ai-client/azure/ai/client/_client.py @@ -41,8 +41,8 @@ class AzureAIClient: :type subscription_id: str :param resource_group_name: The name of the Azure Resource Group. Required. :type resource_group_name: str - :param workspace_name: The name of the Azure AI Studio hub. Required. - :type workspace_name: str + :param project_name: The Azure AI Studio project name. Required. + :type project_name: str :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential :keyword api_version: The API version to use for this operation. Default value is @@ -56,16 +56,16 @@ def __init__( endpoint: str, subscription_id: str, resource_group_name: str, - workspace_name: str, + project_name: str, credential: "TokenCredential", **kwargs: Any ) -> None: - _endpoint = "{endpoint}/{subscriptionId}/{resourceGroupName}/{workspaceName}" + _endpoint = "{endpoint}/{subscriptionId}/{resourceGroupName}/{projectName}" self._config = AzureAIClientConfiguration( endpoint=endpoint, subscription_id=subscription_id, resource_group_name=resource_group_name, - workspace_name=workspace_name, + project_name=project_name, credential=credential, **kwargs ) @@ -120,7 +120,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/sdk/ai/azure-ai-client/azure/ai/client/_configuration.py b/sdk/ai/azure-ai-client/azure/ai/client/_configuration.py index ee10b245b611..dde212466722 100644 --- a/sdk/ai/azure-ai-client/azure/ai/client/_configuration.py +++ b/sdk/ai/azure-ai-client/azure/ai/client/_configuration.py @@ -32,8 +32,8 @@ class AzureAIClientConfiguration: # pylint: disable=too-many-instance-attribute :type subscription_id: str :param resource_group_name: The name of the Azure Resource Group. Required. :type resource_group_name: str - :param workspace_name: The name of the Azure AI Studio hub. Required. - :type workspace_name: str + :param project_name: The Azure AI Studio project name. Required. + :type project_name: str :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential :keyword api_version: The API version to use for this operation. Default value is @@ -47,7 +47,7 @@ def __init__( endpoint: str, subscription_id: str, resource_group_name: str, - workspace_name: str, + project_name: str, credential: "TokenCredential", **kwargs: Any ) -> None: @@ -59,15 +59,15 @@ def __init__( raise ValueError("Parameter 'subscription_id' must not be None.") if resource_group_name is None: raise ValueError("Parameter 'resource_group_name' must not be None.") - if workspace_name is None: - raise ValueError("Parameter 'workspace_name' must not be None.") + if project_name is None: + raise ValueError("Parameter 'project_name' must not be None.") if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.endpoint = endpoint self.subscription_id = subscription_id self.resource_group_name = resource_group_name - self.workspace_name = workspace_name + self.project_name = project_name self.credential = credential self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) diff --git a/sdk/ai/azure-ai-client/azure/ai/client/_patch.py b/sdk/ai/azure-ai-client/azure/ai/client/_patch.py index 1ec9faeef28e..1e2704985699 100644 --- a/sdk/ai/azure-ai-client/azure/ai/client/_patch.py +++ b/sdk/ai/azure-ai-client/azure/ai/client/_patch.py @@ -25,7 +25,7 @@ def __init__( endpoint: str, subscription_id: str, resource_group_name: str, - workspace_name: str, + project_name: str, credential: "TokenCredential", **kwargs: Any, ) -> None: @@ -36,8 +36,8 @@ def __init__( raise ValueError("subscription_id ID is required") if not resource_group_name: raise ValueError("resource_group_name is required") - if not workspace_name: - raise ValueError("workspace_name is required") + if not project_name: + raise ValueError("project_name is required") if not credential: raise ValueError("Credential is required") if "api_version" in kwargs: @@ -50,12 +50,12 @@ def __init__( kwargs3 = kwargs.copy() # For Endpoints operations (enumerating connections, getting SAS tokens) - _endpoint1 = f"https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.MachineLearningServices/workspaces/{workspace_name}" # pylint: disable=line-too-long + _endpoint1 = f"https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.MachineLearningServices/workspaces/{project_name}" # pylint: disable=line-too-long self._config1 = AzureAIClientConfiguration( endpoint=endpoint, subscription_id=subscription_id, resource_group_name=resource_group_name, - workspace_name=workspace_name, + project_name=project_name, credential=credential, api_version="2024-07-01-preview", credential_scopes=["https://management.azure.com"], @@ -81,12 +81,12 @@ def __init__( self._client1 = PipelineClient(base_url=_endpoint1, policies=_policies1, **kwargs1) # For Agents operations - _endpoint2 = f"{endpoint}/agents/v1.0/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.MachineLearningServices/workspaces/{workspace_name}" # pylint: disable=line-too-long + _endpoint2 = f"{endpoint}/agents/v1.0/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.MachineLearningServices/workspaces/{project_name}" # pylint: disable=line-too-long self._config2 = AzureAIClientConfiguration( endpoint=endpoint, subscription_id=subscription_id, resource_group_name=resource_group_name, - workspace_name=workspace_name, + project_name=project_name, credential=credential, api_version="2024-07-01-preview", # TODO: Update me credential_scopes=["https://ml.azure.com"], @@ -112,12 +112,12 @@ def __init__( self._client2 = PipelineClient(base_url=_endpoint2, policies=_policies2, **kwargs2) # For Cloud Evaluations operations - _endpoint3 = f"{endpoint}/raisvc/v1.0/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.MachineLearningServices/workspaces/{workspace_name}" # pylint: disable=line-too-long + _endpoint3 = f"{endpoint}/raisvc/v1.0/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.MachineLearningServices/workspaces/{project_name}" # pylint: disable=line-too-long self._config3 = AzureAIClientConfiguration( endpoint=endpoint, subscription_id=subscription_id, resource_group_name=resource_group_name, - workspace_name=workspace_name, + project_name=project_name, credential=credential, api_version="2024-07-01-preview", # TODO: Update me credential_scopes=["https://ml.azure.com"], # TODO: Update once service changes are ready @@ -167,24 +167,23 @@ def __exit__(self, *exc_details: Any) -> None: self._client2.__exit__(*exc_details) self._client3.__exit__(*exc_details) - @classmethod - def from_connection_string(cls, connection: str, credential: "TokenCredential", **kwargs) -> "AzureAIClient": + def from_connection_string(cls, conn_str: str, credential: "TokenCredential", **kwargs) -> "AzureAIClient": """ Create an AzureAIClient from a connection string. - :param connection: The connection string, copied from your AI Studio project. + :param conn_str: The connection string, copied from your AI Studio project. """ - if not connection: + if not conn_str: raise ValueError("Connection string is required") - parts = connection.split(";") + parts = conn_str.split(";") if len(parts) != 4: raise ValueError("Invalid connection string format") - endpoint = parts[0] + endpoint = "https://" + parts[0] subscription_id = parts[1] resource_group_name = parts[2] - workspace_name = parts[3] - return cls(endpoint, subscription_id, resource_group_name, workspace_name, credential, **kwargs) + project_name = parts[3] + return cls(endpoint, subscription_id, resource_group_name, project_name, credential, **kwargs) __all__: List[str] = [ diff --git a/sdk/ai/azure-ai-client/azure/ai/client/aio/_client.py b/sdk/ai/azure-ai-client/azure/ai/client/aio/_client.py index 53eb218b6823..0e194be24fc6 100644 --- a/sdk/ai/azure-ai-client/azure/ai/client/aio/_client.py +++ b/sdk/ai/azure-ai-client/azure/ai/client/aio/_client.py @@ -41,8 +41,8 @@ class AzureAIClient: :type subscription_id: str :param resource_group_name: The name of the Azure Resource Group. Required. :type resource_group_name: str - :param workspace_name: The name of the Azure AI Studio hub. Required. - :type workspace_name: str + :param project_name: The Azure AI Studio project name. Required. + :type project_name: str :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :keyword api_version: The API version to use for this operation. Default value is @@ -56,16 +56,16 @@ def __init__( endpoint: str, subscription_id: str, resource_group_name: str, - workspace_name: str, + project_name: str, credential: "AsyncTokenCredential", **kwargs: Any ) -> None: - _endpoint = "{endpoint}/{subscriptionId}/{resourceGroupName}/{workspaceName}" + _endpoint = "{endpoint}/{subscriptionId}/{resourceGroupName}/{projectName}" self._config = AzureAIClientConfiguration( endpoint=endpoint, subscription_id=subscription_id, resource_group_name=resource_group_name, - workspace_name=workspace_name, + project_name=project_name, credential=credential, **kwargs ) @@ -122,7 +122,7 @@ def send_request( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) diff --git a/sdk/ai/azure-ai-client/azure/ai/client/aio/_configuration.py b/sdk/ai/azure-ai-client/azure/ai/client/aio/_configuration.py index eb7879780472..8356c07ba7ee 100644 --- a/sdk/ai/azure-ai-client/azure/ai/client/aio/_configuration.py +++ b/sdk/ai/azure-ai-client/azure/ai/client/aio/_configuration.py @@ -32,8 +32,8 @@ class AzureAIClientConfiguration: # pylint: disable=too-many-instance-attribute :type subscription_id: str :param resource_group_name: The name of the Azure Resource Group. Required. :type resource_group_name: str - :param workspace_name: The name of the Azure AI Studio hub. Required. - :type workspace_name: str + :param project_name: The Azure AI Studio project name. Required. + :type project_name: str :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :keyword api_version: The API version to use for this operation. Default value is @@ -47,7 +47,7 @@ def __init__( endpoint: str, subscription_id: str, resource_group_name: str, - workspace_name: str, + project_name: str, credential: "AsyncTokenCredential", **kwargs: Any ) -> None: @@ -59,15 +59,15 @@ def __init__( raise ValueError("Parameter 'subscription_id' must not be None.") if resource_group_name is None: raise ValueError("Parameter 'resource_group_name' must not be None.") - if workspace_name is None: - raise ValueError("Parameter 'workspace_name' must not be None.") + if project_name is None: + raise ValueError("Parameter 'project_name' must not be None.") if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.endpoint = endpoint self.subscription_id = subscription_id self.resource_group_name = resource_group_name - self.workspace_name = workspace_name + self.project_name = project_name self.credential = credential self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) diff --git a/sdk/ai/azure-ai-client/azure/ai/client/aio/_patch.py b/sdk/ai/azure-ai-client/azure/ai/client/aio/_patch.py index 1201648eb3f9..06729aba0632 100644 --- a/sdk/ai/azure-ai-client/azure/ai/client/aio/_patch.py +++ b/sdk/ai/azure-ai-client/azure/ai/client/aio/_patch.py @@ -25,7 +25,7 @@ def __init__( endpoint: str, subscription_id: str, resource_group_name: str, - workspace_name: str, + project_name: str, credential: "AsyncTokenCredential", **kwargs: Any, ) -> None: @@ -36,8 +36,8 @@ def __init__( raise ValueError("subscription_id ID is required") if not resource_group_name: raise ValueError("resource_group_name is required") - if not workspace_name: - raise ValueError("workspace_name is required") + if not project_name: + raise ValueError("project_name is required") if not credential: raise ValueError("Credential is required") if "api_version" in kwargs: @@ -50,12 +50,12 @@ def __init__( kwargs3 = kwargs.copy() # For Endpoints operations (enumerating connections, getting SAS tokens) - _endpoint1 = f"https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.MachineLearningServices/workspaces/{workspace_name}" # pylint: disable=line-too-long + _endpoint1 = f"https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.MachineLearningServices/workspaces/{project_name}" # pylint: disable=line-too-long self._config1 = AzureAIClientConfiguration( endpoint=endpoint, subscription_id=subscription_id, resource_group_name=resource_group_name, - workspace_name=workspace_name, + project_name=project_name, credential=credential, api_version="2024-07-01-preview", credential_scopes=["https://management.azure.com"], @@ -81,12 +81,12 @@ def __init__( self._client1 = AsyncPipelineClient(base_url=_endpoint1, policies=_policies1, **kwargs1) # For Agents operations - _endpoint2 = f"{endpoint}/agents/v1.0/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.MachineLearningServices/workspaces/{workspace_name}" # pylint: disable=line-too-long + _endpoint2 = f"{endpoint}/agents/v1.0/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.MachineLearningServices/workspaces/{project_name}" # pylint: disable=line-too-long self._config2 = AzureAIClientConfiguration( endpoint=endpoint, subscription_id=subscription_id, resource_group_name=resource_group_name, - workspace_name=workspace_name, + project_name=project_name, credential=credential, api_version="2024-07-01-preview", # TODO: Update me credential_scopes=["https://ml.azure.com"], @@ -112,12 +112,12 @@ def __init__( self._client2 = AsyncPipelineClient(base_url=_endpoint2, policies=_policies2, **kwargs2) # For Cloud Evaluations operations - _endpoint3 = f"{endpoint}/raisvc/v1.0/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.MachineLearningServices/workspaces/{workspace_name}" # pylint: disable=line-too-long + _endpoint3 = f"{endpoint}/raisvc/v1.0/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.MachineLearningServices/workspaces/{project_name}" # pylint: disable=line-too-long self._config3 = AzureAIClientConfiguration( endpoint=endpoint, subscription_id=subscription_id, resource_group_name=resource_group_name, - workspace_name=workspace_name, + project_name=project_name, credential=credential, api_version="2024-07-01-preview", # TODO: Update me credential_scopes=["https://management.azure.com"], # TODO: Update once service changes are ready @@ -168,22 +168,23 @@ async def __aexit__(self, *exc_details: Any) -> None: await self._client3.__aexit__(*exc_details) @classmethod - def from_connection_string(cls, connection: str, credential: "AzureTokenCredential", **kwargs) -> "AzureAIClient": + def from_connection_string(cls, conn_str: str, credential: "AsyncTokenCredential", **kwargs) -> "AzureAIClient": """ Create an asynchronous AzureAIClient from a connection string. - :param connection: The connection string, copied from your AI Studio project. + :param conn_str: The connection string, copied from your AI Studio project. """ - if not connection: + if not conn_str: raise ValueError("Connection string is required") - parts = connection.split(";") + parts = conn_str.split(";") if len(parts) != 4: raise ValueError("Invalid connection string format") - endpoint = parts[0] + endpoint = "https://" + parts[0] subscription_id = parts[1] resource_group_name = parts[2] - workspace_name = parts[3] - return cls(endpoint, subscription_id, resource_group_name, workspace_name, credential, **kwargs) + project_name = parts[3] + return cls(endpoint, subscription_id, resource_group_name, project_name, credential, **kwargs) + __all__: List[str] = [ "AzureAIClient", diff --git a/sdk/ai/azure-ai-client/azure/ai/client/aio/operations/_operations.py b/sdk/ai/azure-ai-client/azure/ai/client/aio/operations/_operations.py index f29d76e51ded..5a747e46f845 100644 --- a/sdk/ai/azure-ai-client/azure/ai/client/aio/operations/_operations.py +++ b/sdk/ai/azure-ai-client/azure/ai/client/aio/operations/_operations.py @@ -320,7 +320,7 @@ async def create_agent( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -411,7 +411,7 @@ async def list_agents( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -476,7 +476,7 @@ async def get_agent(self, assistant_id: str, **kwargs: Any) -> _models.Agent: "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -725,7 +725,7 @@ async def update_agent( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -790,7 +790,7 @@ async def delete_agent(self, assistant_id: str, **kwargs: Any) -> _models.AgentD "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -955,7 +955,7 @@ async def create_thread( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -1020,7 +1020,7 @@ async def get_thread(self, thread_id: str, **kwargs: Any) -> _models.AgentThread "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -1188,7 +1188,7 @@ async def update_thread( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -1253,7 +1253,7 @@ async def delete_thread(self, thread_id: str, **kwargs: Any) -> _models.ThreadDe "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -1449,7 +1449,7 @@ async def create_message( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -1548,7 +1548,7 @@ async def list_messages( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -1616,7 +1616,7 @@ async def get_message(self, thread_id: str, message_id: str, **kwargs: Any) -> _ "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -1781,7 +1781,7 @@ async def update_message( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -2105,7 +2105,7 @@ async def create_run( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -2200,7 +2200,7 @@ async def list_runs( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -2268,7 +2268,7 @@ async def get_run(self, thread_id: str, run_id: str, **kwargs: Any) -> _models.T "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -2433,7 +2433,7 @@ async def update_run( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -2610,7 +2610,7 @@ async def submit_tool_outputs_to_run( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -2678,7 +2678,7 @@ async def cancel_run(self, thread_id: str, run_id: str, **kwargs: Any) -> _model "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -2989,7 +2989,7 @@ async def create_thread_and_run( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -3060,7 +3060,7 @@ async def get_run_step(self, thread_id: str, run_id: str, step_id: str, **kwargs "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -3159,7 +3159,7 @@ async def list_run_steps( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -3228,7 +3228,7 @@ async def list_files( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -3354,7 +3354,7 @@ async def upload_file( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -3419,7 +3419,7 @@ async def delete_file(self, file_id: str, **kwargs: Any) -> _models.FileDeletion "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -3484,7 +3484,7 @@ async def get_file(self, file_id: str, **kwargs: Any) -> _models.OpenAIFile: "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -3549,7 +3549,7 @@ async def get_file_content(self, file_id: str, **kwargs: Any) -> _models.FileCon "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -3640,7 +3640,7 @@ async def list_vector_stores( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -3817,7 +3817,7 @@ async def create_vector_store( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -3882,7 +3882,7 @@ async def get_vector_store(self, vector_store_id: str, **kwargs: Any) -> _models "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -4048,7 +4048,7 @@ async def modify_vector_store( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -4114,7 +4114,7 @@ async def delete_vector_store(self, vector_store_id: str, **kwargs: Any) -> _mod "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -4214,7 +4214,7 @@ async def list_vector_store_files( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -4372,7 +4372,7 @@ async def create_vector_store_file( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -4440,7 +4440,7 @@ async def get_vector_store_file(self, vector_store_id: str, file_id: str, **kwar "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -4513,7 +4513,7 @@ async def delete_vector_store_file( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -4671,7 +4671,7 @@ async def create_vector_store_file_batch( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -4741,7 +4741,7 @@ async def get_vector_store_file_batch( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -4812,7 +4812,7 @@ async def cancel_vector_store_file_batch( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -4916,7 +4916,7 @@ async def list_vector_store_file_batch_files( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -4996,7 +4996,7 @@ async def _list(self, **kwargs: Any) -> _models._models.ConnectionsListResponse: "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -5139,7 +5139,7 @@ async def _list_secrets( # pylint: disable=protected-access "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -5282,7 +5282,7 @@ async def create(self, evaluation: Union[_models.Evaluation, JSON, IO[bytes]], * "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -5359,9 +5359,7 @@ def prepare_request(next_link=None): "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url( - "self._config.workspace_name", self._config.workspace_name, "str" - ), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -5386,9 +5384,7 @@ def prepare_request(next_link=None): "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url( - "self._config.workspace_name", self._config.workspace_name, "str" - ), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -5527,7 +5523,7 @@ async def update( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -5592,7 +5588,7 @@ async def get(self, id: str, **kwargs: Any) -> _models.Evaluation: "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -5717,7 +5713,7 @@ async def create_schedule( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -5782,7 +5778,7 @@ async def get_schedule(self, id: str, **kwargs: Any) -> _models.EvaluationSchedu "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -5859,9 +5855,7 @@ def prepare_request(next_link=None): "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url( - "self._config.workspace_name", self._config.workspace_name, "str" - ), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -5886,9 +5880,7 @@ def prepare_request(next_link=None): "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url( - "self._config.workspace_name", self._config.workspace_name, "str" - ), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -5968,9 +5960,7 @@ def prepare_request(next_link=None): "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url( - "self._config.workspace_name", self._config.workspace_name, "str" - ), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -5995,9 +5985,7 @@ def prepare_request(next_link=None): "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url( - "self._config.workspace_name", self._config.workspace_name, "str" - ), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -6062,7 +6050,7 @@ async def delete_schedule(self, id: str, **kwargs: Any) -> None: "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/sdk/ai/azure-ai-client/azure/ai/client/aio/operations/_patch.py b/sdk/ai/azure-ai-client/azure/ai/client/aio/operations/_patch.py index 83bdd5c11161..2f3fe6fc6154 100644 --- a/sdk/ai/azure-ai-client/azure/ai/client/aio/operations/_patch.py +++ b/sdk/ai/azure-ai-client/azure/ai/client/aio/operations/_patch.py @@ -52,6 +52,7 @@ async def get_chat_completions_client(self) -> "ChatCompletionsClient": "[InferenceOperations.get_chat_completions_client] Creating ChatCompletionsClient using API key authentication" ) from azure.core.credentials import AzureKeyCredential + client = ChatCompletionsClient(endpoint=endpoint.endpoint_url, credential=AzureKeyCredential(endpoint.key)) elif endpoint.authentication_type == AuthenticationType.AAD: # MaaS models do not yet support EntraID auth @@ -122,6 +123,10 @@ async def get_azure_openai_client(self) -> "AsyncAzureOpenAI": except ModuleNotFoundError as _: raise ModuleNotFoundError("OpenAI SDK is not installed. Please install it using 'pip install openai-async'") + # Pick latest GA version from the "Data plane - Inference" row in the table + # https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#api-specs + AZURE_OPENAI_API_VERSION = "2024-06-01" + if endpoint.authentication_type == AuthenticationType.API_KEY: logger.debug( "[InferenceOperations.get_azure_openai_client] Creating AzureOpenAI using API key authentication" @@ -129,7 +134,7 @@ async def get_azure_openai_client(self) -> "AsyncAzureOpenAI": client = AsyncAzureOpenAI( api_key=endpoint.key, azure_endpoint=endpoint.endpoint_url, - api_version="2024-08-01-preview", # TODO: Is this needed? + api_version=AZURE_OPENAI_API_VERSION ) elif endpoint.authentication_type == AuthenticationType.AAD: logger.debug( @@ -147,7 +152,7 @@ async def get_azure_openai_client(self) -> "AsyncAzureOpenAI": endpoint.token_credential, "https://cognitiveservices.azure.com/.default" ), azure_endpoint=endpoint.endpoint_url, - api_version="2024-08-01-preview", + api_version=AZURE_OPENAI_API_VERSION, ) elif endpoint.authentication_type == AuthenticationType.SAS: logger.debug("[InferenceOperations.get_azure_openai_client] Creating AzureOpenAI using SAS authentication") @@ -156,7 +161,7 @@ async def get_azure_openai_client(self) -> "AsyncAzureOpenAI": endpoint.token_credential, "https://cognitiveservices.azure.com/.default" ), azure_endpoint=endpoint.endpoint_url, - api_version="2024-08-01-preview", + api_version=AZURE_OPENAI_API_VERSION ) else: raise ValueError("Unknown authentication type") @@ -183,19 +188,20 @@ async def get(self, *, endpoint_name: str, populate_secrets: bool = False) -> En connection_name=endpoint_name, subscription_id=self._config.subscription_id, resource_group_name=self._config.resource_group_name, - workspace_name=self._config.workspace_name, + workspace_name=self._config.project_name, api_version_in_body=self._config.api_version, ) if connection.properties.auth_type == AuthenticationType.AAD: return EndpointProperties(connection=connection, token_credential=self._config.credential) elif connection.properties.auth_type == AuthenticationType.SAS: from ...models._patch import SASTokenCredential + token_credential = SASTokenCredential( sas_token=connection.properties.credentials.sas, credential=self._config.credential, subscription_id=self._config.subscription_id, resource_group_name=self._config.resource_group_name, - workspace_name=self._config.workspace_name, + project_name=self._config.project_name, connection_name=endpoint_name, ) return EndpointProperties(connection=connection, token_credential=token_credential) @@ -1707,4 +1713,3 @@ def patch_sdk(): you can't accomplish using the techniques described in https://aka.ms/azsdk/python/dpcodegen/python/customize """ - diff --git a/sdk/ai/azure-ai-client/azure/ai/client/models/__init__.py b/sdk/ai/azure-ai-client/azure/ai/client/models/__init__.py index 61340ac38b60..ecf84301a862 100644 --- a/sdk/ai/azure-ai-client/azure/ai/client/models/__init__.py +++ b/sdk/ai/azure-ai-client/azure/ai/client/models/__init__.py @@ -138,7 +138,9 @@ from ._enums import AgentsApiToolChoiceOptionMode from ._enums import AgentsNamedToolChoiceType from ._enums import ApiResponseFormat +from ._enums import AuthenticationType from ._enums import DoneEvent +from ._enums import EndpointType from ._enums import ErrorEvent from ._enums import FilePurpose from ._enums import FileState @@ -302,7 +304,9 @@ "AgentsApiToolChoiceOptionMode", "AgentsNamedToolChoiceType", "ApiResponseFormat", + "AuthenticationType", "DoneEvent", + "EndpointType", "ErrorEvent", "FilePurpose", "FileState", diff --git a/sdk/ai/azure-ai-client/azure/ai/client/models/_enums.py b/sdk/ai/azure-ai-client/azure/ai/client/models/_enums.py index a47264fce831..676321444449 100644 --- a/sdk/ai/azure-ai-client/azure/ai/client/models/_enums.py +++ b/sdk/ai/azure-ai-client/azure/ai/client/models/_enums.py @@ -125,7 +125,7 @@ class ApiResponseFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """to do.""" + """Authentication type used by Azure AI service to connect to another service.""" API_KEY = "ApiKey" """API Key authentication""" @@ -146,11 +146,9 @@ class EndpointType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Type (or category) of the connection.""" AZURE_OPEN_AI = "AzureOpenAI" - """Azure OpenAI""" + """Azure OpenAI service""" SERVERLESS = "Serverless" - """Serverless API""" - AGENT = "Agent" - """Agent""" + """Serverless API service""" class ErrorEvent(str, Enum, metaclass=CaseInsensitiveEnumMeta): diff --git a/sdk/ai/azure-ai-client/azure/ai/client/models/_models.py b/sdk/ai/azure-ai-client/azure/ai/client/models/_models.py index 9382a7a409c9..1ba759bda534 100644 --- a/sdk/ai/azure-ai-client/azure/ai/client/models/_models.py +++ b/sdk/ai/azure-ai-client/azure/ai/client/models/_models.py @@ -539,7 +539,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles class ConnectionProperties(_model_base.Model): - """to do. + """Connetion properties. You probably want to use the sub-classes and not this class directly. Known sub-classes are: ConnectionPropertiesAADAuth, ConnectionPropertiesApiKeyAuth, ConnectionPropertiesSASAuth @@ -564,20 +564,19 @@ class ConnectionPropertiesAADAuth(ConnectionProperties, discriminator="AAD"): :ivar auth_type: Authentication type of the connection target. Required. Entra ID authentication :vartype auth_type: str or ~azure.ai.client.models.AAD - :ivar category: Category of the connection. Required. Known values are: "AzureOpenAI", - "Serverless", and "Agent". + :ivar category: Category of the connection. Required. Known values are: "AzureOpenAI" and + "Serverless". :vartype category: str or ~azure.ai.client.models.EndpointType - :ivar target: to do. Required. + :ivar target: The connection URL to be used for this service. Required. :vartype target: str """ auth_type: Literal[AuthenticationType.AAD] = rest_discriminator(name="authType") # type: ignore """Authentication type of the connection target. Required. Entra ID authentication""" - category: Union[str, "_models._enums.EndpointType"] = rest_field() - """Category of the connection. Required. Known values are: \"AzureOpenAI\", \"Serverless\", and - \"Agent\".""" + category: Union[str, "_models.EndpointType"] = rest_field() + """Category of the connection. Required. Known values are: \"AzureOpenAI\" and \"Serverless\".""" target: str = rest_field() - """to do. Required.""" + """The connection URL to be used for this service. Required.""" class ConnectionPropertiesApiKeyAuth(ConnectionProperties, discriminator="ApiKey"): @@ -586,24 +585,23 @@ class ConnectionPropertiesApiKeyAuth(ConnectionProperties, discriminator="ApiKey :ivar auth_type: Authentication type of the connection target. Required. API Key authentication :vartype auth_type: str or ~azure.ai.client.models.API_KEY - :ivar category: Category of the connection. Required. Known values are: "AzureOpenAI", - "Serverless", and "Agent". + :ivar category: Category of the connection. Required. Known values are: "AzureOpenAI" and + "Serverless". :vartype category: str or ~azure.ai.client.models.EndpointType :ivar credentials: Credentials will only be present for authType=ApiKey. Required. :vartype credentials: ~azure.ai.client.models._models.CredentialsApiKeyAuth - :ivar target: to do. Required. + :ivar target: The connection URL to be used for this service. Required. :vartype target: str """ auth_type: Literal[AuthenticationType.API_KEY] = rest_discriminator(name="authType") # type: ignore """Authentication type of the connection target. Required. API Key authentication""" - category: Union[str, "_models._enums.EndpointType"] = rest_field() - """Category of the connection. Required. Known values are: \"AzureOpenAI\", \"Serverless\", and - \"Agent\".""" + category: Union[str, "_models.EndpointType"] = rest_field() + """Category of the connection. Required. Known values are: \"AzureOpenAI\" and \"Serverless\".""" credentials: "_models._models.CredentialsApiKeyAuth" = rest_field() """Credentials will only be present for authType=ApiKey. Required.""" target: str = rest_field() - """to do. Required.""" + """The connection URL to be used for this service. Required.""" class ConnectionPropertiesSASAuth(ConnectionProperties, discriminator="SAS"): @@ -613,41 +611,40 @@ class ConnectionPropertiesSASAuth(ConnectionProperties, discriminator="SAS"): :ivar auth_type: Authentication type of the connection target. Required. Shared Access Signature (SAS) authentication :vartype auth_type: str or ~azure.ai.client.models.SAS - :ivar category: Category of the connection. Required. Known values are: "AzureOpenAI", - "Serverless", and "Agent". + :ivar category: Category of the connection. Required. Known values are: "AzureOpenAI" and + "Serverless". :vartype category: str or ~azure.ai.client.models.EndpointType :ivar credentials: Credentials will only be present for authType=ApiKey. Required. :vartype credentials: ~azure.ai.client.models._models.CredentialsSASAuth - :ivar target: to do. Required. + :ivar target: The connection URL to be used for this service. Required. :vartype target: str """ auth_type: Literal[AuthenticationType.SAS] = rest_discriminator(name="authType") # type: ignore """Authentication type of the connection target. Required. Shared Access Signature (SAS) authentication""" - category: Union[str, "_models._enums.EndpointType"] = rest_field() - """Category of the connection. Required. Known values are: \"AzureOpenAI\", \"Serverless\", and - \"Agent\".""" + category: Union[str, "_models.EndpointType"] = rest_field() + """Category of the connection. Required. Known values are: \"AzureOpenAI\" and \"Serverless\".""" credentials: "_models._models.CredentialsSASAuth" = rest_field() """Credentials will only be present for authType=ApiKey. Required.""" target: str = rest_field() - """to do. Required.""" + """The connection URL to be used for this service. Required.""" class ConnectionsListResponse(_model_base.Model): - """to do. + """Response from the list operation. - :ivar value: to do. Required. + :ivar value: A list of connection list secrets. Required. :vartype value: list[~azure.ai.client.models._models.ConnectionsListSecretsResponse] """ value: List["_models._models.ConnectionsListSecretsResponse"] = rest_field() - """to do. Required.""" + """A list of connection list secrets. Required.""" class ConnectionsListSecretsResponse(_model_base.Model): - """to do. + """Response from the listSecrets operation. :ivar name: The name of the resource. Required. @@ -663,27 +660,27 @@ class ConnectionsListSecretsResponse(_model_base.Model): class CredentialsApiKeyAuth(_model_base.Model): - """to do. + """The credentials needed for API key authentication. - :ivar key: to do. Required. + :ivar key: The API key. Required. :vartype key: str """ key: str = rest_field() - """to do. Required.""" + """The API key. Required.""" class CredentialsSASAuth(_model_base.Model): - """to do. + """The credentials neede for Shared Access Signatures (SAS) authentication. - :ivar sas: to do. Required. + :ivar sas: The Shared Access Signatures (SAS) token. Required. :vartype sas: str """ sas: str = rest_field(name="SAS") - """to do. Required.""" + """The Shared Access Signatures (SAS) token. Required.""" class Dataset(InputData, discriminator="dataset"): diff --git a/sdk/ai/azure-ai-client/azure/ai/client/models/_patch.py b/sdk/ai/azure-ai-client/azure/ai/client/models/_patch.py index 26b197188a38..bd5acd50c2d7 100644 --- a/sdk/ai/azure-ai-client/azure/ai/client/models/_patch.py +++ b/sdk/ai/azure-ai-client/azure/ai/client/models/_patch.py @@ -81,14 +81,14 @@ def __init__( credential: TokenCredential, subscription_id: str, resource_group_name: str, - workspace_name: str, + project_name: str, connection_name: str, ): self._sas_token = sas_token self._credential = credential self._subscription_id = subscription_id self._resource_group_name = resource_group_name - self._workspace_name = workspace_name + self._project_name = project_name self._connection_name = connection_name self._expires_on = SASTokenCredential._get_expiration_date_from_token(self._sas_token) logger.debug("[SASTokenCredential.__init__] Exit. Given token expires on %s.", self._expires_on) @@ -112,7 +112,7 @@ def _refresh_token(self) -> None: endpoint="not-needed", # Since we are only going to use the "endpoints" operations, we don't need to supply an endpoint. http://management.azure.com is hard coded in the SDK. subscription_id=self._subscription_id, resource_group_name=self._resource_group_name, - workspace_name=self._workspace_name, + project_name=self._project_name, ) connection = ai_client.endpoints.get(endpoint_name=self._connection_name, populate_secrets=True) diff --git a/sdk/ai/azure-ai-client/azure/ai/client/operations/_operations.py b/sdk/ai/azure-ai-client/azure/ai/client/operations/_operations.py index c71ab5334762..2d3adab9ec1f 100644 --- a/sdk/ai/azure-ai-client/azure/ai/client/operations/_operations.py +++ b/sdk/ai/azure-ai-client/azure/ai/client/operations/_operations.py @@ -1658,7 +1658,7 @@ def create_agent( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -1749,7 +1749,7 @@ def list_agents( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -1814,7 +1814,7 @@ def get_agent(self, assistant_id: str, **kwargs: Any) -> _models.Agent: "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -2063,7 +2063,7 @@ def update_agent( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -2128,7 +2128,7 @@ def delete_agent(self, assistant_id: str, **kwargs: Any) -> _models.AgentDeletio "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -2293,7 +2293,7 @@ def create_thread( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -2358,7 +2358,7 @@ def get_thread(self, thread_id: str, **kwargs: Any) -> _models.AgentThread: "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -2526,7 +2526,7 @@ def update_thread( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -2591,7 +2591,7 @@ def delete_thread(self, thread_id: str, **kwargs: Any) -> _models.ThreadDeletion "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -2787,7 +2787,7 @@ def create_message( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -2886,7 +2886,7 @@ def list_messages( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -2954,7 +2954,7 @@ def get_message(self, thread_id: str, message_id: str, **kwargs: Any) -> _models "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -3119,7 +3119,7 @@ def update_message( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -3443,7 +3443,7 @@ def create_run( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -3538,7 +3538,7 @@ def list_runs( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -3606,7 +3606,7 @@ def get_run(self, thread_id: str, run_id: str, **kwargs: Any) -> _models.ThreadR "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -3771,7 +3771,7 @@ def update_run( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -3948,7 +3948,7 @@ def submit_tool_outputs_to_run( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -4016,7 +4016,7 @@ def cancel_run(self, thread_id: str, run_id: str, **kwargs: Any) -> _models.Thre "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -4327,7 +4327,7 @@ def create_thread_and_run( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -4398,7 +4398,7 @@ def get_run_step(self, thread_id: str, run_id: str, step_id: str, **kwargs: Any) "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -4497,7 +4497,7 @@ def list_run_steps( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -4566,7 +4566,7 @@ def list_files( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -4692,7 +4692,7 @@ def upload_file( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -4757,7 +4757,7 @@ def delete_file(self, file_id: str, **kwargs: Any) -> _models.FileDeletionStatus "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -4822,7 +4822,7 @@ def get_file(self, file_id: str, **kwargs: Any) -> _models.OpenAIFile: "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -4887,7 +4887,7 @@ def get_file_content(self, file_id: str, **kwargs: Any) -> _models.FileContentRe "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -4978,7 +4978,7 @@ def list_vector_stores( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -5155,7 +5155,7 @@ def create_vector_store( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -5220,7 +5220,7 @@ def get_vector_store(self, vector_store_id: str, **kwargs: Any) -> _models.Vecto "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -5386,7 +5386,7 @@ def modify_vector_store( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -5452,7 +5452,7 @@ def delete_vector_store(self, vector_store_id: str, **kwargs: Any) -> _models.Ve "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -5552,7 +5552,7 @@ def list_vector_store_files( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -5710,7 +5710,7 @@ def create_vector_store_file( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -5778,7 +5778,7 @@ def get_vector_store_file(self, vector_store_id: str, file_id: str, **kwargs: An "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -5851,7 +5851,7 @@ def delete_vector_store_file( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -6009,7 +6009,7 @@ def create_vector_store_file_batch( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -6079,7 +6079,7 @@ def get_vector_store_file_batch( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -6150,7 +6150,7 @@ def cancel_vector_store_file_batch( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -6254,7 +6254,7 @@ def list_vector_store_file_batch_files( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -6334,7 +6334,7 @@ def _list(self, **kwargs: Any) -> _models._models.ConnectionsListResponse: # py "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -6477,7 +6477,7 @@ def _list_secrets( # pylint: disable=protected-access "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -6618,7 +6618,7 @@ def create(self, evaluation: Union[_models.Evaluation, JSON, IO[bytes]], **kwarg "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -6695,9 +6695,7 @@ def prepare_request(next_link=None): "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url( - "self._config.workspace_name", self._config.workspace_name, "str" - ), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -6722,9 +6720,7 @@ def prepare_request(next_link=None): "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url( - "self._config.workspace_name", self._config.workspace_name, "str" - ), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -6863,7 +6859,7 @@ def update( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -6928,7 +6924,7 @@ def get(self, id: str, **kwargs: Any) -> _models.Evaluation: "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -7053,7 +7049,7 @@ def create_schedule( "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -7118,7 +7114,7 @@ def get_schedule(self, id: str, **kwargs: Any) -> _models.EvaluationSchedule: "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -7195,9 +7191,7 @@ def prepare_request(next_link=None): "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url( - "self._config.workspace_name", self._config.workspace_name, "str" - ), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -7222,9 +7216,7 @@ def prepare_request(next_link=None): "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url( - "self._config.workspace_name", self._config.workspace_name, "str" - ), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -7304,9 +7296,7 @@ def prepare_request(next_link=None): "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url( - "self._config.workspace_name", self._config.workspace_name, "str" - ), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -7331,9 +7321,7 @@ def prepare_request(next_link=None): "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url( - "self._config.workspace_name", self._config.workspace_name, "str" - ), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) @@ -7398,7 +7386,7 @@ def delete_schedule(self, id: str, **kwargs: Any) -> None: # pylint: disable=in "resourceGroupName": self._serialize.url( "self._config.resource_group_name", self._config.resource_group_name, "str" ), - "workspaceName": self._serialize.url("self._config.workspace_name", self._config.workspace_name, "str"), + "projectName": self._serialize.url("self._config.project_name", self._config.project_name, "str"), } _request.url = self._client.format_url(_request.url, **path_format_arguments) diff --git a/sdk/ai/azure-ai-client/azure/ai/client/operations/_patch.py b/sdk/ai/azure-ai-client/azure/ai/client/operations/_patch.py index dd351ad9b3a8..b5133b04d620 100644 --- a/sdk/ai/azure-ai-client/azure/ai/client/operations/_patch.py +++ b/sdk/ai/azure-ai-client/azure/ai/client/operations/_patch.py @@ -134,6 +134,10 @@ def get_azure_openai_client(self) -> "AzureOpenAI": except ModuleNotFoundError as _: raise ModuleNotFoundError("OpenAI SDK is not installed. Please install it using 'pip install openai'") + # Pick latest GA version from the "Data plane - Inference" row in the table + # https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#api-specs + AZURE_OPENAI_API_VERSION = "2024-06-01" + if endpoint.authentication_type == AuthenticationType.API_KEY: logger.debug( "[InferenceOperations.get_azure_openai_client] Creating AzureOpenAI using API key authentication" @@ -141,7 +145,7 @@ def get_azure_openai_client(self) -> "AzureOpenAI": client = AzureOpenAI( api_key=endpoint.key, azure_endpoint=endpoint.endpoint_url, - api_version="2024-08-01-preview", # TODO: Is this needed? + api_version=AZURE_OPENAI_API_VERSION ) elif endpoint.authentication_type == AuthenticationType.AAD: logger.debug( @@ -159,7 +163,7 @@ def get_azure_openai_client(self) -> "AzureOpenAI": endpoint.token_credential, "https://cognitiveservices.azure.com/.default" ), azure_endpoint=endpoint.endpoint_url, - api_version="2024-08-01-preview", + api_version=AZURE_OPENAI_API_VERSION ) elif endpoint.authentication_type == AuthenticationType.SAS: logger.debug("[InferenceOperations.get_azure_openai_client] Creating AzureOpenAI using SAS authentication") @@ -168,7 +172,7 @@ def get_azure_openai_client(self) -> "AzureOpenAI": endpoint.token_credential, "https://cognitiveservices.azure.com/.default" ), azure_endpoint=endpoint.endpoint_url, - api_version="2024-08-01-preview", + api_version=AZURE_OPENAI_API_VERSION ) else: raise ValueError("Unknown authentication type") @@ -197,7 +201,7 @@ def get(self, *, endpoint_name: str, populate_secrets: bool = False) -> Endpoint connection_name=endpoint_name, subscription_id=self._config.subscription_id, resource_group_name=self._config.resource_group_name, - workspace_name=self._config.workspace_name, + workspace_name=self._config.project_name, api_version_in_body=self._config.api_version, ) if connection.properties.auth_type == AuthenticationType.AAD: @@ -210,7 +214,7 @@ def get(self, *, endpoint_name: str, populate_secrets: bool = False) -> Endpoint credential=self._config.credential, subscription_id=self._config.subscription_id, resource_group_name=self._config.resource_group_name, - workspace_name=self._config.workspace_name, + project_name=self._config.project_name, connection_name=endpoint_name, ) return EndpointProperties(connection=connection, token_credential=token_credential) diff --git a/sdk/ai/azure-ai-client/samples/agents/async_samples/sample_agents_basics_async.py b/sdk/ai/azure-ai-client/samples/agents/async_samples/sample_agents_basics_async.py index 2e89732c94ff..fd80e5077a43 100644 --- a/sdk/ai/azure-ai-client/samples/agents/async_samples/sample_agents_basics_async.py +++ b/sdk/ai/azure-ai-client/samples/agents/async_samples/sample_agents_basics_async.py @@ -34,11 +34,9 @@ async def main(): # At the moment, it should be in the format ";;;" # Customer needs to login to Azure subscription via Azure CLI and set the environment variables - connection_string = os.environ["AI_CLIENT_CONNECTION_STRING"] - ai_client = AzureAIClient.from_connection_string( credential=DefaultAzureCredential(), - connection=connection_string, + conn_str=os.environ["AI_CLIENT_CONNECTION_STRING"] ) # Or, you can create the Azure AI Client by giving all required parameters directly diff --git a/sdk/ai/azure-ai-client/samples/agents/async_samples/sample_agents_functions_async.py b/sdk/ai/azure-ai-client/samples/agents/async_samples/sample_agents_functions_async.py index 4aeb19e4d894..611da3150afe 100644 --- a/sdk/ai/azure-ai-client/samples/agents/async_samples/sample_agents_functions_async.py +++ b/sdk/ai/azure-ai-client/samples/agents/async_samples/sample_agents_functions_async.py @@ -36,11 +36,9 @@ async def main(): # At the moment, it should be in the format ";;;" # Customer needs to login to Azure subscription via Azure CLI and set the environment variables - connection_string = os.environ["AI_CLIENT_CONNECTION_STRING"] - ai_client = AzureAIClient.from_connection_string( credential=DefaultAzureCredential(), - connection=connection_string, + conn_str=os.environ["AI_CLIENT_CONNECTION_STRING"] ) # Or, you can create the Azure AI Client by giving all required parameters directly diff --git a/sdk/ai/azure-ai-client/samples/agents/async_samples/sample_agents_stream_eventhandler_async.py b/sdk/ai/azure-ai-client/samples/agents/async_samples/sample_agents_stream_eventhandler_async.py index 63476c3cacd1..8d11336e1dad 100644 --- a/sdk/ai/azure-ai-client/samples/agents/async_samples/sample_agents_stream_eventhandler_async.py +++ b/sdk/ai/azure-ai-client/samples/agents/async_samples/sample_agents_stream_eventhandler_async.py @@ -61,11 +61,9 @@ async def main(): # At the moment, it should be in the format ";;;" # Customer needs to login to Azure subscription via Azure CLI and set the environment variables - connection_string = os.environ["AI_CLIENT_CONNECTION_STRING"] - ai_client = AzureAIClient.from_connection_string( credential=DefaultAzureCredential(), - connection=connection_string, + conn_str=os.environ["AI_CLIENT_CONNECTION_STRING"] ) # Or, you can create the Azure AI Client by giving all required parameters directly diff --git a/sdk/ai/azure-ai-client/samples/agents/async_samples/sample_agents_stream_eventhandler_with_toolset_async.py b/sdk/ai/azure-ai-client/samples/agents/async_samples/sample_agents_stream_eventhandler_with_toolset_async.py index 777331e2afd0..c6d8cd869b59 100644 --- a/sdk/ai/azure-ai-client/samples/agents/async_samples/sample_agents_stream_eventhandler_with_toolset_async.py +++ b/sdk/ai/azure-ai-client/samples/agents/async_samples/sample_agents_stream_eventhandler_with_toolset_async.py @@ -102,11 +102,9 @@ async def main(): # At the moment, it should be in the format ";;;" # Customer needs to login to Azure subscription via Azure CLI and set the environment variables - connection_string = os.environ["AI_CLIENT_CONNECTION_STRING"] - ai_client = AzureAIClient.from_connection_string( credential=DefaultAzureCredential(), - connection=connection_string, + conn_str=os.environ["AI_CLIENT_CONNECTION_STRING"] ) # Or, you can create the Azure AI Client by giving all required parameters directly diff --git a/sdk/ai/azure-ai-client/samples/agents/async_samples/sample_agents_stream_iteration_async.py b/sdk/ai/azure-ai-client/samples/agents/async_samples/sample_agents_stream_iteration_async.py index fc6cc13efa93..6d1cf2fd89cb 100644 --- a/sdk/ai/azure-ai-client/samples/agents/async_samples/sample_agents_stream_iteration_async.py +++ b/sdk/ai/azure-ai-client/samples/agents/async_samples/sample_agents_stream_iteration_async.py @@ -34,11 +34,9 @@ async def main(): # At the moment, it should be in the format ";;;" # Customer needs to login to Azure subscription via Azure CLI and set the environment variables - connection_string = os.environ["AI_CLIENT_CONNECTION_STRING"] - ai_client = AzureAIClient.from_connection_string( credential=DefaultAzureCredential(), - connection=connection_string, + conn_str=os.environ["AI_CLIENT_CONNECTION_STRING"] ) # Or, you can create the Azure AI Client by giving all required parameters directly diff --git a/sdk/ai/azure-ai-client/samples/agents/async_samples/sample_agents_with_file_search_attachment_async.py b/sdk/ai/azure-ai-client/samples/agents/async_samples/sample_agents_with_file_search_attachment_async.py index 2e5df870ed82..3342d0741305 100644 --- a/sdk/ai/azure-ai-client/samples/agents/async_samples/sample_agents_with_file_search_attachment_async.py +++ b/sdk/ai/azure-ai-client/samples/agents/async_samples/sample_agents_with_file_search_attachment_async.py @@ -34,11 +34,9 @@ async def main(): # At the moment, it should be in the format ";;;" # Customer needs to login to Azure subscription via Azure CLI and set the environment variables - connection_string = os.environ["AI_CLIENT_CONNECTION_STRING"] - ai_client = AzureAIClient.from_connection_string( credential=DefaultAzureCredential(), - connection=connection_string, + conn_str=os.environ["AI_CLIENT_CONNECTION_STRING"] ) # Or, you can create the Azure AI Client by giving all required parameters directly diff --git a/sdk/ai/azure-ai-client/samples/agents/sample_agents_basics.py b/sdk/ai/azure-ai-client/samples/agents/sample_agents_basics.py index e3df8d7aa06b..f0d4e68d6219 100644 --- a/sdk/ai/azure-ai-client/samples/agents/sample_agents_basics.py +++ b/sdk/ai/azure-ai-client/samples/agents/sample_agents_basics.py @@ -29,24 +29,10 @@ # At the moment, it should be in the format ";;;" # Customer needs to login to Azure subscription via Azure CLI and set the environment variables -connection_string = os.environ["AI_CLIENT_CONNECTION_STRING"] - ai_client = AzureAIClient.from_connection_string( credential=DefaultAzureCredential(), - connection=connection_string, -) - -# Or, you can create the Azure AI Client by giving all required parameters directly -""" -ai_client = AzureAIClient( - credential=DefaultAzureCredential(), - host_name=os.environ["AI_CLIENT_HOST_NAME"], - subscription_id=os.environ["AI_CLIENT_SUBSCRIPTION_ID"], - resource_group_name=os.environ["AI_CLIENT_RESOURCE_GROUP_NAME"], - workspace_name=os.environ["AI_CLIENT_WORKSPACE_NAME"], - logging_enable=True, # Optional. Remove this line if you don't want to show how to enable logging + conn_str=os.environ["AI_CLIENT_CONNECTION_STRING"], ) -""" with ai_client: agent = ai_client.agents.create_agent( diff --git a/sdk/ai/azure-ai-client/samples/agents/sample_agents_code_interpreter_attachment.py b/sdk/ai/azure-ai-client/samples/agents/sample_agents_code_interpreter_attachment.py index fda7c863fc56..5f36c9de0e9e 100644 --- a/sdk/ai/azure-ai-client/samples/agents/sample_agents_code_interpreter_attachment.py +++ b/sdk/ai/azure-ai-client/samples/agents/sample_agents_code_interpreter_attachment.py @@ -33,11 +33,9 @@ # At the moment, it should be in the format ";;;" # Customer needs to login to Azure subscription via Azure CLI and set the environment variables -connection_string = os.environ["AI_CLIENT_CONNECTION_STRING"] - ai_client = AzureAIClient.from_connection_string( credential=DefaultAzureCredential(), - connection=connection_string, + conn_str=os.environ["AI_CLIENT_CONNECTION_STRING"] ) # Or, you can create the Azure AI Client by giving all required parameters directly diff --git a/sdk/ai/azure-ai-client/samples/agents/sample_agents_file_search.py b/sdk/ai/azure-ai-client/samples/agents/sample_agents_file_search.py index 599d9cb73696..3416906e0dbd 100644 --- a/sdk/ai/azure-ai-client/samples/agents/sample_agents_file_search.py +++ b/sdk/ai/azure-ai-client/samples/agents/sample_agents_file_search.py @@ -36,11 +36,9 @@ # At the moment, it should be in the format ";;;" # Customer needs to login to Azure subscription via Azure CLI and set the environment variables -connection_string = os.environ["AI_CLIENT_CONNECTION_STRING"] - ai_client = AzureAIClient.from_connection_string( credential=DefaultAzureCredential(), - connection=connection_string, + conn_str=os.environ["AI_CLIENT_CONNECTION_STRING"] ) # Or, you can create the Azure AI Client by giving all required parameters directly diff --git a/sdk/ai/azure-ai-client/samples/agents/sample_agents_functions.py b/sdk/ai/azure-ai-client/samples/agents/sample_agents_functions.py index c2a9ee348fb6..585874f0bf90 100644 --- a/sdk/ai/azure-ai-client/samples/agents/sample_agents_functions.py +++ b/sdk/ai/azure-ai-client/samples/agents/sample_agents_functions.py @@ -31,24 +31,10 @@ # At the moment, it should be in the format ";;;" # Customer needs to login to Azure subscription via Azure CLI and set the environment variables -connection_string = os.environ["AI_CLIENT_CONNECTION_STRING"] - ai_client = AzureAIClient.from_connection_string( credential=DefaultAzureCredential(), - connection=connection_string, -) - -# Or, you can create the Azure AI Client by giving all required parameters directly -""" -ai_client = AzureAIClient( - credential=DefaultAzureCredential(), - host_name=os.environ["AI_CLIENT_HOST_NAME"], - subscription_id=os.environ["AI_CLIENT_SUBSCRIPTION_ID"], - resource_group_name=os.environ["AI_CLIENT_RESOURCE_GROUP_NAME"], - workspace_name=os.environ["AI_CLIENT_WORKSPACE_NAME"], - logging_enable=True, # Optional. Remove this line if you don't want to show how to enable logging + conn_str=os.environ["AI_CLIENT_CONNECTION_STRING"] ) -""" # Initialize function tool with user functions functions = FunctionTool(functions=user_functions) diff --git a/sdk/ai/azure-ai-client/samples/agents/sample_agents_run_with_toolset.py b/sdk/ai/azure-ai-client/samples/agents/sample_agents_run_with_toolset.py index 34ee7dc290f7..75df4ab5f3cb 100644 --- a/sdk/ai/azure-ai-client/samples/agents/sample_agents_run_with_toolset.py +++ b/sdk/ai/azure-ai-client/samples/agents/sample_agents_run_with_toolset.py @@ -32,24 +32,10 @@ # At the moment, it should be in the format ";;;" # Customer needs to login to Azure subscription via Azure CLI and set the environment variables -connection_string = os.environ["AI_CLIENT_CONNECTION_STRING"] - ai_client = AzureAIClient.from_connection_string( credential=DefaultAzureCredential(), - connection=connection_string, -) - -# Or, you can create the Azure AI Client by giving all required parameters directly -""" -ai_client = AzureAIClient( - credential=DefaultAzureCredential(), - host_name=os.environ["AI_CLIENT_HOST_NAME"], - subscription_id=os.environ["AI_CLIENT_SUBSCRIPTION_ID"], - resource_group_name=os.environ["AI_CLIENT_RESOURCE_GROUP_NAME"], - workspace_name=os.environ["AI_CLIENT_WORKSPACE_NAME"], - logging_enable=True, # Optional. Remove this line if you don't want to show how to enable logging + conn_str=os.environ["AI_CLIENT_CONNECTION_STRING"], ) -""" # Initialize agent toolset with user functions and code interpreter functions = FunctionTool(user_functions) diff --git a/sdk/ai/azure-ai-client/samples/agents/sample_agents_stream_eventhandler.py b/sdk/ai/azure-ai-client/samples/agents/sample_agents_stream_eventhandler.py index 72f6eafedb3f..eeecf71292b5 100644 --- a/sdk/ai/azure-ai-client/samples/agents/sample_agents_stream_eventhandler.py +++ b/sdk/ai/azure-ai-client/samples/agents/sample_agents_stream_eventhandler.py @@ -41,24 +41,10 @@ # At the moment, it should be in the format ";;;" # Customer needs to login to Azure subscription via Azure CLI and set the environment variables -connection_string = os.environ["AI_CLIENT_CONNECTION_STRING"] - ai_client = AzureAIClient.from_connection_string( credential=DefaultAzureCredential(), - connection=connection_string, -) - -# Or, you can create the Azure AI Client by giving all required parameters directly -""" -ai_client = AzureAIClient( - credential=DefaultAzureCredential(), - host_name=os.environ["AI_CLIENT_HOST_NAME"], - subscription_id=os.environ["AI_CLIENT_SUBSCRIPTION_ID"], - resource_group_name=os.environ["AI_CLIENT_RESOURCE_GROUP_NAME"], - workspace_name=os.environ["AI_CLIENT_WORKSPACE_NAME"], - logging_enable=True, # Optional. Remove this line if you don't want to show how to enable logging + conn_str=os.environ["AI_CLIENT_CONNECTION_STRING"], ) -""" class MyEventHandler(AgentEventHandler): def on_message_delta(self, delta: "MessageDeltaChunk") -> None: diff --git a/sdk/ai/azure-ai-client/samples/agents/sample_agents_stream_eventhandler_with_toolset.py b/sdk/ai/azure-ai-client/samples/agents/sample_agents_stream_eventhandler_with_toolset.py index 52331386e780..1071cd24aa58 100644 --- a/sdk/ai/azure-ai-client/samples/agents/sample_agents_stream_eventhandler_with_toolset.py +++ b/sdk/ai/azure-ai-client/samples/agents/sample_agents_stream_eventhandler_with_toolset.py @@ -40,11 +40,9 @@ # At the moment, it should be in the format ";;;" # Customer needs to login to Azure subscription via Azure CLI and set the environment variables -connection_string = os.environ["AI_CLIENT_CONNECTION_STRING"] - ai_client = AzureAIClient.from_connection_string( credential=DefaultAzureCredential(), - connection=connection_string, + conn_str=os.environ["AI_CLIENT_CONNECTION_STRING"] ) # Or, you can create the Azure AI Client by giving all required parameters directly diff --git a/sdk/ai/azure-ai-client/samples/agents/sample_agents_stream_iteration.py b/sdk/ai/azure-ai-client/samples/agents/sample_agents_stream_iteration.py index 3fba6a251eda..dc1036017b09 100644 --- a/sdk/ai/azure-ai-client/samples/agents/sample_agents_stream_iteration.py +++ b/sdk/ai/azure-ai-client/samples/agents/sample_agents_stream_iteration.py @@ -38,24 +38,10 @@ # At the moment, it should be in the format ";;;" # Customer needs to login to Azure subscription via Azure CLI and set the environment variables -connection_string = os.environ["AI_CLIENT_CONNECTION_STRING"] - ai_client = AzureAIClient.from_connection_string( credential=DefaultAzureCredential(), - connection=connection_string, -) - -# Or, you can create the Azure AI Client by giving all required parameters directly -""" -ai_client = AzureAIClient( - credential=DefaultAzureCredential(), - host_name=os.environ["AI_CLIENT_HOST_NAME"], - subscription_id=os.environ["AI_CLIENT_SUBSCRIPTION_ID"], - resource_group_name=os.environ["AI_CLIENT_RESOURCE_GROUP_NAME"], - workspace_name=os.environ["AI_CLIENT_WORKSPACE_NAME"], - logging_enable=True, # Optional. Remove this line if you don't want to show how to enable logging + conn_str=os.environ["AI_CLIENT_CONNECTION_STRING"], ) -""" with ai_client: # Create an agent and run stream with iteration diff --git a/sdk/ai/azure-ai-client/samples/agents/sample_agents_stream_iteration_with_toolset.py b/sdk/ai/azure-ai-client/samples/agents/sample_agents_stream_iteration_with_toolset.py index 880420249ae2..a34fb5c1912e 100644 --- a/sdk/ai/azure-ai-client/samples/agents/sample_agents_stream_iteration_with_toolset.py +++ b/sdk/ai/azure-ai-client/samples/agents/sample_agents_stream_iteration_with_toolset.py @@ -35,11 +35,9 @@ # At the moment, it should be in the format ";;;" # Customer needs to login to Azure subscription via Azure CLI and set the environment variables -connection_string = os.environ["AI_CLIENT_CONNECTION_STRING"] - ai_client = AzureAIClient.from_connection_string( credential=DefaultAzureCredential(), - connection=connection_string, + conn_str=os.environ["AI_CLIENT_CONNECTION_STRING"] ) # Or, you can create the Azure AI Client by giving all required parameters directly diff --git a/sdk/ai/azure-ai-client/samples/agents/sample_agents_with_file_search_attachment.py b/sdk/ai/azure-ai-client/samples/agents/sample_agents_with_file_search_attachment.py index 97de3ba1382e..293d32c539b7 100644 --- a/sdk/ai/azure-ai-client/samples/agents/sample_agents_with_file_search_attachment.py +++ b/sdk/ai/azure-ai-client/samples/agents/sample_agents_with_file_search_attachment.py @@ -33,11 +33,9 @@ # At the moment, it should be in the format ";;;" # Customer needs to login to Azure subscription via Azure CLI and set the environment variables -connection_string = os.environ["AI_CLIENT_CONNECTION_STRING"] - ai_client = AzureAIClient.from_connection_string( credential=DefaultAzureCredential(), - connection=connection_string, + conn_str=os.environ["AI_CLIENT_CONNECTION_STRING"] ) # Or, you can create the Azure AI Client by giving all required parameters directly diff --git a/sdk/ai/azure-ai-client/samples/endpoints/async_samples/sample_endpoints_async.py b/sdk/ai/azure-ai-client/samples/endpoints/async_samples/sample_endpoints_async.py index 2ee646d8eb7e..66cc29821061 100644 --- a/sdk/ai/azure-ai-client/samples/endpoints/async_samples/sample_endpoints_async.py +++ b/sdk/ai/azure-ai-client/samples/endpoints/async_samples/sample_endpoints_async.py @@ -4,13 +4,14 @@ # ------------------------------------ """ -FILE: sample_endpoints_async +FILE: sample_endpoints_async.py DESCRIPTION: - This sample demonstrates how to enumerate and get endpoints from an AzureAIClient. + Given an asynchronous AzureAIClient, this sample demonstrates how to enumerate endpoints + and get endpoint properties. USAGE: - python sample_endpoints_async + python sample_endpoints_async.py Before running the sample: @@ -24,11 +25,7 @@ import os from azure.ai.client.aio import AzureAIClient from azure.ai.client.models import EndpointType, AuthenticationType -from openai import AzureOpenAI -from azure.ai.inference.aio import ChatCompletionsClient -from azure.ai.inference.models import UserMessage -from azure.identity import DefaultAzureCredential, get_bearer_token_provider -from azure.core.credentials import AzureKeyCredential +from azure.identity import DefaultAzureCredential async def sample_endpoints_async(): @@ -36,18 +33,9 @@ async def sample_endpoints_async(): # It should be in the format ";;;" async with AzureAIClient.from_connection_string( credential=DefaultAzureCredential(), - connection=os.environ["AI_CLIENT_CONNECTION_STRING"], + conn_str=os.environ["AI_CLIENT_CONNECTION_STRING"], ) as ai_client: - # Or, you can create the Azure AI Client by giving all required parameters directly - # async with AzureAIClient( - # credential=DefaultAzureCredential(), - # endpoint=os.environ["AI_CLIENT_ENDPOINT"], - # subscription_id=os.environ["AI_CLIENT_SUBSCRIPTION_ID"], - # resource_group_name=os.environ["AI_CLIENT_RESOURCE_GROUP_NAME"], - # workspace_name=os.environ["AI_CLIENT_WORKSPACE_NAME"], - # ) as ai_client: - # List all endpoints of a particular "type", with or without their credentials: print("====> Listing of all Azure Open AI endpoints:") async for endpoint in ai_client.endpoints.list( @@ -59,83 +47,85 @@ async def sample_endpoints_async(): # Get the default endpoint of a particular "type" (note that since at the moment the service # does not have a notion of a default endpoint, this will return the first endpoint of that type): endpoint = await ai_client.endpoints.get_default( - endpoint_type=EndpointType.AZURE_OPEN_AI, populate_secrets=True # Required. # Optional. Defaults to "False" + endpoint_type=EndpointType.AZURE_OPEN_AI, + populate_secrets=True, # Required. # Optional. Defaults to "False" ) print("====> Get default Azure Open AI endpoint:") print(endpoint) # Get an endpoint by its name: endpoint = await ai_client.endpoints.get( - endpoint_name=os.environ["AI_CLIENT_CONNECTION_NAME"], populate_secrets=True # Required. + endpoint_name=os.environ["AI_CLIENT_ENDPOINT_NAME"], populate_secrets=True # Required. ) print("====> Get endpoint by name:") print(endpoint) - exit() - - # Here is how you would create the appropriate AOAI or Inference SDK for these endpoint - if endpoint.endpoint_type == EndpointType.AZURE_OPEN_AI: - - if endpoint.authentication_type == AuthenticationType.API_KEY: - print("====> Creating AzureOpenAI client using API key authentication") - client = AzureOpenAI( - api_key=endpoint.key, - azure_endpoint=endpoint.endpoint_url, - api_version="2024-08-01-preview", # TODO: Is this needed? - ) - elif endpoint.authentication_type == AuthenticationType.AAD: - print("====> Creating AzureOpenAI client using Entra ID authentication") - client = AzureOpenAI( - # See https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity?view=azure-python#azure-identity-get-bearer-token-provider - azure_ad_token_provider=get_bearer_token_provider( - endpoint.token_credential, "https://cognitiveservices.azure.com/.default" - ), - azure_endpoint=endpoint.endpoint_url, - api_version="2024-08-01-preview", - ) - elif endpoint.authentication_type == AuthenticationType.SAS: - # TODO - Not yet supported by the service. Expected 9/27. - print("====> Creating AzureOpenAI client using SAS authentication") - client = AzureOpenAI( - azure_ad_token_provider=get_bearer_token_provider( - endpoint.token_credential, "https://cognitiveservices.azure.com/.default" - ), - azure_endpoint=endpoint.endpoint_url, - api_version="2024-08-01-preview", - ) - - response = client.chat.completions.create( - model="gpt-4o", - messages=[ - { - "role": "user", - "content": "How many feet are in a mile?", - }, - ], + # Examples of how you would create Inference client + if endpoint.endpoint_type == EndpointType.AZURE_OPEN_AI: + + from openai import AsyncAzureOpenAI + + if endpoint.authentication_type == AuthenticationType.API_KEY: + print("====> Creating AzureOpenAI client using API key authentication") + client = AsyncAzureOpenAI( + api_key=endpoint.key, + azure_endpoint=endpoint.endpoint_url, + api_version="2024-06-01" # See "Data plane - inference" row in table https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#api-specs ) + elif endpoint.authentication_type == AuthenticationType.AAD: + print("====> Creating AzureOpenAI client using Entra ID authentication") + from azure.identity import get_bearer_token_provider + client = AsyncAzureOpenAI( + # See https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity?view=azure-python#azure-identity-get-bearer-token-provider + azure_ad_token_provider=get_bearer_token_provider( + endpoint.token_credential, "https://cognitiveservices.azure.com/.default" + ), + azure_endpoint=endpoint.endpoint_url, + api_version="2024-06-01" # See "Data plane - inference" row in table https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#api-specs + ) + else: + raise ValueError(f"Authentication type {endpoint.authentication_type} not supported.") + + response = await client.chat.completions.create( + model="gpt-4o", + messages=[ + { + "role": "user", + "content": "How many feet are in a mile?", + }, + ], + ) + print(response.choices[0].message.content) - print(response.choices[0].message.content) + elif endpoint.endpoint_type == EndpointType.SERVERLESS: - elif endpoint.endpoint_type == EndpointType.SERVERLESS: + from azure.ai.inference.aio import ChatCompletionsClient + from azure.ai.inference.models import UserMessage - if endpoint.authentication_type == AuthenticationType.API_KEY: - print("====> Creating ChatCompletionsClient using API key authentication") - client = ChatCompletionsClient(endpoint=endpoint.endpoint_url, credential=AzureKeyCredential(endpoint.key)) - elif endpoint.authentication_type == AuthenticationType.AAD: - # MaaS models do not yet support EntraID auth - print("====> Creating ChatCompletionsClient using Entra ID authentication") - client = ChatCompletionsClient(endpoint=endpoint.endpoint_url, credential=endpoint.properties.token_credential) - elif endpoint.authentication_type == AuthenticationType.SAS: - # TODO - Not yet supported by the service. Expected 9/27. - print("====> Creating ChatCompletionsClient using SAS authentication") - client = ChatCompletionsClient(endpoint=endpoint.endpoint_url, credential=endpoint.token_credential) + if endpoint.authentication_type == AuthenticationType.API_KEY: + print("====> Creating ChatCompletionsClient using API key authentication") + from azure.core.credentials import AzureKeyCredential + client = ChatCompletionsClient( + endpoint=endpoint.endpoint_url, credential=AzureKeyCredential(endpoint.key) + ) + elif endpoint.authentication_type == AuthenticationType.AAD: + # MaaS models do not yet support EntraID auth + print("====> Creating ChatCompletionsClient using Entra ID authentication") + client = ChatCompletionsClient( + endpoint=endpoint.endpoint_url, credential=endpoint.properties.token_credential + ) + else: + raise ValueError(f"Authentication type {endpoint.authentication_type} not supported.") - response = client.complete(messages=[UserMessage(content="How many feet are in a mile?")]) + response = await client.complete(messages=[UserMessage(content="How many feet are in a mile?")]) + await client.close() + print(response.choices[0].message.content) - print(response.choices[0].message.content) async def main(): await sample_endpoints_async() + if __name__ == "__main__": - asyncio.run(main()) \ No newline at end of file + asyncio.run(main()) + diff --git a/sdk/ai/azure-ai-client/samples/endpoints/sample_endpoints.py b/sdk/ai/azure-ai-client/samples/endpoints/sample_endpoints.py index e19cc7191d84..51a49f309f42 100644 --- a/sdk/ai/azure-ai-client/samples/endpoints/sample_endpoints.py +++ b/sdk/ai/azure-ai-client/samples/endpoints/sample_endpoints.py @@ -3,6 +3,24 @@ # Licensed under the MIT License. # ------------------------------------ +""" +FILE: sample_endpoints.py + +DESCRIPTION: + Given an AzureAIClient, this sample demonstrates how to enumerate endpoints + and get endpoint properties. + +USAGE: + python sample_endpoints.py + + Before running the sample: + + pip install azure.ai.client azure-identity + + Set the environment variables with your own values: + 1) AI_CLIENT_CONNECTION_STRING - the Azure AI Project connection string, as found in your AI Studio Project. +""" + import os from azure.ai.client import AzureAIClient from azure.ai.client.models import EndpointType, AuthenticationType @@ -14,47 +32,37 @@ # Create an Azure AI Client from a connection string, copied from your AI Studio project. # It should be in the format ";;;" -ai_client = AzureAIClient.from_connection_string( +with AzureAIClient.from_connection_string( credential=DefaultAzureCredential(), - connection=os.environ["AI_CLIENT_CONNECTION_STRING"], -) - -# Or, you can create the Azure AI Client by giving all required parameters directly -# ai_client = AzureAIClient( -# credential=DefaultAzureCredential(), -# endpoint=os.environ["AI_CLIENT_ENDPOINT"], -# subscription_id=os.environ["AI_CLIENT_SUBSCRIPTION_ID"], -# resource_group_name=os.environ["AI_CLIENT_RESOURCE_GROUP_NAME"], -# workspace_name=os.environ["AI_CLIENT_WORKSPACE_NAME"], -# ) - -# List all endpoints of a particular "type", with or without their credentials: -endpoints = ai_client.endpoints.list( - endpoint_type=EndpointType.AZURE_OPEN_AI, # Optional. Defaults to all types. - populate_secrets=True, # Optional. Defaults to "False" -) -print("====> Listing of all Azure Open AI endpoints:") -for endpoint in endpoints: - print(endpoint) + conn_str=os.environ["AI_CLIENT_CONNECTION_STRING"], +) as ai_client: -# Get the default endpoint of a particular "type" (note that since at the moment the service -# does not have a notion of a default endpoint, this will return the first endpoint of that type): -endpoint = ai_client.endpoints.get_default( - endpoint_type=EndpointType.AZURE_OPEN_AI, populate_secrets=True # Required. # Optional. Defaults to "False" -) -print("====> Get default Azure Open AI endpoint:") -print(endpoint) + # List all endpoints of a particular "type", with or without their credentials: + endpoints = ai_client.endpoints.list( + endpoint_type=EndpointType.AZURE_OPEN_AI, # Optional. Defaults to all types. + populate_secrets=True, # Optional. Defaults to "False" + ) + print("====> Listing of all Azure Open AI endpoints:") + for endpoint in endpoints: + print(endpoint) -# Get an endpoint by its name: -endpoint = ai_client.endpoints.get( - endpoint_name=os.environ["AI_CLIENT_CONNECTION_NAME"], populate_secrets=True # Required. -) -print("====> Get endpoint by name:") -print(endpoint) + # Get the default endpoint of a particular "type" (note that since at the moment the service + # does not have a notion of a default endpoint, this will return the first endpoint of that type): + endpoint = ai_client.endpoints.get_default( + endpoint_type=EndpointType.AZURE_OPEN_AI, populate_secrets=True # Required. # Optional. Defaults to "False" + ) + print("====> Get default Azure Open AI endpoint:") + print(endpoint) + + # Get an endpoint by its name: + endpoint = ai_client.endpoints.get( + endpoint_name=os.environ["AI_CLIENT_ENDPOINT_NAME"], populate_secrets=True # Required. + ) + print("====> Get endpoint by name:") + print(endpoint) -exit() -# Here is how you would create the appropriate AOAI or Inference SDK for these endpoint +# Examples of how you would create Inference client if endpoint.endpoint_type == EndpointType.AZURE_OPEN_AI: if endpoint.authentication_type == AuthenticationType.API_KEY: @@ -62,7 +70,7 @@ client = AzureOpenAI( api_key=endpoint.key, azure_endpoint=endpoint.endpoint_url, - api_version="2024-08-01-preview", # TODO: Is this needed? + api_version="2024-06-01" # See "Data plane - inference" row in table https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#api-specs ) elif endpoint.authentication_type == AuthenticationType.AAD: print("====> Creating AzureOpenAI client using Entra ID authentication") @@ -72,18 +80,10 @@ endpoint.token_credential, "https://cognitiveservices.azure.com/.default" ), azure_endpoint=endpoint.endpoint_url, - api_version="2024-08-01-preview", - ) - elif endpoint.authentication_type == AuthenticationType.SAS: - # TODO - Not yet supported by the service. Expected 9/27. - print("====> Creating AzureOpenAI client using SAS authentication") - client = AzureOpenAI( - azure_ad_token_provider=get_bearer_token_provider( - endpoint.token_credential, "https://cognitiveservices.azure.com/.default" - ), - azure_endpoint=endpoint.endpoint_url, - api_version="2024-08-01-preview", + api_version="2024-06-01" # See "Data plane - inference" row in table https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#api-specs ) + else: + raise ValueError(f"Authentication type {endpoint.authentication_type} not supported.") response = client.chat.completions.create( model="gpt-4o", @@ -94,7 +94,7 @@ }, ], ) - + client.close() print(response.choices[0].message.content) elif endpoint.endpoint_type == EndpointType.SERVERLESS: @@ -106,11 +106,9 @@ # MaaS models do not yet support EntraID auth print("====> Creating ChatCompletionsClient using Entra ID authentication") client = ChatCompletionsClient(endpoint=endpoint.endpoint_url, credential=endpoint.properties.token_credential) - elif endpoint.authentication_type == AuthenticationType.SAS: - # TODO - Not yet supported by the service. Expected 9/27. - print("====> Creating ChatCompletionsClient using SAS authentication") - client = ChatCompletionsClient(endpoint=endpoint.endpoint_url, credential=endpoint.token_credential) + else: + raise ValueError(f"Authentication type {endpoint.authentication_type} not supported.") response = client.complete(messages=[UserMessage(content="How many feet are in a mile?")]) - + client.close() print(response.choices[0].message.content) diff --git a/sdk/ai/azure-ai-client/samples/evaluations/sample_evaluations.py b/sdk/ai/azure-ai-client/samples/evaluations/sample_evaluations.py index cf260c12bcc0..5f30c2717dda 100644 --- a/sdk/ai/azure-ai-client/samples/evaluations/sample_evaluations.py +++ b/sdk/ai/azure-ai-client/samples/evaluations/sample_evaluations.py @@ -17,7 +17,7 @@ # Create an Azure AI client ai_client = AzureAIClient.from_connection_string( credential=DefaultAzureCredential(), - connection=f"{Endpoint};{Subscription};{ResourceGroup};{Workspace}", + conn_str=f"{Endpoint};{Subscription};{ResourceGroup};{Workspace}", logging_enable=True, # Optional. Remove this line if you don't want to show how to enable logging ) diff --git a/sdk/ai/azure-ai-client/samples/inference/async_samples/sample_get_azure_openai_client_async.py b/sdk/ai/azure-ai-client/samples/inference/async_samples/sample_get_azure_openai_client_async.py index e2d03086acf5..3376675d4b5a 100644 --- a/sdk/ai/azure-ai-client/samples/inference/async_samples/sample_get_azure_openai_client_async.py +++ b/sdk/ai/azure-ai-client/samples/inference/async_samples/sample_get_azure_openai_client_async.py @@ -25,24 +25,14 @@ from azure.ai.client.aio import AzureAIClient from azure.identity import DefaultAzureCredential + async def sample_get_azure_openai_client_async(): - # Create an Azure AI Client from a connection string, copied from your AI Studio project. - # It should have the format ";;;" async with AzureAIClient.from_connection_string( credential=DefaultAzureCredential(), - connection=os.environ["AI_CLIENT_CONNECTION_STRING"], + conn_str=os.environ["AI_CLIENT_CONNECTION_STRING"], ) as ai_client: - # Or, you can create the Azure AI Client by giving all required parameters directly - # async with AzureAIClient( - # credential=DefaultAzureCredential(), - # endpoint=os.environ["AI_CLIENT_ENDPOINT"], - # subscription_id=os.environ["AI_CLIENT_SUBSCRIPTION_ID"], - # resource_group_name=os.environ["AI_CLIENT_RESOURCE_GROUP_NAME"], - # workspace_name=os.environ["AI_CLIENT_WORKSPACE_NAME"], - # ) as ai_client: - # Get an authenticated AsyncAzureOpenAI client for your default Azure OpenAI connection: async with await ai_client.inference.get_azure_openai_client() as client: @@ -58,8 +48,10 @@ async def sample_get_azure_openai_client_async(): print(response.choices[0].message.content) + async def main(): await sample_get_azure_openai_client_async() + if __name__ == "__main__": asyncio.run(main()) diff --git a/sdk/ai/azure-ai-client/samples/inference/async_samples/sample_get_chat_completions_client_async.py b/sdk/ai/azure-ai-client/samples/inference/async_samples/sample_get_chat_completions_client_async.py index 27201ddef947..625b4b3fc7b1 100644 --- a/sdk/ai/azure-ai-client/samples/inference/async_samples/sample_get_chat_completions_client_async.py +++ b/sdk/ai/azure-ai-client/samples/inference/async_samples/sample_get_chat_completions_client_async.py @@ -26,24 +26,14 @@ from azure.ai.inference.models import UserMessage from azure.identity import DefaultAzureCredential + async def sample_get_chat_completions_client_async(): - # Create an Azure AI Client from a connection string, copied from your AI Studio project. - # It should have the format ";;;" async with AzureAIClient.from_connection_string( credential=DefaultAzureCredential(), - connection=os.environ["AI_CLIENT_CONNECTION_STRING"], + conn_str=os.environ["AI_CLIENT_CONNECTION_STRING"], ) as ai_client: - # Or, you can create the Azure AI Client by giving all required parameters directly - # async with AzureAIClient( - # credential=DefaultAzureCredential(), - # endpoint=os.environ["AI_CLIENT_ENDPOINT"], - # subscription_id=os.environ["AI_CLIENT_SUBSCRIPTION_ID"], - # resource_group_name=os.environ["AI_CLIENT_RESOURCE_GROUP_NAME"], - # workspace_name=os.environ["AI_CLIENT_WORKSPACE_NAME"], - # ) as ai_client: - # Get an authenticated async ChatCompletionsClient (from azure.ai.inference) for your default Serverless connection: async with await ai_client.inference.get_chat_completions_client() as client: @@ -54,5 +44,6 @@ async def sample_get_chat_completions_client_async(): async def main(): await sample_get_chat_completions_client_async() + if __name__ == "__main__": asyncio.run(main()) diff --git a/sdk/ai/azure-ai-client/samples/inference/async_samples/sample_get_embeddings_client_async.py b/sdk/ai/azure-ai-client/samples/inference/async_samples/sample_get_embeddings_client_async.py index 051ba27eb26d..cd6022f4c8a2 100644 --- a/sdk/ai/azure-ai-client/samples/inference/async_samples/sample_get_embeddings_client_async.py +++ b/sdk/ai/azure-ai-client/samples/inference/async_samples/sample_get_embeddings_client_async.py @@ -25,24 +25,14 @@ from azure.ai.client.aio import AzureAIClient from azure.identity import DefaultAzureCredential + async def sample_get_embeddings_client_async(): - # Create an Azure AI Client from a connection string, copied from your AI Studio project. - # It should have the format ";;;" async with AzureAIClient.from_connection_string( credential=DefaultAzureCredential(), - connection=os.environ["AI_CLIENT_CONNECTION_STRING"], + conn_str=os.environ["AI_CLIENT_CONNECTION_STRING"], ) as ai_client: - # Or, you can create the Azure AI Client by giving all required parameters directly - # async with AzureAIClient( - # credential=DefaultAzureCredential(), - # endpoint=os.environ["AI_CLIENT_ENDPOINT"], - # subscription_id=os.environ["AI_CLIENT_SUBSCRIPTION_ID"], - # resource_group_name=os.environ["AI_CLIENT_RESOURCE_GROUP_NAME"], - # workspace_name=os.environ["AI_CLIENT_WORKSPACE_NAME"], - # ) as ai_client: - # Get an authenticated async azure.ai.inference embeddings client for your default Serverless connection: async with await ai_client.inference.get_embeddings_client() as client: @@ -59,5 +49,7 @@ async def sample_get_embeddings_client_async(): async def main(): await sample_get_embeddings_client_async() + if __name__ == "__main__": - asyncio.run(main()) \ No newline at end of file + asyncio.run(main()) + diff --git a/sdk/ai/azure-ai-client/samples/inference/sample_get_azure_openai_client.py b/sdk/ai/azure-ai-client/samples/inference/sample_get_azure_openai_client.py index 73f8c00ccd6e..4d2c0dab80fd 100644 --- a/sdk/ai/azure-ai-client/samples/inference/sample_get_azure_openai_client.py +++ b/sdk/ai/azure-ai-client/samples/inference/sample_get_azure_openai_client.py @@ -24,33 +24,22 @@ from azure.ai.client import AzureAIClient from azure.identity import DefaultAzureCredential -# Create an Azure AI Client from a connection string, copied from your AI Studio project. -# It should have the format ";;;" -ai_client = AzureAIClient.from_connection_string( +with AzureAIClient.from_connection_string( credential=DefaultAzureCredential(), - connection=os.environ["AI_CLIENT_CONNECTION_STRING"], -) - -# Or, you can create the Azure AI Client by giving all required parameters directly -# ai_client = AzureAIClient( -# credential=DefaultAzureCredential(), -# endpoint=os.environ["AI_CLIENT_ENDPOINT"], -# subscription_id=os.environ["AI_CLIENT_SUBSCRIPTION_ID"], -# resource_group_name=os.environ["AI_CLIENT_RESOURCE_GROUP_NAME"], -# workspace_name=os.environ["AI_CLIENT_WORKSPACE_NAME"], -# ) - -# Get an authenticated OpenAI client for your default Azure OpenAI connection: -client = ai_client.inference.get_azure_openai_client() - -response = client.chat.completions.create( - model="gpt-4-0613", - messages=[ - { - "role": "user", - "content": "How many feet are in a mile?", - }, - ], -) - -print(response.choices[0].message.content) + conn_str=os.environ["AI_CLIENT_CONNECTION_STRING"], +) as ai_client: + + # Get an authenticated OpenAI client for your default Azure OpenAI connection: + with ai_client.inference.get_azure_openai_client() as client: + + response = client.chat.completions.create( + model="gpt-4-0613", + messages=[ + { + "role": "user", + "content": "How many feet are in a mile?", + }, + ], + ) + + print(response.choices[0].message.content) diff --git a/sdk/ai/azure-ai-client/samples/inference/sample_get_chat_completions_client.py b/sdk/ai/azure-ai-client/samples/inference/sample_get_chat_completions_client.py index 20ac52c8dd0a..af508bd87571 100644 --- a/sdk/ai/azure-ai-client/samples/inference/sample_get_chat_completions_client.py +++ b/sdk/ai/azure-ai-client/samples/inference/sample_get_chat_completions_client.py @@ -25,25 +25,14 @@ from azure.ai.inference.models import UserMessage from azure.identity import DefaultAzureCredential -# Create an Azure AI Client from a connection string, copied from your AI Studio project. -# It should have the format ";;;" -ai_client = AzureAIClient.from_connection_string( +with AzureAIClient.from_connection_string( credential=DefaultAzureCredential(), - connection=os.environ["AI_CLIENT_CONNECTION_STRING"], -) + conn_str=os.environ["AI_CLIENT_CONNECTION_STRING"], +) as ai_client: -# Or, you can create the Azure AI Client by giving all required parameters directly -# ai_client = AzureAIClient( -# credential=DefaultAzureCredential(), -# endpoint=os.environ["AI_CLIENT_ENDPOINT"], -# subscription_id=os.environ["AI_CLIENT_SUBSCRIPTION_ID"], -# resource_group_name=os.environ["AI_CLIENT_RESOURCE_GROUP_NAME"], -# workspace_name=os.environ["AI_CLIENT_WORKSPACE_NAME"], -# ) + # Get an authenticated azure.ai.inference chat completions client for your default Serverless connection: + with ai_client.inference.get_chat_completions_client() as client: -# Get an authenticated azure.ai.inference chat completions client for your default Serverless connection: -client = ai_client.inference.get_chat_completions_client() + response = client.complete(messages=[UserMessage(content="How many feet are in a mile?")]) -response = client.complete(messages=[UserMessage(content="How many feet are in a mile?")]) - -print(response.choices[0].message.content) + print(response.choices[0].message.content) diff --git a/sdk/ai/azure-ai-client/samples/inference/sample_get_embeddings_client.py b/sdk/ai/azure-ai-client/samples/inference/sample_get_embeddings_client.py index cc6a306685ad..e1a1a22dae82 100644 --- a/sdk/ai/azure-ai-client/samples/inference/sample_get_embeddings_client.py +++ b/sdk/ai/azure-ai-client/samples/inference/sample_get_embeddings_client.py @@ -24,30 +24,19 @@ from azure.ai.client import AzureAIClient from azure.identity import DefaultAzureCredential -# Create an Azure AI Client from a connection string, copied from your AI Studio project. -# It should have the format ";;;" -ai_client = AzureAIClient.from_connection_string( +with AzureAIClient.from_connection_string( credential=DefaultAzureCredential(), - connection=os.environ["AI_CLIENT_CONNECTION_STRING"], -) - -# Or, you can create the Azure AI Client by giving all required parameters directly -# ai_client = AzureAIClient( -# credential=DefaultAzureCredential(), -# endpoint=os.environ["AI_CLIENT_ENDPOINT"], -# subscription_id=os.environ["AI_CLIENT_SUBSCRIPTION_ID"], -# resource_group_name=os.environ["AI_CLIENT_RESOURCE_GROUP_NAME"], -# workspace_name=os.environ["AI_CLIENT_WORKSPACE_NAME"], -# ) - -# Get an authenticated azure.ai.inference embeddings client for your default Serverless connection: -client = ai_client.inference.get_embeddings_client() - -response = client.embed(input=["first phrase", "second phrase", "third phrase"]) - -for item in response.data: - length = len(item.embedding) - print( - f"data[{item.index}]: length={length}, [{item.embedding[0]}, {item.embedding[1]}, " - f"..., {item.embedding[length-2]}, {item.embedding[length-1]}]" - ) + conn_str=os.environ["AI_CLIENT_CONNECTION_STRING"], +) as ai_client: + + # Get an authenticated azure.ai.inference embeddings client for your default Serverless connection: + with ai_client.inference.get_embeddings_client() as client: + + response = client.embed(input=["first phrase", "second phrase", "third phrase"]) + + for item in response.data: + length = len(item.embedding) + print( + f"data[{item.index}]: length={length}, [{item.embedding[0]}, {item.embedding[1]}, " + f"..., {item.embedding[length-2]}, {item.embedding[length-1]}]" + ) diff --git a/sdk/ai/azure-ai-client/tests/endpoints/unit_tests.py b/sdk/ai/azure-ai-client/tests/endpoints/unit_tests.py index 7bd10564b4d0..341224aae4e5 100644 --- a/sdk/ai/azure-ai-client/tests/endpoints/unit_tests.py +++ b/sdk/ai/azure-ai-client/tests/endpoints/unit_tests.py @@ -75,7 +75,7 @@ def test_sas_token_credential_class_mocked(self, **kwargs): credential=FakeTokenCredential(), subscription_id="fake_subscription_id", resource_group_name="fake_resouce_group", - workspace_name="fake_workspace_name", + project_name="fake_project_name", connection_name="fake_connection_name", ) assert sas_token_credential._expires_on == sas_token_expiration @@ -106,7 +106,7 @@ def test_sas_token_credential_class_real(self, **kwargs): credential=None, subscription_id=None, resource_group_name=None, - workspace_name=None, + project_name=None, connection_name=None, ) diff --git a/sdk/ai/azure-ai-client/tsp-location.yaml b/sdk/ai/azure-ai-client/tsp-location.yaml index 2746197f6f58..283f9c571164 100644 --- a/sdk/ai/azure-ai-client/tsp-location.yaml +++ b/sdk/ai/azure-ai-client/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/ai/Azure.AI.Client -commit: 075ca688a475e4fbbbcfc2af8aa18bd6a9ff7680 +commit: 6335d810e99108296eb601a9b7191b08b9368c29 repo: Azure/azure-rest-api-specs additionalDirectories: