Share E-Book

AI Agents The Illustrated Guidebook (Avi Chawla, Akshay Pachaar)(Z-Library)

Author

,

Rating 3.5 AI initial rating

Log in to rate

AI
Language English

A book about AI agents, with figurative illustrations to guide you through the basics and depths of knowledge of AI agent mechanics, design, and implementation.

Format PDF
Size 5.1 MB
(First 20 pages)

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Page 1
FREE AI AGENTS 2025 EDITION THE ILLUSTRATED GUIDEBOOK Avi Chawla & Akshay Pachaar D a i l y D o s e o f D S . c o m Daily Dose of Data Science
Page 2
DailyDoseofDS.com How to make the most out of this book and your time? The reading time of this book is about 8 hours. But not all chapters will be of relevance to you. This 2-minute assessment will test your current expertise and recommend chapters that will be most useful to you. Scan the QR code below or open this link to start the assessment. It will only take 2 minutes to complete. https://bit.ly/agents-assessment 1
Page 3
DailyDoseofDS.com Table of contents AI Agents....................................................................................................... 4 What is an AI Agent?...................................................................................5 Agent vs LLM vs RAG...................................................................................8 LLM (Large Language Model)..............................................................................8 RAG (Retrieval-Augmented Generation).........................................................9 Agent.............................................................................................................................. 9 Building blocks of AI Agents.....................................................................10 1) Role-playing...........................................................................................................10 2) Focus/Tasks............................................................................................................ 11 3) Tools.......................................................................................................................... 11 #3.1) Custom tools.................................................................................................. 12 #3.2) Custom tools via MCP...............................................................................17 4) Cooperation...........................................................................................................21 5) Guardrails.............................................................................................................22 6) Memory................................................................................................................. 22 5 Agentic AI Design Patterns...................................................................24 #1) Reüection pattern..........................................................................................25 #2) Tool use pattern.............................................................................................25 #3) ReAct (Reason and Act) pattern........................................................... 26 #4) Planning pattern........................................................................................... 28 #5) Multi-Agent pattern.....................................................................................29 5 Levels of Agentic AI Systems................................................................30 #1) Basic responder................................................................................................31 #2) Router pattern.................................................................................................31 #3) Tool calling.......................................................................................................32 #4) Multi-agent pattern.....................................................................................32 #5) Autonomous pattern....................................................................................33 2
Page 4
DailyDoseofDS.com AI Agents Projects.....................................................................................34 #1) Agentic RAG...........................................................................................................35 #2) Voice RAG Agent..................................................................................................41 #3) Multi-agent Flight ûnder................................................................................ 46 #4) Financial Analyst.................................................................................................54 #5) Brand Monitoring System................................................................................ 59 #6) Multi-agent Hotel Finder.................................................................................67 #7) Multi-agent Deep Researcher........................................................................75 #8) Human-like Memory for Agents...................................................................82 #9) Multi-agent Book Writer................................................................................. 89 #10) Multi-agent Content Creation System.....................................................98 #11) Documentation Writer Flow.........................................................................106 #12) News Generator................................................................................................ 112 3
Page 5
DailyDoseofDS.com AI Agents 4
Page 6
DailyDoseofDS.com What is an AI Agent? Imagine you want to generate a report on the latest trends in AI research. If you use a standard LLM, you might: 1. Ask for a summary of recent AI research papers. 2. Review the response and realize you need sources. 3. Obtain a list of papers along with citations. 4. Find that some sources are outdated, so you reûne your query. 5. Finally, a܀昀er multiple iterations, you get a useful output. This iterative process takes time and eûort, requiring you to act as the decision-maker at every step. Now, let9s see how AI agents handle this diûerently: A Research Agent autonomously searches and retrieves relevant AI research papers from arXiv, Semantic Scholar, or Google Scholar. 5
Page 7
DailyDoseofDS.com ï A Filtering Agent scans the retrieved papers, identifying the most relevant ones based on citation count, publication date, and keywords. ï A Summarization Agent extracts key insights and condenses them into an easy-to-read report. ï A Formatting Agent structures the ûnal report, ensuring it follows a clear, professional layout. 6
Page 8
DailyDoseofDS.com Here, the AI agents not only execute the research process end-to-end but also self-reûne their outputs, ensuring the ûnal report is comprehensive, up-to-date, and well-structured - all without requiring human intervention at every step. To formalize AI Agents are autonomous systems that can reason, think, plan, ûgure out the relevant sources and extract information from them when needed, take actions, and even correct themselves if something goes wrong. 7
Page 9
DailyDoseofDS.com Agent vs LLM vs RAG Let9s break it down with a simple analogy: ï LLM is the brain. ï RAG is feeding that brain with fresh information. ï An agent is the decision-maker that plans and acts using the brain and the tools. LLM (Large Language Model) An LLM like GPT-4 is trained on massive text data. It can reason, generate, summarize but only using what it already knows (i.e., its training data). 8
Page 10
DailyDoseofDS.com It9s smart, but static. It can9t access the web, call APIs, or fetch new facts on its own. RAG (Retrieval-Augmented Generation) RAG enhances an LLM by retrieving external documents (from a vector DB, search engine, etc.) and feeding them into the LLM as context before generating a response. RAG makes the LLM aware of updated, relevant info without retraining. Agent An Agent adds autonomy to the mix. It doesn9t just answer a question4it decides what steps to take: Should it call a tool? Search the web? Summarize? Store info? An Agent uses an LLM, calls tools, makes decisions, and orchestrates workûows just like a real assistant. 9
Page 11
DailyDoseofDS.com Building blocks of AI Agents AI agents are designed to reason, plan, and take action autonomously. However, to be eûective, they must be built with certain key principles in mind. There are six essential building blocks that make AI agents more reliable, intelligent, and useful in real-world applications: 1. Role-playing 2. Focus 3. Tools 4. Cooperation 5. Guardrails 6. Memory Let9s explore each of these concepts and understand why they are fundamental to building great AI agents. 1) Role-playing One of the simplest ways to boost an agent9s performance is by giving it a clear, speciûc role. A generic AI assistant may give vague answers. But deûne it as a <Senior contract lawyer,= and it responds with legal precision and context. Why? Because role assignment shapes the agent9s reasoning and retrieval process. The 10
Page 12
DailyDoseofDS.com more speciûc the role, the sharper and more relevant the output. 2) Focus/Tasks Focus is key to reducing hallucinations and improving accuracy. Giving an agent too many tasks or too much data doesn9t help - it hurts. Overloading leads to confusion, inconsistency, and poor results. For example, a marketing agent should stick to messaging, tone, and audience not pricing or market analysis. Instead of trying to make one agent do everything, a better approach is to use multiple agents, each with a speciûc and narrow focus. Specialized agents perform better - every time. 3) Tools Agents get smarter when they can use the right tools. But more tools b better results. 11
Page 13
DailyDoseofDS.com For example, an AI research agent could beneût from: ï A web search tool for retrieving recent publications. ï A summarization model for condensing long research papers. ï A citation manager to properly format references. But if you add unnecessary tools4like a speech-to-text module or a code execution environment4it could confuse the agent and reduce eûciency. #3.1) Custom tools While LLM-powered agents are great at reasoning and generating responses, they lack direct access to real-time information, external systems, and specialized computations. Tools allow the Agent to: ï Search the web for real-time data. ï Retrieve structured information from APIs and databases. ï Execute code to perform calculations or data transformations. ï Analyze images, PDFs, and documents beyond just text inputs. 12
Page 14
DailyDoseofDS.com CrewAI supports several tools that you can integrate with Agents, as depicted below: However, you may need to build custom tools at times. In this example, we're building a real-time currency conversion tool inside CrewAI. Instead of making an LLM guess exchange rates, we integrate a custom tool that fetches live exchange rates from an external API and provides some insights. Below, let's look at how you can build one for your custom needs in the CrewAI framework. Firstly, make sure the tools package is installed: 13
Page 15
DailyDoseofDS.com You would also need an API key from here: https://www.exchangerate-api.com/ (it's free). Specify it in the .env ûle as shown below: Once that's done, we start with some standard import statements: Next, we deûne the input ûelds the tool expects using Pydantic. 14
Page 16
DailyDoseofDS.com Now, we deûne the CurrencyConverterTool by inheriting from BaseTool: Every tool class should have the _run method which we will execute whenever the Agents wants to make use of it. For our use case, we implement it as follows: In the above code, we fetch live exchange rates using an API request. We also handle errors if the request fails or the currency code is invalid. Now, we deûne an agent that uses the tool for real-time currency analysis and attach our CurrencyConverterTool, allowing the agent to call it directly if needed: 15
Page 17
DailyDoseofDS.com We assign a task to the currency_analyst agent. Finally, we create a Crew, assign the agent to the task, and execute it. Printing the response, we get the following output: Works as expected! 16
Page 18
DailyDoseofDS.com #3.2) Custom tools via MCP Now, let9s take it a step further. Instead of embedding the tool directly in every Crew, we9ll expose it as a reusable MCP tool4making it accessible across multiple agents and ûows via a simple server. First, install the required packages: We9ll continue using ExchangeRate-API in our .env ûle: We9ll now write a lightweight server.py script that exposes the currency converter tool. We start with the standard imports: Now, we load environment variables and initialize the server: 17
Page 19
DailyDoseofDS.com Next, we deûne the tool logic with @mcp.tool(): This function takes three inputs4amount, source currency, and target currency4and returns the converted result using the real-time exchange rate API. To make the tool accessible, we need to run the MCP server. Add this at the end of your script: 18
Page 20
DailyDoseofDS.com This starts the server and exposes your convert_currency tool at: http://localhost:8081/sse. Now any CrewAI agent can connect to it using MCPServerAdapter. Let9s now consume this tool from within a CrewAI agent. First, we import the required CrewAI classes. We9ll use Agent, Task, and Crew from CrewAI, and MCPServerAdapter to connect to our tool server. Next, we connect to the MCP tool server. Deûne the server parameters to connect to your running tool (from server.py). Now, we use the discovered MCP tool in an agent: This agent is assigned the convert_currency tool from the remote server. It can now call the tool just like a locally deûned one. 19
The above is a preview of the first 20 pages. Register to read the complete e-book.

Recommended for You

Loading recommended books...
Failed to load, please try again later

Tip the Site

Scan the WeChat Pay or Alipay code to tip. No login required.

WeChat Pay
Alipay
← Back to List