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

[BUG]Issue Connecting CREW AI with Azure OpenAI #1540

Open
jamil-z opened this issue Oct 31, 2024 · 1 comment
Open

[BUG]Issue Connecting CREW AI with Azure OpenAI #1540

jamil-z opened this issue Oct 31, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@jamil-z
Copy link

jamil-z commented Oct 31, 2024

Description

I’m experiencing issues when trying to connect CREW AI with Azure OpenAI. After some investigation, I found that only version 0.11 works with Azure OpenAI, but unfortunately, this version lacks the latest features available in more recent releases.

Could anyone guide me on how to connect to Azure OpenAI using an API key with the latest version of CREW AI? Alternatively, if there’s an example available, I haven’t been able to locate it.

Thank you in advance for any assistance!

Steps to Reproduce

run this code

`
import os
from dotenv import load_dotenv
from crewai import Agent, Task, Crew
from langchain_openai import AzureChatOpenAI

load_dotenv()

AZURE_OPENAI_API_KEY = os.getenv("AZURE_OPENAI_API_KEY")
AZURE_OPENAI_ENDPOINT = os.getenv("AZURE_OPENAI_ENDPOINT")
AZURE_OPENAI_API_VERSION = os.getenv("AZURE_OPENAI_API_VERSION")
AZURE_OPENAI_GPT4_DEPLOYMENT = os.getenv("AZURE_OPENAI_GPT4_DEPLOYMENT")

azure_llm = AzureChatOpenAI(
deployment_name=AZURE_OPENAI_GPT4_DEPLOYMENT,
temperature=0.5,
openai_api_key=AZURE_OPENAI_API_KEY,
azure_endpoint=AZURE_OPENAI_ENDPOINT,
openai_api_version=AZURE_OPENAI_API_VERSION,
openai_api_type='azure',
verbose=True
)

researcher = Agent(
role="Researcher",
goal="Analyze trends in artificial intelligence",
backstory="An AI researcher focused on trend analysis.",
llm=azure_llm, # Pasamos el modelo AzureChatOpenAI ya configurado
verbose=True
)

task = Task(
config={"name": "AI Trends Analysis", "description": "Analyze the latest trends in AI"},
agent=researcher,
description="Analyze trends in artificial intelligence with a focus on current advancements.",
expected_output="summary"
)

crew = Crew(
agents=[researcher],
tasks=[task],
process="sequential",
memory=False,
verbose=True
)

result = crew.kickoff()
print("Result:", result)
`

Expected behavior

I would like to be able to connect to Azure OpenAI using an Azure API key with the latest version of CREW AI. This would allow me to utilize the new features in the updated version while still connecting seamlessly to Azure OpenAI.

Screenshots/Code snippets

Provider List: https://docs.litellm.ai/docs/providers

2024-10-31 14:15:12,382 - 137261981890368 - llm.py-llm:178 - ERROR: Failed to get supported params: argument of type 'NoneType' is not iterable

Agent: Researcher

Task: Analyze trends in artificial intelligence with a focus on current advancements.

2024-10-31 14:15:12,387 - 137261981890368 - llm.py-llm:161 - ERROR: LiteLLM call failed: litellm.BadRequestError: LLM Provider NOT provided. Pass in the LLM provider you are trying to call. You passed model=gpt-4-preview
Pass model as E.g. For 'Huggingface' inference endpoints pass in completion(model='huggingface/starcoder',..) Learn more: https://docs.litellm.ai/docs/providers

Operating System

Ubuntu 22.04

Python Version

3.11

crewAI Version

Name: crewai Version: 0.70.1

crewAI Tools Version

crewai_tools==0.12.1

Virtual Environment

Venv

Evidence

File "/home/x/x/x/x/x/venv/lib/python3.11/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py", line 290, in get_llm_provider
raise litellm.exceptions.BadRequestError( # type: ignore
litellm.exceptions.BadRequestError: litellm.BadRequestError: LLM Provider NOT provided. Pass in the LLM provider you are trying to call. You passed model=gpt-4o
Pass model as E.g. For 'Huggingface' inference endpoints pass in completion(model='huggingface/starcoder',..) Learn more: https://docs.litellm.ai/docs/providers

Possible Solution

when I use this requirements the previous code running
crewai==0.11.0
python-dotenv==1.0.0
langchain_openai==0.0.2
pandas
IPython

Additional context

The problem is trying to use the Azure OpenAI keys to run CrewAI on a more current version, at least from 0.7 and above, since it only works for 0.11 specifically.

Why do I want to use a higher version?
I want to use CrewAI for the tools and utilize the latest features.

Please, even a basic example of how I should use Azure with this new version, or if I'm missing something. I appreciate any help.

@jamil-z jamil-z added the bug Something isn't working label Oct 31, 2024
@Friend09
Copy link

from crewai import LLM

llm_crewai = LLM(
api_key = "api_key",
api_version = '2024-07-18',
model = 'azure/<model_name_goes_here>',
base_url = 'https://<yourcompany.com>/coreapi/openai/v1',
)

prefix azure/ to your model name. this approach worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants