guidance
guidance copied to clipboard
models.AzureOpenAI class missing in guidance.models despite example notebook
The bug The official AzureOpenAI example notebook shows usage of guidance.models.AzureOpenAI, but importing or referencing that class in the latest published guidance package fails:
AttributeError: module 'guidance.models' has no attribute 'AzureOpenAI'
To Reproduce 1. Install the latest guidance (e.g. pip install guidance). 2. Create a file guidance_example.py with the following contents:
import os
from azure.identity import DefaultAzureCredential, get_bearer_token_provider
from dotenv import load_dotenv
import guidance
from guidance import models
load_dotenv()
model = os.getenv("AZUREAI_CHAT_MODEL")
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
azure_deployment = os.getenv("AZURE_OPENAI_DEPLOYMENT_NAME")
azure_api_ver = os.getenv("AZURE_OPENAI_ENDPOINT_API_VERSION")
credential = DefaultAzureCredential()
token_provider = get_bearer_token_provider(
credential, "https://cognitiveservices.azure.com/.default"
)
# This line errors out
azureai_model = models.AzureOpenAI(
model=model,
azure_endpoint=azure_endpoint,
azure_deployment=azure_deployment,
version=azure_api_ver,
azure_ad_token_provider=token_provider,
)
- Run:
python3 guidance_example.py
System info (please complete the following information): guidance version: 0.2.1 Python version: 3.11.x azure-identity version: 1.22.0 openai SDK version: 1.78.1