azure.ai.resources.client package¶
- class azure.ai.resources.client.AIClient(credential: TokenCredential, subscription_id: str, resource_group_name: str, ai_resource_name: str | None = None, project_name: str | None = None, **kwargs: Any)[source]¶
Note
This is an experimental class, and may change at any time. Please see https://aka.ms/azuremlexperimental for more information.
A client class to interact with Azure AI services.
Use this client to manage Azure AI resources such as MLIndexes, jobs, models, and so on.
- Parameters:
credential (TokenCredential) – The credential object.
subscription_id (str) – The Azure subscription ID.
resource_group_name (str) – The name of the resource group.
ai_resource_name (Optional[str]) – The name of the AI resource.
project_name (Optional[str]) – The name of the AI project.
- build_index_on_cloud(*, output_index_name: str, vector_store: str, data_source_url: str | None = None, chunk_size: int | None = None, chunk_overlap: int | None = None, input_glob: str | None = None, max_sample_files: int | None = None, chunk_prepend_summary: bool | None = None, document_path_replacement_regex: str | None = None, embeddings_model: str = 'text-embedding-ada-002', aoai_connection_id: str = 'Default_AzureOpenAI', acs_config: ACSOutputConfig | None = None, input_source: IndexDataSource | str, identity: ManagedIdentityConfiguration | UserIdentityConfiguration | None = None, _dry_run: bool = False) MLIndex | Job [source]¶
Builds an index on the cloud using the Azure AI Resources service.
- Parameters:
output_index_name (str) – The name of the index to be created.
vector_store (str) – The name of the vector store to be used for the index.
data_source_url (Optional[str]) – The URL of the data source.
chunk_size (Optional[int]) – The size of chunks to be used for indexing.
chunk_overlap (Optional[int]) – The amount of overlap between chunks.
input_glob (Optional[str]) – The glob pattern to be used for indexing.
max_sample_files (Optional[int]) – The maximum number of sample files to be used for indexing.
chunk_prepend_summary (Optional[bool]) – Whether to prepend a summary to each chunk.
document_path_replacement_regex (Optional[str]) – The regex pattern for replacing document paths.
embeddings_model (str) – The model to be used for embeddings. Defaults to “text-embedding-ada-002”.
aoai_connection_id (str) – The ID of the Azure Open AI connection to be used. Defaults to ~azure.ai.resources.constants._common.DEFAULT_OPEN_AI_CONNECTION_NAME.
acs_config (Optional[ACSOutputConfig]) – The configuration for the ACS output.
input_source (Union[IndexDataSource, str]) – The input source for the index.
identity (Optional[Union[ManagedIdentityConfiguration, UserIdentityConfiguration]]) – The identity to be used for the index.
_dry_run (bool) – Whether to run the operation as a dry run. Defaults to False.
- Returns:
If the source_input is an ACSSource, returns an MLIndex object. If the source_input is a GitSource, returns a created DataIndex Job object.
- Return type:
Union[MLIndex, Job]
- Raises:
ValueError – If the source_input is not type ~typing.Str or ~azure.ai.resources.operations.LocalSource.
- classmethod from_config(credential: TokenCredential, *, path: str | PathLike | None = None, file_name=None, **kwargs) AIClient [source]¶
Returns a client from an existing Azure AI project using a file configuration.
To get the required details, you can go to the Project Overview page in the AI Studio.
You can save a project’s details in a JSON configuration file using this format:
{ "subscription_id": "<subscription_id>", "resource_group": "<resource_group_name>", "project_name": "<project_name>", }
This method provides a simple way to reuse the same project across multiple Python notebooks or projects without retyping the project details.
- Parameters:
credential (TokenCredential) – The credential object.
- Keyword Arguments:
path (Optional[Union[os.PathLike, str]]) – The path to the configuration file or starting directory to search for the configuration file within. Defaults to None, indicating the current directory will be used.
file_name (Optional[str]) – The configuration file name to search for when path is a directory path. Defaults to “config.json”.
- Raises:
ValidationException – Raised if “config.json”, or file_name if overridden, cannot be found in directory. Details will be provided in the error message.
- Returns:
The client for an existing Azure AI project.
- Return type:
- get_default_aoai_connection() azure.ai.resources.entities.AzureOpenAIConnection [source]¶
Retrieves the default Azure Open AI connection associated with this AIClient’s project, creating it if it does not already exist.
- Returns:
An Azure OpenAI Connection associated to the project
- Return type:
- get_default_content_safety_connection() azure.ai.resources.entities.AzureAIServiceConnection [source]¶
Retrieves a default Azure AI Service connection associated with this AIClient’s project, creating it if the connection does not already exist. This particular AI Service connection is linked to an Azure Content Safety service.
- Returns:
An Azure AI Service Connection associated to the project that is linked to an Azure Content Safety service.
- Return type:
- property ai_resource_name: str | None¶
The name of the AI Resource where resource-dependent operations will be executed.
- Returns:
The name of the AI Resource where resource-dependent operations will be executed.
- Return type:
Optional[str]
- property ai_resources: AIResourceOperations¶
A collection of AI resource-related operations.
- Returns:
A class containing AI resource-related operations.
- Return type:
- property azure_open_ai_deployments: AzureOpenAIDeploymentOperations¶
A collection of Azure OpenAI deployment-related operations.
- Returns:
Azure OpenAI deployment operations
- Return type:
- property connections: ConnectionOperations¶
A collection of connection-related operations.
Note
Unlike other operation handles, the connections handle is scoped to the AIClient’s AI Resource, and not the project. SDK support for project-scoped connections does not exist yet.
- Returns:
A class containing connection-related operations.
- Return type:
ConnectionsOperations
- property data: DataOperations¶
A collection of data-related operations.
- Returns:
A class containing data-related operations.
- Return type:
- property indexes: MLIndexOperations¶
A collection of ML index-related operations.
- Returns:
A class containing ML index-related operations.
- Return type:
- property models: ModelOperations¶
A collection of model-related operations.
- Returns:
A class containing model-related operations.
- Return type:
- property project_name: str | None¶
The workspace where workspace-dependent operations will be executed.
- Returns:
The name of the workspace where workspace-dependent operations will be executed.
- Return type:
Optional[str]
- property projects: ProjectOperations¶
A collection of project-related operations.
- Returns:
A class containing project-related operations.
- Return type:
- property resource_group_name: str¶
The name of the resource group that the AIClient is associated with.
- Returns:
The name of the resource group that the AIClient is associated with.
- Return type:
- property single_deployments: SingleDeploymentOperations¶
A collection of single deployment-related operations.
- Returns:
A class containing single deployment-related operations.
- Return type: