Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'autogen_ext.models.openai' has no attribute 'AzureTokenProvider' #4989

Open
James4Ever0 opened this issue Jan 10, 2025 · 1 comment · May be fixed by #4992
Open

AttributeError: module 'autogen_ext.models.openai' has no attribute 'AzureTokenProvider' #4989

James4Ever0 opened this issue Jan 10, 2025 · 1 comment · May be fixed by #4992

Comments

@James4Ever0
Copy link

When following the official guide of Magentic-one, I have encountered the exception.

To reproduce the exception:

env "CHAT_COMPLETION_CLIENT_CONFIG=$(cat config.json)" LOGLEVEL=DEBUG python examples/example.py --logs_dir ./logs

Content of config.json:

{
    "provider": "AzureOpenAIChatCompletionClient",
    "config": {
        "model": "gpt-4o-2024-05-13",
        "azure_endpoint": "https://{your-custom-endpoint}.openai.azure.com/",
        "azure_deployment": "{your-azure-deployment}",
        "api_version": "2024-06-01",
        "azure_ad_token_provider": {
            "provider": "autogen_ext.models.openai.AzureTokenProvider",
            "config": {
                "provider_kind": "DefaultAzureCredential",
                "scopes": [
                    "https://cognitiveservices.azure.com/.default"
                ]
            }
        }
    }
}

In order to resolve this issue, I have made the following change, but unsure if it is appropriate or effective.

# file: python/packages/autogen-core/src/autogen_core/_component_config.py
# in: class ComponentLoader, def load_component

        _typ = ComponentConfigImpl[BaseModel]
        try:
            _val = module.__getattribute__(class_name) # AttributeError: module 'autogen_ext.models.openai' has no attribute 'AzureTokenProvider'
        except:
            print("Falling back to default class:", cls.__name__)
            _val = cls
        component_class = cast(_typ, _val)
@jackgerrits
Copy link
Member

The provider for the token provider should be:

"provider": "autogen_ext.auth.azure.AzureTokenProvider",

I'll submit a fix for this in main.

@jackgerrits jackgerrits linked a pull request Jan 10, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants