crewAI: [BUG]Error with memory=True using AzureOpenAI Provider

Description

Hi, I encountered an issue when using the AzureOpenAI provider. Setting memory=True results in a parameters error because it doesn’t allow defining the embedder with additional parameters beyond model_name and provider. In my configuration for Azure embeddings, I need to include all parameters, including SSO access details. For example, the setup requires something like the following configuration:

"model": EMBEDDING_MODEL,
            "deployment": EMBEDDING_MODEL ,
            "openai_api_key":API_KEY,
            "azure_endpoint": API_BASE,
            "openai_api_version":API_VERSION,
            "openai_api_type":TYPE,
            "default_headers": {
                "Authorization": f"Bearer {access_token}",
                "Content-Type": "application/json"

Please let me know if there’s a workaround or fix for this issue. Thanks

Steps to Reproduce

crew = Crew(
    agents=[support_agent, support_quality_assurance_agent],
    tasks=[inquiry_resolution, quality_assurance_review],
    verbose=True,
    memory=True,
    llm=llm,
    embedder={
        "provider": "azure_openai",
        "config": {
            "model": EMBEDDING_MODEL,
            "deployment": EMBEDDING_MODEL ,
            "openai_api_key":API_KEY,
            "azure_endpoint": API_BASE,
            "openai_api_version":API_VERSION,
            "openai_api_type":TYPE,
            "default_headers": {
                "Authorization": f"Bearer {access_token}",
                "Content-Type": "application/json"
            }
        }})

Expected behavior

I expected the crew to run successfully after being built using crew.kickoff.

Screenshots/Code snippets


Operating System

Windows 10

Python Version

3.11

crewAI Version

0.55.2

crewAI Tools Version

0.12.1

Virtual Environment

Venv

Evidence

AuthenticationError: Error code: 401 - {'statusCode': 401, 'message': 'Invalid Authorization token'}

Possible Solution

I attempted to modify the source code by adding additional parameter inputs for the embedder in misc.py and embedder-base.py. However, when running the kickoff, I still encounter an error related to SSO. AuthenticationError: Error code: 401 - {'statusCode': 401, 'message': 'Invalid Authorization token'}

Additional context

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15

Most upvoted comments

No, https://learn.microsoft.com/en-us/azure/ai-services/openai/reference and Azure Cognitive Services APIs is other service. I do not think crewai by itself or liteLLM support Cognitive.