Posts

Showing posts from November, 2024

GenerativeAI Python Libaries

Image
https://www.pexels.com/photo/two-women-looking-at-the-code-at-laptop-1181263/ After deploying GenerativeAI chat completion models from Azure GenerativeAI catalog, we need to know which Python SDK to used. OpenAI Models After deploying Azure OpenAI model, we use openai Python library. Either pip install openai or poetry add openai and we suggest that you use the asynchronous client. from openai import AsyncAzureOpenAI client = AsyncAzureOpenAI( api_key=<azure_openai_key>, api_version=<azure_openai_api_version>, azure_endpoint=<azure_openai_endpoint>, ) or (even better, use the DefaultAzureCredential ) from azure.identity import DefaultAzureCredential, get_bearer_token_provider from openai import AsyncAzureOpenAI azure_credential = DefaultAzureCredential() token_provider = get_bearer_token_provider( azure_credential, "https://cognitiveservices.azure.com/.default" ) client = AsyncAzureOpenAI( api_version=<azure_openai_api_version>,