AI Agents Crash Course—Part 7 (With Implementation)

A deep dive into Knowledge for Agentic systems.

👉

Introduction

So far in this AI Agent crash course series, we’ve built powerful agents that:

  • Collaborate across tasks and roles.
  • Execute asynchronously.
  • Use callbacks, guardrails, and multimodal inputs.
  • Work under human supervision and within hierarchical processes.
  • and many many more things.

However, so far, our Agents have mostly worked with inputs and tools we provided at runtime, like a prompt, a blog URL, or a tool to take some real-world action.

What if you want your agents to:

  • Access a company knowledge base?
  • Query structured datasets like CSVs or JSON?
  • Read and recall insights from PDFs, docs, or text files?
  • Answer questions based on internal documentation or product specs.

Knowledge helps you do that and this is what we are discussing today.

Let's dive in to learn more about it. Like always, everything will be supported with clear explanations to help you learn practically.


A quick note

In case you are new here...

Over the past six parts of this crash course, we have progressively built our understanding of Agentic Systems and multi-agent workflows with CrewAI.

  • In Part 1, we covered the fundamentals of Agentic systems, understanding how AI agents can act autonomously to perform structured tasks.
AI Agents Crash Course—Part 1 (With Implementation)
A deep dive into the fundamentals of Agentic systems, building blocks, and how to build them.
  • In Part 2, we explored how to extend Agent capabilities by integrating custom tools, using structured tools, and building modular Crews to compartmentalize responsibilities.
AI Agents Crash Course—Part 2 (With Implementation)
A deep dive into the fundamentals of Agentic systems, building blocks, and how to build them.
  • In Part 3, we focused on Flows, learning about state management, flow control, and integrating a Crew into a Flow. As discussed last time, with Flows, you can create structured, event-driven workflows that seamlessly connect multiple tasks, manage state, and control the flow of execution in your AI applications.
AI Agents Crash Course—Part 3 (With Implementation)
A deep dive into implementing Flows for building robust Agentic systems.
  • In Part 4, we extended these concepts into real-world multi-agent, multi-crew Flow projects, demonstrating how to automate complex workflows such as content planning and book writing.
AI Agents Crash Course—Part 4 (With Implementation)
A deep dive into implementing Flows for building robust Agentic systems.
  • In Part 5 and 6, we shall move into advanced techniques that make AI agents more robust, dynamic, and adaptable.
    • Guardrails → Enforcing constraints to ensure agents produce reliable and expected outputs.
    • Referencing other Tasks and their outputs → Allowing agents to dynamically use previous task results.
    • Executing tasks async → Running agent tasks concurrently to optimize performance.
    • Adding callbacks → Allowing post-processing or monitoring of task completions.
    • Introduce human-in-the-loop during execution → Introducing human-in-the-loop mechanisms for validation and control.
    • Hierarchical Agentic processes → Structuring agents into sub-agents and multi-level execution trees for more complex workflows.
    • Multimodal Agents → Extending CrewAI agents to handle text, images, audio, and beyond.
    • and more.
AI Agents Crash Course—Part 5 (With Implementation)
A deep dive into advanced techniques to make robust Agentic systems.
AI Agents Crash Course—Part 6 (With Implementation)
A deep dive into advanced techniques to make robust Agentic systems.

Installation and setup

💡
Feel free to skip this part if you have followed these instructions before.

Throughout this crash course, we have been using CrewAI, an open-source framework that makes it seamless to orchestrate role-playing, set goals, integrate tools, bring any of the popular LLMs, etc., to build autonomous AI agents.

GitHub - crewAIInc/crewAI: Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.
Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks. - crewAIInc/crewAI

To highlight more, CrewAI is a standalone independent framework without any dependencies on Langchain or other agent frameworks.

Let's dive in!

To get started, install CrewAI as follows:

Like the RAG crash course, we shall be using Ollama to serve LLMs locally. That said, CrewAI integrates with several LLM providers like:

  • OpenAI
  • Gemini
  • Groq
  • Azure
  • Fireworks AI
  • Cerebras
  • SambaNova
  • and many more.
💡
If you have an OpenAI API key, we recommend using that since the outputs may not make sense at times with weak LLMs. If you don't have an API key, you can get some credits by creating a dummy account on OpenAI and use that instead. If not, you can continue reading and use Ollama instead but the outputs could be poor in that case.

To set up OpenAI, create a .env file in the current directory and specify your OpenAI API key as follows:

Also, here's a step-by-step guide on using Ollama:

  • Go to Ollama.com, select your operating system, and follow the instructions.
    • If you are using Linux, you can run the following command:

  • Ollama supports a bunch of models that are also listed in the model library:
library
Get up and running with large language models.

Once you've found the model you're looking for, run this command in your terminal:

The above command will download the model locally, so give it some time to complete. But once it's done, you'll have Llama 3.2 3B running locally, as shown below, which depicts Microsoft's Phi-3 served locally through Ollama:

0:00
/0:29

That said, for our demo, we would be running Llama 3.2 1B model instead since it's smaller and will not take much memory:

Done!

Everything is set up now and we can move on to building robust agentic workflows.

You can download the code for this article below:

Join the Daily Dose of Data Science Today!

A daily column with insights, observations, tutorials, and best practices on data science.

Get Started!
Join the Daily Dose of Data Science Today!

Great! You’ve successfully signed up. Please check your email.

Welcome back! You've successfully signed in.

You've successfully subscribed to Daily Dose of Data Science.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.