joaomdmoura / 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
17.11k stars 2.32k forks source link

Error on Did not find openai_api_key while using crewai with Anthropic claude3 #736

Open Microsvuln opened 1 month ago

Microsvuln commented 1 month ago

Hi .

I have the following code :

os.environ["ANTHROPIC_API_KEY"] = 'MY_API_KEY'

from langchain.llms import anthropic

llm = ChatAnthropic(
    model="claude-3-opus-20240229"
)

search = DuckDuckGoSearchRun()

tools = [
    Tool(
        name="Search",
        func=search.run,
        description="useful for when you search for info"
    )
]

But when I run my script I get the following error which is irrelevant as I want to use crewai with claude3 :

Did not find openai_api_key, please add an environment variableOPENAI_API_KEYwhich contains it, or passopenai_api_keyas a named parameter. (type=value_error)

Any ideas how to solve this ?

Thanks.

gadgethome commented 1 month ago

Are you setting the llm on each of the agents?

Create an agent and set the LLM

agent = Agent( role='Software Engineer', goal='Develop a simple Python application', backstory='You are a skilled software engineer with experience in Python.', verbose=True, allow_delegation=False, llm=llm, )

Microsvuln commented 1 month ago

Thanks @gadgethome , that's solved the problem .

My other question is, is it possible to use GPT-4, LLAMA3 and Claude3 at the same time ? if so, how to do this ?

Thanks.

yuripourre commented 1 month ago

My other question is, is it possible to use GPT-4, LLAMA3 and Claude3 at the same time ? if so, how to do this ?

You can assign one LLM to each agent.