Level Up Your AI Agents with Crew AI, Gemini API, and Google Search Grounding
The world of AI is evolving rapidly, and one of the most exciting advancements is the rise of multi-agent systems. These systems allow individual AI agents to collaborate and communicate, leading to more complex and intelligent behavior.
Crew AI is a platform that simplifies the development and deployment of such multi-agent systems. But how can we make these agents truly knowledgeable and capable of understanding the real world? This is where the Gemini API and Google Search Retrieval Grounding come into play.
Gemini API: This powerful API provides access to Google’s latest and most advanced large language models (LLMs). By integrating the Gemini API into your Crew AI agents, you can equip them with:
- Enhanced natural language understanding: Gemini excels at understanding and generating human-like text, enabling more natural and effective communication within your multi-agent system.
- Advanced reasoning and problem-solving: Gemini’s powerful reasoning capabilities allow your agents to analyze information, draw conclusions, and make informed decisions.
- Creative content generation: Need your agents to generate creative text formats like poems, code, scripts, musical pieces, email, letters, etc.? Gemini can handle it.
Google Search Retrieval Grounding: While LLMs possess vast knowledge, they can still benefit from access to real-time information. Google Search Retrieval Grounding allows your agents to:
- Access up-to-date information: Connect your agents to the vast knowledge base of Google Search, ensuring they have the latest data at their fingertips.
- Ground their responses in real-world facts: By retrieving relevant information from Google Search, your agents can provide more accurate and contextually relevant responses.
- Expand their knowledge beyond their training data: Break free from the limitations of static training data and empower your agents with dynamic, ever-evolving knowledge.
Example Use Case with Coding:
#install the packages
!pip install crewai langchain-google-genai crewai_tools
#import libraries and gemini_api_key and only Tool for searching the web for grounding
from crewai import Agent
from langchain.tools import tool
from langchain_google_genai import ChatGoogleGenerativeAI
#you need to have a Gemini API Key
api_key = os.getenv(“GOOGLE_API_KEY”)
llm=ChatGoogleGenerativeAI(model=”gemini-1.5-flash”,tools=”google_search_retrieval”,verbose=True, temperature=0.7,google_api_key=”api_key”)
#install the required libraries of crewai for multiagents deployment
from crewai import Agent, Task, Crew
# no need to attach tools of web searching as we have already the tools=”google_search_retrieval”
# create a researcher agent
researcher_agent = Agent(
role=”Expert Researcher”,
goal=”Uncover the current and future technologies in {topic}”,
verbose=True,
memory=True,
backstory=( “As being expert, you’re at the forefront of”
“innovation, eager to explore and share knowledge that could help”
“clarify with details.”
),
llm=llm,
)
# researcher task
research_task = Task(
description=(
“Identify the important big trends in {topic}.”
“Focus on identifying pros and cons and the overall narrative.”
“Your final report should clearly articulate the key points,”
“its opportunities, and potential risks.”
),
expected_output=”A comprehensive 4 paragraphs long report on the latest AI trends.”,
agent=researcher_agent
)
#creating the crew with agents and tasks
crew = Crew(
agents=[researcher_agent, writer_agent,editor_agent],
tasks=[research_task, write_task,editor_task],
verbose=True
)
#crew output and results as blog according to your topic with markdown
inputs_array = {‘topic’: ‘Your Topic’}
crew_output = crew.kickoff(inputs=inputs_array)
from IPython.display import Markdown
Markdown(crew_output)
By combining the power of Crew AI, the Gemini API, and Google Search Retrieval Grounding, you can unlock new levels of intelligence and capability in your multi-agent systems. This powerful combination allows you to build truly innovative and impactful AI applications that can understand, reason, and interact with the real world like never before.
coding details: https://github.com/bukempas/gemini_crewai_multiagents_google_search_retrieval/tree/main
for gemini api key :