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
16.83k stars 2.27k forks source link

crewAI is asking me for a openAI API key while im using gemini as model #769

Open LucasCBT opened 2 weeks ago

LucasCBT commented 2 weeks ago

`from crewai import Agent, Task, Crew from google.cloud import bigquery from langchain_google_vertexai import VertexAI from crewai_tools import SerperDevTool

llm = VertexAI( temperature=0.0, max_output_tokens=4096, model_name="gemini-1.5-pro", top_k=1, top_p=0.0 ) search_tool = SerperDevTool()

researcher = Agent( role='Senior Researcher', goal='Uncover groundbreaking technologies in {topic}', verbose=True, memory=True, llm=llm, backstory=( "Driven by curiosity, you're at the forefront of" "innovation, eager to explore and share knowledge that could change" "the world." ), tools=[search_tool], allow_delegation=True )

writer = Agent( role='Writer', goal='Narrate compelling tech stories about {topic}', verbose=True, memory=True, llm=llm, backstory=( "With a flair for simplifying complex topics, you craft" "engaging narratives that captivate and educate, bringing new" "discoveries to light in an accessible manner." ), tools=[search_tool], allow_delegation=False )

research_task = Task( description=( "Identify the next big trend in {topic}." "Focus on identifying pros and cons and the overall narrative." "Your final report should clearly articulate the key points," "its market opportunities, and potential risks." ), expected_output='A comprehensive 3 paragraphs long report on the latest AI trends.', tools=[search_tool], agent=researcher, )

write_task = Task( description=( "Compose an insightful article on {topic}." "Focus on the latest trends and how it's impacting the industry." "This article should be easy to understand, engaging, and positive." ), expected_output='A 4 paragraph article on {topic} advancements formatted as markdown.', tools=[search_tool], agent=writer, async_execution=False, )

crew = Crew( agents=[writer], tasks=[write_task], memory=True, cache=True, max_rpm=100 ) result = crew.kickoff(inputs={'topic': 'AI in healthcare'}) print(result)`

AuthenticationError: Error code: 401 - {'error': {'message': 'Incorrect API key provided: fake. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}}

Can someone help me with that? What am i doing wrong? All the code is running without problem except for the "result = ..."

LucasCBT commented 2 weeks ago

Also, its worth to mention that the llm is working. I sent a massage to it and receive a proper responde via llm.invoke

greg80303 commented 2 weeks ago

@LucasCBT CrewAI uses OpenAI for embeddings when using Memory. Set memory=False in your Crew to disable the use of embeddings, or provide a different embeddings config (embedder field of Crew). I know CrewAI uses EmbedChain, and the default value for embedder is {"provider": "openai"}. I haven't played around with overriding this to use something else, but I'm sure it's possible.

LucasCBT commented 2 weeks ago

@greg80303 Thanks, im gonna try that! Google also has a few embedder models that i can try to use in case i want memory.

cbarkinozer commented 1 week ago

I have the same problem. By checking the schema validation from the source code, I managed to pass the exception by giving this embedder field to the Crew():

embedder={
        "provider": "huggingface",
        "config": {
            "model": "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2"
        }
 }

For example:

crew = Crew(
        agents=agent_list,
        tasks=task_list,
        process=Process.sequential,
        embedder={
            "provider": "huggingface",
            "config": {"model": "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2"},
        },
        verbose=2,
        memory=True
    )