Arize-ai / phoenix

AI Observability & Evaluation
https://docs.arize.com/phoenix
Other
3.57k stars 267 forks source link

[BUG] Phoenix.evals.OpenAIModel doesn't recognize Azure Active Directory Authentication #3813

Closed Jgilhuly closed 3 months ago

Jgilhuly commented 3 months ago

Describe the bug Azure has an option for active directory authentication which allows you to log in via CLI instead of supplying API keys. The initializer for our OpenAIModel class requires an api_key as a parameter, and so throws an error if it is missing - even though it is not needed if this active directory approach is being used.

To Reproduce Steps to reproduce the behavior:

from azure.identity import DefaultAzureCredential, get_bearer_token_provider
from phoenix.evals import OpenAIModel

token_provider = get_bearer_token_provider(
    DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default"
)

client = OpenAIModel(
    api_version="2024-02-15-preview",
    azure_endpoint=<endpoint>,
    azure_ad_token_provider= token_provider,
    model=<deployment_name>,
)

response = client('Does Azure OpenAI support customer managed keys?')
print(response)

Expected behavior Ideally we should recognize the active directory key and allow initialization without a key in this case.

Environment (please complete the following information):

Workaround Can add a random api_key to the OpenAIModel initialization call and it will be overridden by the active directory value.

axiomofjoy commented 3 months ago

Thanks @Jgilhuly, I'll take a look tomorrow.