The Synthetic Intelligence trade is transferring quick. It’s spectacular and plenty of occasions overwhelming.
I’ve been learning, studying, and constructing my foundations on this space of Information Science as a result of I imagine that the way forward for Information Science is strongly correlated with the event of Generative AI.
It was simply the opposite day after I constructed my first Ai Agent, after which a few weeks after that, there have been a number of Python packages to select from, to not point out the no-code choices which might be doing very nicely, like n8n.
From “mere” fashions that would simply chat with us to a tsunami of AI Brokers which might be all over the place, looking the Web, dealing with recordsdata, and making complete Information Science tasks (from EDA to modeling and analysis), all of that occurred in simply a few years.
What?
Seeing all of that, my thought was: “I have to get on board as quickly as attainable”. In spite of everything, it’s higher to surf the wave than be swallowed by it.
For that purpose, I made a decision to start out this sequence of posts the place I plan to go from the basics to construct our first AI Agent, till extra advanced ideas.
Sufficient discuss, let’s dive in.
The Fundamentals of AI Brokers
An AI Agent is created after we give the Llm the ability to work together with instruments and carry out helpful actions for us. So, as a substitute of being only a chatbot, now it could actually schedule appointments, care for our calendar, search the web, write social media posts, and the record goes on…
AI Brokers can do helpful issues, not simply chat.
However how can we give that energy to an LLM?
The easy reply is to make use of an API to work together with the LLM. There are a number of Python packages for that these days. Should you comply with my weblog, you will notice that I’ve already tried a few packages to construct brokers: Langchain, Agno (former PhiData), and CrewAI, as an illustration. For this sequence, I’ll stick to Agno [1].
First, arrange a digital surroundings utilizing uv
, Anaconda, or the surroundings handler of your desire. Subsequent, set up the packages.
# Agno AI
pip set up agno
# module to work together with Gemini
pip set up google-generativeai
# Set up these different packages that will likely be wanted all through the tutorial
pip set up agno groq lancedb sentence-transformers tantivy youtube-transcript-api
Fast be aware earlier than we proceed. Don’t neglect to get a Google Gemini API Key [2].
Making a easy agent may be very easy. All of the packages are very related. They’ve a category Agent
or one thing related that permits us to pick a mannequin and begin interacting with the LLM of our alternative. Listed below are the principle parts of this class:
mannequin
: the reference to the LLM. Right here we are going to select between OpenAI, Gemini, Llama, Deepseek and many others.description
: This argument lets us describe the conduct of the agent. That is added to thesystem_message
, which is an identical argument.directions
: I like to think about an agent like an worker or an assistant that we’re managing. To be able to have a process completed, we should present the directions of what must be completed. Right here is the place you are able to do that.expected_output
: Right here we can provide directions concerning the anticipated output.instruments
: That is what makes the LLM an Agent, enabling it to work together with the actual world utilizing these instruments.
Now, let’s create a easy agent that has no instruments, however will serve to construct our instinct across the construction of the code.
# Imports
from agno.agent import Agent
from agno.fashions.google import Gemini
import os
# Create agent
agent = Agent(
mannequin= Gemini(id="gemini-1.5-flash",
api_key = os.environ.get("GEMINI_API_KEY")),
description= "An assistant agent",
directions= ["Be sucint. Answer in a maximum of 2 sentences."],
markdown= True
)
# Run agent
response = agent.run("What is the climate like in NYC in Might?")
# Print response
print(response.content material)
########### OUTPUT ###############
Anticipate gentle temperatures in NYC throughout Might, sometimes starting from the low 50s
to the mid-70s Fahrenheit.
There's an opportunity of rain, so packing layers and an umbrella is advisable.
That’s nice. We’re utilizing the Gemini 1.5 mannequin. Discover the way it responds based mostly on the info it was educated on. If we ask it to inform us the climate immediately, we’ll see a response saying it could actually’t entry the web.
Let’s discover the directions
and expected_output
arguments. We now desire a desk with the month, season and common temperature for NYC.
# Imports
from agno.agent import Agent
from agno.fashions.google import Gemini
import os
# Create agent
agent = Agent(
mannequin= Gemini(id="gemini-1.5-flash",
api_key = os.environ.get("GEMINI_API_KEY")),
description= "An assistant agent",
directions= ["Be sucint. Return a markdown table"],
expected_output= "A desk with month, season and common temperature",
markdown= True
)
# Run agent
response = agent.run("What is the climate like in NYC for every month of the 12 months?")
# Print response
print(response.content material)
And there’s the end result.
Month | Season | Common Temperature (°F) |
---|---|---|
January | Winter | 32 |
February | Winter | 35 |
March | Spring | 44 |
April | Spring | 54 |
Might | Spring | 63 |
June | Summer season | 72 |
July | Summer season | 77 |
August | Summer season | 76 |
September | Autumn | 70 |
October | Autumn | 58 |
November | Autumn | 48 |
December | Winter | 37 |
Instruments
The earlier responses are good. However we naturally don’t need to use highly effective fashions comparable to LLMs to play with a chatbot or inform us outdated information, proper?
We wish them to be a bridge to automation, productiveness, and data. So, the Instruments will add capabilities to our AI Brokers, constructing, due to this fact, the bridge with the actual world. Frequent examples of instruments for brokers are: looking the online, working SQL, sending an e mail or calling APIs.
However greater than that, we are able to create customized capabilities to our brokers by utilizing any Python perform as a instrument.
Instruments are features that an Agent can run to attain duties.
By way of code, including a instrument to the Agent is only a matter of utilizing the argument instruments
within the Agent
class.
Think about a solopreneur (one-person firm) within the wholesome residing enterprise who desires to automate their content material technology. This individual posts recommendations on wholesome habits every single day. I do know for a indisputable fact that content material technology isn’t as simple because it seems like. It calls for creativity, analysis, and copywriting expertise. So, if this could possibly be automated, or not less than a part of it, that’s time saved.
So we write this code to create a quite simple agent that may generate a easy Instagram submit and reserve it to a markdown file for our overview. We diminished the method from considering > researching > writing > reviewing > posting to reviewing > posting.
# Imports
import os
from agno.agent import Agent
from agno.fashions.google import Gemini
from agno.instruments.file import FileTools
# Create agent
agent = Agent(
mannequin= Gemini(id="gemini-1.5-flash",
api_key = os.environ.get("GEMINI_API_KEY")),
description= "You're a social media marketer specialised in creating participating content material.",
instruments=[FileTools(
read_files=True,
save_files=True
)],
show_tool_calls=True)
# Writing and saving a file
agent.print_response("""Write a brief submit for instagram with suggestions and methods
that positions me as an authority in wholesome consuming
and reserve it to a file named 'submit.txt'.""",
markdown=True)
Because of this, we’ve got the next.
Unlock Your Finest Self By means of Wholesome Consuming:
1. Prioritize complete meals: Load up on fruits, greens, lean proteins, and complete
grains. They're full of vitamins and maintain you feeling full and energized.
2. Aware consuming: Take note of your physique's starvation and fullness cues.
Keep away from distractions whereas consuming.
3. Hydrate, hydrate, hydrate: Water is essential for digestion, power ranges,
and general well being.
4. Do not deprive your self: Permit for infrequent treats.
Deprivation can result in overeating later. Take pleasure in every part carefully!
5. Plan forward: Prep your meals or snacks upfront to keep away from unhealthy
impulse choices.
#healthyeating #healthylifestyle #vitamin #foodie
#wellbeing #healthytips #eatclean #weightloss #healthyrecipes
#nutritiontips #instahealth #healthyfood #mindfuleating #wellnessjourney
#healthcoach
Actually, we might make it far more fancy by making a crew with different brokers to go looking a listing of internet sites for content material, a content material checker and reviewer, and one other one to generate a picture for the submit. However I imagine you bought the overall concept of the best way to add a instrument
to an Agent
.
One other sort of instrument we are able to add is the perform instrument. We are able to use a Python perform to function a instrument for the LLM. Simply don’t neglect so as to add the kind hints like video_id:str
, so the mannequin is aware of what to make use of because the perform’s enter. In any other case, you may see an error.
Let’s see briefly how that works.
We now need our Agent to have the ability to get a given YouTube video and summarize it. To carry out such a process, we merely create a perform that downloads the transcript of the video from YT and passes it to the mannequin to summarize.
# Imports
import os
from agno.agent import Agent
from agno.fashions.google import Gemini
from youtube_transcript_api import YouTubeTranscriptApi
# Get YT transcript
def get_yt_transcript(video_id:str) -> str:
"""
Use this perform to get the transcript from a YouTube video utilizing the video id.
Parameters
----------
video_id : str
The id of the YouTube video.
Returns
-------
str
The transcript of the video.
"""
# Instantiate
ytt_api = YouTubeTranscriptApi()
# Fetch
yt = ytt_api.fetch(video_id)
# Return
return ''.be part of([line.text for line in yt])
# Create agent
agent = Agent(
mannequin= Gemini(id="gemini-1.5-flash",
api_key = os.environ.get("GEMINI_API_KEY")),
description= "You're an assistant that summarizes YouTube movies.",
instruments=[get_yt_transcript],
expected_output= "A abstract of the video with the 5 details and a pair of questions for me to check my understanding.",
markdown=True,
show_tool_calls=True)
# Run agent
agent.print_response("""Summarize the textual content of the video with the id 'hrZSfMly_Ck' """,
markdown=True)
After which you’ve gotten a end result.

Brokers with Reasoning
One other cool choice from the Agno package deal is permitting us to simply create brokers that may analyze the state of affairs earlier than answering a query. That’s the reasoning instrument.
We are going to create a reasoning agent with Alibaba’s Qwen-qwq-32b mannequin. Discover that the one distinction right here, in addition to the mannequin, is that we’re including the instrument ReasoningTools()
.
The adding_instructions=True
means offering detailed directions to the agent, which reinforces the reliability and accuracy of its instrument utilization, whereas setting this to False
forces the agent to rely by itself reasoning, which could be extra vulnerable to errors.
# Imports
import os
from agno.agent import Agent
from agno.fashions.groq import Groq
from agno.instruments.reasoning import ReasoningTools
# Create agent with reasoning
agent = Agent(
mannequin= Groq(id="qwen-qwq-32b",
api_key = os.environ.get("GROQ_API_KEY")),
description= "You're an skilled math instructor.",
instruments=[ReasoningTools(add_instructions=True)],
show_tool_calls=True)
# Writing and saving a file
agent.print_response("""Clarify the idea of sin and cosine in easy phrases.""",
stream=True,
show_full_reasoning=True,
markdown=True)
Follows the output.

Agent with Information
This instrument is the best method for me to create a Retrieval Augmented Technology (RAG). With this characteristic, you may level the agent to an internet site or a listing of internet sites, and it’ll add the content material to a vector database. Then, it turns into searchable. As soon as requested, the agent can use the content material as a part of the reply.
On this easy instance, I added one web page of my web site and requested the agent what books are listed there.
# Imports
import os
from agno.agent import Agent
from agno.fashions.google import Gemini
from agno.data.url import UrlKnowledge
from agno.vectordb.lancedb import LanceDb, SearchType
from agno.embedder.sentence_transformer import SentenceTransformerEmbedder
# Load webpage to the data base
agent_knowledge = UrlKnowledge(
urls=["https://gustavorsantos.me/?page_id=47"],
vector_db=LanceDb(
uri="tmp/lancedb",
table_name="tasks",
search_type=SearchType.hybrid,
# Use Sentence Transformer for embeddings
embedder=SentenceTransformerEmbedder(),
),
)
# Create agent
agent = Agent(
mannequin=Gemini(id="gemini-2.0-flash", api_key=os.environ.get("GEMINI_API_KEY")),
directions=[
"Use tables to display data.",
"Search your knowledge before answering the question.",
"Only inlcude the content from the agent_knowledge base table 'projects'",
"Only include the output in your response. No other text.",
],
data=agent_knowledge,
add_datetime_to_instructions=True,
markdown=True,
)
if __name__ == "__main__":
# Load the data base, you may remark out after first run
# Set recreate to True to recreate the data base if wanted
agent.data.load(recreate=False)
agent.print_response(
"What are the 2 books listed within the 'agent_knowledge'",
stream=True,
show_full_reasoning=True,
stream_intermediate_steps=True,
)

