The Synthetic Intelligence business is transferring quick. It’s spectacular and lots of occasions overwhelming.
I’ve been finding out, studying, and constructing my foundations on this space of Knowledge Science as a result of I consider that the way forward for Knowledge 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 can be doing very effectively, like n8n.
From “mere” fashions that would simply chat with us to a tsunami of AI Brokers which can be all over the place, looking out the Web, dealing with information, and making complete Data 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 any case, it’s higher to surf the wave than be swallowed by it.
For that motive, I made a decision to begin 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 an alternative of being only a chatbot, now it will possibly schedule appointments, deal with our calendar, search the web, write social media posts, and the listing goes on…
AI Brokers can do helpful issues, not simply chat.
However how can we give that energy to an LLM?
The straightforward 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. For those who observe my weblog, you will note that I’ve already tried a few packages to construct brokers: Langchain, Agno (former PhiData), and CrewAI, as an example. For this sequence, I’ll follow Agno [1].
First, arrange a digital surroundings utilizing uv
, Anaconda, or the surroundings handler of your choice. 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 shall be wanted all through the tutorial
pip set up agno groq lancedb sentence-transformers tantivy youtube-transcript-api
Fast observe earlier than we proceed. Don’t overlook 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 enables us to pick out a mannequin and begin interacting with the LLM of our alternative. Listed below are the primary elements of this class:
mannequin
: the reference to the LLM. Right here we are going to select between OpenAI, Gemini, Llama, Deepseek and so on.description
: This argument lets us describe the conduct of the agent. That is added to thesystem_message
, which is an analogous 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 job finished, we should present the directions of what must be finished. Right here is the place you are able to do that.expected_output
: Right here we can provide directions in regards to the anticipated output.instruments
: That is what makes the LLM an Agent, enabling it to work together with the true 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 ###############
Count on delicate 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 primarily based on the information it was educated on. If we ask it to inform us the climate right this moment, we’ll see a response saying it will possibly’t entry the web.
Let’s discover the directions
and expected_output
arguments. We now need 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 time | 72 |
July | Summer time | 77 |
August | Summer time | 76 |
September | Autumn | 70 |
October | Autumn | 58 |
November | Autumn | 48 |
December | Winter | 37 |
Instruments
The earlier responses are good. However we naturally don’t wish to use highly effective fashions comparable to LLMs to play with a chatbot or inform us previous information, proper?
We wish them to be a bridge to automation, productiveness, and information. So, the Instruments will add capabilities to our AI Brokers, constructing, subsequently, the bridge with the true world. Widespread examples of instruments for brokers are: looking out the net, operating SQL, sending an e-mail or calling APIs.
However greater than that, we will create customized capabilities to our brokers by utilizing any Python perform as a device.
Instruments are capabilities that an Agent can run to realize duties.
When it comes to code, including a device 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 needs to automate their content material technology. This particular person posts tips on wholesome habits day-after-day. I do know for a incontrovertible fact that content material technology is just not as easy because it appears like. It calls for creativity, analysis, and copywriting expertise. So, if this may very well 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 publish and reserve it to a markdown file for our evaluation. We lowered the method from pondering > 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 partaking 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 publish for instagram with suggestions and methods
that positions me as an authority in wholesome consuming
and reserve it to a file named 'publish.txt'.""",
markdown=True)
Consequently, now we have the next.
Unlock Your Finest Self By way of Wholesome Consuming:
1. Prioritize complete meals: Load up on fruits, greens, lean proteins, and complete
grains. They're full of vitamins and preserve 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, vitality ranges,
and total well being.
4. Do not deprive your self: Enable 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 selections.
#healthyeating #healthylifestyle #vitamin #foodie
#wellbeing #healthytips #eatclean #weightloss #healthyrecipes
#nutritiontips #instahealth #healthyfood #mindfuleating #wellnessjourney
#healthcoach
Actually, we may make it far more fancy by making a crew with different brokers to look a listing of internet sites for content material, a content material checker and reviewer, and one other one to generate a picture for the publish. However I consider you bought the final concept of the best way to add a device
to an Agent
.
One other kind of device we will add is the perform device. We will use a Python perform to function a device for the LLM. Simply don’t overlook 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 would possibly 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 job, 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 a 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 might be an assistant that summarizes YouTube movies.",
instruments=[get_yt_transcript],
expected_output= "A abstract of the video with the 5 details and a couple 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 may have a end result.
Brokers with Reasoning
One other cool choice from the Agno bundle is permitting us to simply create brokers that may analyze the scenario earlier than answering a query. That’s the reasoning device.
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 device ReasoningTools()
.
The adding_instructions=True
means offering detailed directions to the agent, which reinforces the reliability and accuracy of its device utilization, whereas setting this to False
forces the agent to rely by itself reasoning, which may be extra susceptible 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 might be 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 Data
This device is the simplest approach for me to create a Retrieval Augmented Technology (RAG). With this function, you possibly can level the agent to a web 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.information.url import UrlKnowledge
from agno.vectordb.lancedb import LanceDb, SearchType
from agno.embedder.sentence_transformer import SentenceTransformerEmbedder
# Load webpage to the information 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.",
],
information=agent_knowledge,
add_datetime_to_instructions=True,
markdown=True,
)
if __name__ == "__main__":
# Load the information base, you possibly can remark out after first run
# Set recreate to True to recreate the information base if wanted
agent.information.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 kind we are going to go over on this publish is the agent with reminiscence.
Any such agent can retailer and retrieve details about customers from earlier interactions, permitting it to be taught consumer 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 primarily based 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
# Consumer 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 consumer reminiscences
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 Knowledge Scientist studying about AI Brokers.")
reminiscences = reminiscence.get_user_memories(user_id=user_id)
print(f"Recollections about {user_id}:")
pprint(reminiscences)
agent.print_response("What matter ought to I examine about?")
agent.print_response("I write articles for In direction of Knowledge Science.")
print(f"Recollections about {user_id}:")
pprint(reminiscences)
agent.print_response("The place ought to I publish my subsequent article?")

And right here we finish this primary publish about AI Brokers.
Earlier than You Go
There’s plenty of content material on this publish. 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 begin and what to review.
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 publish, 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 may be 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 publish, we are going to be taught extra about brokers and analysis. Keep tuned!
GitHub Repository
https://github.com/gurezende/agno-ai-labs
Contact and On-line Presence
For those who 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/project/youtube-transcript-api/
[4] https://github.com/agno-agi/agno/tree/main/cookbook
[5] https://docs.agno.com/introduction/agents#agent-with-knowledge