Skip to content

Function get_bearer_token_provider is not JSON serializable #1561

@arthurgreef

Description

@arthurgreef

A warning about using the AzureOpenAI is displayed in version 2.5.2. The recommendation is to use dspy.LM. I get the serialize exception when I change this the client from this:

from azure.identity import DefaultAzureCredential, get_bearer_token_provider

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

model=os.environ["AZURE_AI_MODEL_GPT_4o"]

llm_gpt_4o = dspy.LM(
    model="gpt-4o"
    api_version=os.environ["OPENAI_API_VERSION"],
    api_base=os.environ["AZURE_OPENAI_ENDPOINT"],
    azure_ad_token_provider=token_provider,
    max_tokens=3000,
)

to this:

llm_gpt_4o = dspy.LM(
    model=os.environ["AZURE_AI_MODEL_GPT_4o"],
    api_version=os.environ["OPENAI_API_VERSION"],
    api_base=os.environ["AZURE_OPENAI_ENDPOINT"],
    azure_ad_token_provider=token_provider,
    max_tokens=3000,
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions