Wednesday, May 13, 2026

CrewAI - A Very Basic Single Agent in CrewAI

 This agent is very lightweight and works in google colab. 

[Code Cell 001]

!pip install -U crewai


[Code Cell 002]
from google.colab import userdata
import os
os.environ["GOOGLE_API_KEY"] = userdata.get('GEMINI_API_KEY_006')

[Code Cell 003- Actual Agent]
import os
from crewai import Agent, Task, Crew, LLM

# 1. Setup your Google API Key
# Replace 'your-google-key' with your actual key
#os.environ["GEMINI_API_KEY"] = "your-google-api-key-here"

# 2. Define the Gemini Model
# We use the 'gemini/' prefix so CrewAI knows to use Google
gemini_llm = LLM(
    #model="gemini/gemini-3.1-flash-lite",
    model="gemini/gemma-4-26b-a4b-it",
    temperature=0.7
)

# 3. Create an Agent
# Note: We must pass the gemini_llm to the agent
researcher = Agent(
    role='Expert Researcher',
    goal='Find a simple explanation of what AI Agents are.',
    backstory='You are a helpful assistant that simplifies complex topics.',
    llm=gemini_llm,
    verbose=True
)

# 4. Create a Task
task = Task(
    description='Write a 3-sentence explanation of AI Agents.',
    expected_output='A clear, 3-sentence paragraph.',
    agent=researcher
)

# 5. Assemble the Crew
crew = Crew(
    agents=[researcher],
    tasks=[task],
    verbose=True
)

# 6. Start the process
result = crew.kickoff()

# 7. Print result
print("\n\nRESULT:")
print(result)



=====================================================================================
OUTPUT
=====================================================================================
╭─────────────────────────────────────────── πŸš€ Crew Execution Started ───────────────────────────────────────────╮
                                                                                                                 
  Crew Execution Started                                                                                         
  Name: crew                                                                                                     
  ID: 0c34552d-8bab-4b80-b058-415914289ce0                                                                       
                                                                                                                 
                                                                                                                 
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭──────────────────────────────────────────────── πŸ“‹ Task Started ────────────────────────────────────────────────╮
                                                                                                                 
  Task Started                                                                                                   
  Name: Write a 3-sentence explanation of AI Agents.                                                             
  ID: 5b5c9658-0f0f-4f02-8111-bf4f48a3035d                                                                       
                                                                                                                 
                                                                                                                 
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭─────────────────────────────────────────────── πŸ€– Agent Started ────────────────────────────────────────────────╮
                                                                                                                 
  Agent: Expert Researcher                                                                                       
                                                                                                                 
  Task: Write a 3-sentence explanation of AI Agents.                                                             
                                                                                                                 
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭───────────────────────────────────────────── ✅ Agent Final Answer ─────────────────────────────────────────────╮
                                                                                                                 
  Agent: Expert Researcher                                                                                       
                                                                                                                 
  Final Answer:                                                                                                  
  An AI agent is an intelligent system designed to achieve specific goals by perceiving its environment and      
  taking independent actions. Unlike a standard chatbot that only provides information, an agent can use         
  external tools and create complex plans to complete tasks autonomously. Essentially, it moves beyond just      
  talking to actually doing work on your behalf.                                                                 
                                                                                                                 
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭────────────────────────────────────────────── πŸ“‹ Task Completion ───────────────────────────────────────────────╮
                                                                                                                 
  Task Completed                                                                                                 
  Name: Write a 3-sentence explanation of AI Agents.                                                             
  Agent: Expert Researcher                                                                                       
                                                                                                                 
                                                                                                                 
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭──────────────────────────────────────────────── Crew Completion ────────────────────────────────────────────────╮
                                                                                                                 
  Crew Execution Completed                                                                                       
  Name: crew                                                                                                     
  ID: 0c34552d-8bab-4b80-b058-415914289ce0                                                                       
  Final Output: An AI agent is an intelligent system designed to achieve specific goals by perceiving its        
  environment and taking independent actions. Unlike a standard chatbot that only provides information, an       
  agent can use external tools and create complex plans to complete tasks autonomously. Essentially, it moves    
  beyond just talking to actually doing work on your behalf.                                                     
                                                                                                                 
                                                                                                                 
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
RESULT:
An AI agent is an intelligent system designed to achieve specific goals by perceiving its environment and taking independent actions. Unlike a standard chatbot that only provides information, an agent can use external tools and create complex plans to complete tasks autonomously. Essentially, it moves beyond just talking to actually doing work on your behalf.

No comments:

Post a Comment

A quick tip on YAML ">" and "|" symbols

In YAML, the > and | symbols are Block Scalar Indicators used to handle multi-line strings. While Python doesn't have an exact 1:1...