Agent with Reminiscence
The final sort we are going to go over on this submit is the agent with reminiscence.
Such a agent can retailer and retrieve details about customers from earlier interactions, permitting it to study person preferences and personalize its responses.
Let’s see this instance the place I’ll inform a few issues to the agent and ask for suggestions based mostly on that interplay.
# imports
import os
from agno.agent import Agent
from agno.reminiscence.v2.db.sqlite import SqliteMemoryDb
from agno.reminiscence.v2.reminiscence import Reminiscence
from agno.fashions.google import Gemini
from wealthy.fairly import pprint
# Person Title
user_id = "data_scientist"
# Making a reminiscence database
reminiscence = Reminiscence(
db=SqliteMemoryDb(table_name="reminiscence",
db_file="tmp/reminiscence.db"),
mannequin=Gemini(id="gemini-2.0-flash",
api_key=os.environ.get("GEMINI_API_KEY"))
)
# Clear the reminiscence earlier than begin
reminiscence.clear()
# Create the agent
agent = Agent(
mannequin=Gemini(id="gemini-2.0-flash", api_key=os.environ.get("GEMINI_API_KEY")),
user_id=user_id,
reminiscence=reminiscence,
# Allow the Agent to dynamically create and handle person recollections
enable_agentic_memory=True,
add_datetime_to_instructions=True,
markdown=True,
)
# Run the code
if __name__ == "__main__":
agent.print_response("My title is Gustavo and I'm a Information Scientist studying about AI Brokers.")
recollections = reminiscence.get_user_memories(user_id=user_id)
print(f"Reminiscences about {user_id}:")
pprint(recollections)
agent.print_response("What subject ought to I examine about?")
agent.print_response("I write articles for In direction of Information Science.")
print(f"Reminiscences about {user_id}:")
pprint(recollections)
agent.print_response("The place ought to I submit my subsequent article?")

