Skip to main content

Microsoft Azure Machine Learning Client Library for Python

Project description

Azure AI Generative Package client library for Python

The Azure AI Generative package is part of the Azure AI SDK for Python and contains functionality for building, evaluating and deploying Generative AI applications that leverage Azure AI services. The default installation of the package contains capabilities for cloud-connected scenarios, and by installing extras you can also run operations locally (such as building indexes and calculating metrics).

Source code | Package (PyPI) | API reference documentation | Product documentation | Samples

This package has been tested with Python 3.8, 3.9, 3.10, 3.11 and 3.12.

For a more complete set of Azure libraries, see https://aka.ms/azsdk/python/all.

Getting started

Prerequisites

Install the package

Install the Azure AI generative package for Python with pip:

pip install azure-ai-generative[index,evaluate,promptflow]
pip install azure-identity

Key concepts

The [index,evaluate,promptflow] syntax specifies extra packages that you can optionally remove if you don't need the functionality:

  • [index] adds the ability to build indexes on your local development environment
  • [evaluate] adds the ability to run evaluation and calculate metrics in your local development environment
  • [promptflow] adds the ability to develop with prompt flow connected to your Azure AI project

Usage

Connecting to Projects

The generative package includes the azure-ai-resources package and uses the AIClient for connecting to your project.

First, create an AI Client:

from azure.ai.resources.client import AIClient
from azure.identity import DefaultAzureCredential

ai_client = AIClient(
    credential=DefaultAzureCredential(),
    subscription_id='subscription_id',
    resource_group_name='resource_group',
    project_name='project_name'
)

Using the generative package

Azure AI Generative Python SDK offers the following key capabilities.

To build an index locally, import the build_index function:

from azure.ai.generative.index import build_index

To run a local evaluation, import the evaluate function:

from azure.ai.generative.evaluate import evaluate

To deploy chat functions and prompt flows, import the deploy function:

from azure.ai.resources.entities.deployment import Deployment

For sample usage of these, refer to this sample

Examples

See our samples repository for examples of how to use the Azure AI Generative Python SDK.

Troubleshooting

General

Azure AI clients raise exceptions defined in Azure Core.

from azure.core.exceptions import HttpResponseError

try:
    ai_client.compute.get("cpu-cluster")
except HttpResponseError as error:
    print("Request failed: {}".format(error.message))

Logging

This library uses the standard logging library for logging. Basic information about HTTP sessions (URLs, headers, etc.) is logged at INFO level.

Detailed DEBUG level logging, including request/response bodies and unredacted headers, can be enabled on a client with the logging_enable argument.

See full SDK logging documentation with examples here.

Telemetry

The Azure AI Generative Python SDK includes a telemetry feature that collects usage and failure data about the SDK and sends it to Microsoft when you use the SDK in a Jupyter Notebook only. Telemetry will not be collected for any use of the Python SDK outside of a Jupyter Notebook.

Telemetry data helps the SDK team understand how the SDK is used so it can be improved and the information about failures helps the team resolve problems and fix bugs. The SDK telemetry feature is enabled by default for Jupyter Notebook usage and cannot be enabled for non-Jupyter scenarios. To opt out of the telemetry feature in a Jupyter scenario, set the environment variable "AZURE_AI_GENERATIVE_ENABLE_LOGGING" to "False".

Next steps

See our samples repository for examples of how to use the Azure AI Generative Python SDK.

Contributing

If you encounter any bugs or have suggestions, please file an issue in the Issues section of the project.

Impressions

Release History

1.0.0b10 (2024-10-03)

Bugs Fixed

  • Bug fixes

1.0.0b9 (2024-09-16)

Bugs Fixed

  • Bug fixes

1.0.0b8 (2024-03-27)

Other Changes

  • Bug fixes

1.0.0b7 (2024-02-07)

Other Changes

  • Bug fixes

1.0.0b6 (2024-02-06)

Other Changes

  • Recursive Text Splitter is now enabled by default for local index builds which mimics behavior of cloud index builds
  • Bug fixes

1.0.0b5 (2024-02-02)

Features Added

  • Supports evaluate() on chat

Bugs Fixed

  • Fix promptflow evaluation bugs

Other Changes

  • Duplicate cleanup

1.0.0b4 (2024-02-01)

Features Added

  • Support custom metrics for evaluation

Other Changes

  • Switched evaluate() function to run on promptflow engine
  • Use openai v1 environment variable

1.0.0b3 (2024-01-30)

Other Changes

  • Support for Python 3.12

1.0.0b2 (2023-11-30)

Features Added

  • Added new format to export data to in qa generator.

Other Changes

  • Dependency improvements.

1.0.0b1 (2023-11-10)

Features Added

  • Try use langchain VectorStore and fallback to vendor.
  • Add azure-search-documents 11.4.0b11 and above support.
  • Invoke OpenAI with dynamic batch size.
  • Fix LangChain importing path
  • First preview.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

azure_ai_generative-1.0.0b10.tar.gz (1.5 MB view details)

Uploaded Source

Built Distribution

azure_ai_generative-1.0.0b10-py3-none-any.whl (1.6 MB view details)

Uploaded Python 3

File details

Details for the file azure_ai_generative-1.0.0b10.tar.gz.

File metadata

File hashes

Hashes for azure_ai_generative-1.0.0b10.tar.gz
Algorithm Hash digest
SHA256 374796058550b8b67c28542ac83439149e55e1d13b9abb455b9f7c4b4098be53
MD5 ee28a20768f45ecfef226e2afe18614c
BLAKE2b-256 1092532aa7819b28a2daea8400533c877e1328e504b905c0e42c807d0d0bc9e6

See more details on using hashes here.

File details

Details for the file azure_ai_generative-1.0.0b10-py3-none-any.whl.

File metadata

File hashes

Hashes for azure_ai_generative-1.0.0b10-py3-none-any.whl
Algorithm Hash digest
SHA256 b4d031c4489cbca1e36e8d41899ecc376fae5cb1d293f46a980ea617fac77646
MD5 976642e044689963a426ce731eb73238
BLAKE2b-256 a2599ef853e4ec9da7a2e0304891855e805005c0ae1c9470a4fa44f889e30036

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page