crewAIInc / crewAI

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.
https://crewai.com
MIT License
18.45k stars 2.54k forks source link

AzureOpenAI object has no attribute 'bind' #775

Open Tlaloc-Es opened 2 months ago

Tlaloc-Es commented 2 months ago

Hello I was trying crewai wiht a AzureOpenAI, for a job project and I get the following error

File c:\.venv\lib\site-packages\crewai\agent.py:138, in Agent.__init__(__pydantic_self__, **data)
    138 |    config = data.pop("config", {})
    139 |    super().init__(**config, **data)
File c:\.venv\lib\site-packages\crewai\agent.py:187, in Agent.set_agent_executor(self)
    185 |    if not self.cache_handler:
    186 |        self.cache_handler = CacheHandler()
    187 |    self.tools_handler.cache_handler = self.cache_handler
    188 |    return self
File c:\.venv\lib\site-packages\crewai\agent.py:259, in Agent.set_cache_handler(self, cache_handler)
    257 |    self.cache_handler = cache_handler
    258 |    self.tools_handler.cache_handler = cache_handler
    259 |    self.create_agent_executor()
File c:\.venv\lib\site-packages\crewai\agent.py:330, in Agent.create_agent_executor(self, tools)
    325 |    if self.response_template:
    326 |        stop_words.append(
    327 |            self.response_template.split("{ Response }")[1].strip()
    328 |        )
    329 |    bind = self.llm.bind(stop=stop_words)
    330 |    agent_executor = AgentExecutor()
    331 |    agent = RunnableAgent(Runnable.ensure(agent), **executor_args)
AttributeError: 'AzureOpenAI' object has no attribute 'bind'

The code that shows the error is the following:

from openai import AzureOpenai
Agente(....llm=AzureOpenAI(...))

How can I solve it?

Openai version is 1.34
Crewai is 0.30.11

Thanks

jesusEstaba commented 2 months ago

@Tlaloc-Es could you share the code?

Tlaloc-Es commented 2 months ago

The code is this

from openai import AzureOpenai # Load AzureOpenAi

Agent(....llm=AzureOpenAI(...)) # Instante the CrewAI Agent with llm as AzureOpenAI

I can instantate AzureOpenAI outsite anyway.

Regards.

saqib727 commented 2 months ago

@Tlaloc-Es did you get answer, i'm facing solve problem.

saqib727 commented 2 months ago

`

Initialize the AzureOpenAI object with credentials

azure_llm = AzureOpenAI( azure_endpoint=os.getenv('AZURE_OPENAI_ENDPOINT'), api_key=os.getenv('AZURE_OPENAI_KEY'), api_version="2024-02-01" )

Initialize the YouTube search tool

Create a Senior Blog Content Researcher agent

blog_researcher = Agent(

description='xxx',
verbose=True,
memory=True,
backstory=""" s""",
allow_delegation=True,
tools=[yt_tool],
llm=azure_llm

)

`

I'm getting error of AttributeError: 'AzureOpenAI' object has no attribute 'bind'

saqib727 commented 2 months ago

@jesusEstaba @jesusEstaba pls help us in this.

lehoangh commented 1 month ago

Maybe azure openai does not support function calling yet?

github-actions[bot] commented 3 days ago

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.