And right here we finish this primary submit about AI Brokers.
Earlier than You Go
There’s a whole lot of content material on this submit. We climbed step one on this ladder of studying about AI brokers. I do know, it’s overwhelming. There may be a lot info on the market that it turns into tougher and tougher to know the place to start out and what to check.
My suggestion is to take the identical street I’m taking. One step at a time, selecting simply a few packages like Agno, CrewAI, and going deep on these, studying the best way to create extra advanced brokers every time.
On this submit, we began from scratch, studying the best way to merely work together with an LLM to creating brokers with reminiscence, and even making a easy RAG for an AI Agent.
Clearly, there’s far more you are able to do simply with a single agent. Try the Reference [4].
With these easy expertise, make sure that you might be forward of lots of people, and there’s a lot you are able to do already. Simply use the creativity and (why not?) ask for the assistance of an LLM to construct one thing cool!
Within the subsequent submit, we are going to study extra about brokers and analysis. Keep tuned!
GitHub Repository
https://github.com/gurezende/agno-ai-labs
Contact and On-line Presence
Should you preferred this content material, discover extra of my work and social media in my web site:
References
[1] https://docs.agno.com/introduction
[2] https://ai.google.dev/gemini-api/docs
[3] https://pypi.org/challenge/youtube-transcript-api/
[4] https://github.com/agno-agi/agno/tree/major/cookbook
[5] https://docs.agno.com/introduction/brokers#agent-with-knowledge