The Synthetic Intelligence business is shifting quick. It’s spectacular and plenty of instances overwhelming.
I’ve been learning, studying, and constructing my foundations on this space of Knowledge Science as a result of I imagine 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 might simply chat with us to a tsunami of AI Brokers which can be in all places, looking out the Web, dealing with information, and making complete Data Science initiatives (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 doable”. In spite of everything, it’s higher to surf the wave than be swallowed by it.
For that cause, 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 complicated ideas.
Sufficient discuss, let’s dive in.
The Fundamentals of AI Brokers
An AI Agent is created once we give the Llm the facility to work together with instruments and carry out helpful actions for us. So, as an alternative of being only a chatbot, now it may possibly schedule appointments, handle 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. Should you observe 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 persist with Agno [1].
First, arrange a digital setting utilizing uv
, Anaconda, or the setting 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 will likely be wanted all through the tutorial
pip set up agno groq lancedb sentence-transformers tantivy youtube-transcript-api
Fast notice earlier than we proceed. Don’t overlook to get a Google Gemini API Key [2].
Making a easy agent could be very easy. All of the packages are very comparable. They’ve a category Agent
or one thing comparable that enables us to pick a mannequin and begin interacting with the LLM of our selection. Listed here are the primary parts of this class:
mannequin
: the reference to the LLM. Right here we are going to select between OpenAI, Gemini, Llama, Deepseek and so forth.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 consider an agent like an worker or an assistant that we’re managing. In an effort to have a process 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 may give directions in regards to 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 ###############
Count on 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 skilled on. If we ask it to inform us the climate right this moment, we’ll see a response saying it may possibly’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 yr?")
# Print response
print(response.content material)
And there’s the consequence.
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 wish to use highly effective fashions comparable to LLMs to play with a chatbot or inform us outdated information, proper?
We would like 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 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 software.
Instruments are features that an Agent can run to attain duties.
When it comes to code, including a software 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 era. This individual posts tips on wholesome habits day-after-day. I do know for a undeniable fact that content material era isn’t as simple because it appears like. It calls for creativity, analysis, and copywriting abilities. So, if this could possibly be automated, or a minimum of 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 put up and reserve it to a markdown file for our overview. We decreased 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 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 put up for instagram with ideas and methods
that positions me as an authority in wholesome consuming
and reserve it to a file named 'put up.txt'.""",
markdown=True)
Consequently, we’ve the next.
Unlock Your Greatest Self Via 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. Conscious 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: Permit for infrequent treats.
Deprivation can result in overeating later. Take pleasure in every part moderately!
5. Plan forward: Prep your meals or snacks prematurely 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 rather more fancy by making a crew with different brokers to go looking an inventory of internet sites for content material, a content material checker and reviewer, and one other one to generate a picture for the put up. However I imagine you bought the overall concept of how you can add a software
to an Agent
.
One other kind of software we will add is the perform software. We are able to use a Python perform to function a software 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 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 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 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 have got a consequence.
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 software.
We are going to create a reasoning agent with Alibaba’s Qwen-qwq-32b mannequin. Discover that the one distinction right here, apart from the mannequin, is that we’re including the software ReasoningTools()
.
The adding_instructions=True
means offering detailed directions to the agent, which reinforces the reliability and accuracy of its software utilization, whereas setting this to False
forces the agent to rely by itself reasoning, which will 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 software is the best approach for me to create a Retrieval Augmented Era (RAG). With this function, you may level the agent to a web site or an inventory 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="initiatives",
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 kind we are going to go over on this put up is the agent with reminiscence.
This sort of 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 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 Identify
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 identify is Gustavo and I'm a Knowledge Scientist studying about AI Brokers.")
reminiscences = reminiscence.get_user_memories(user_id=user_id)
print(f"Reminiscences about {user_id}:")
pprint(reminiscences)
agent.print_response("What matter ought to I research about?")
agent.print_response("I write articles for In the direction of Knowledge Science.")
print(f"Reminiscences about {user_id}:")
pprint(reminiscences)
agent.print_response("The place ought to I put up my subsequent article?")

And right here we finish this primary put up about AI Brokers.
Earlier than You Go
There’s a variety of content material on this put up. We climbed step one on this ladder of studying about AI brokers. I do know, it’s overwhelming. There’s a lot data on the market that it turns into more durable and more durable to know the place to begin and what to review.
My suggestion is to take the identical highway I’m taking. One step at a time, selecting simply a few packages like Agno, CrewAI, and going deep on these, studying how you can create extra complicated brokers every time.
On this put up, we began from scratch, studying how you can 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 rather more you are able to do simply with a single agent. Take a look at the Reference [4].
With these easy abilities, ensure 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 put up, 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
Should you appreciated 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