Build LLM Agents Faster with Datapizza AI – Towards Data Science

Welcome to the forefront of conversational AI as we explore the fascinating world of AI chatbots in our dedicated blog series. Discover the latest advancements, applications, and strategies that propel the evolution of chatbot technology. From enhancing customer interactions to streamlining business processes, these articles delve into the innovative ways artificial intelligence is shaping the landscape of automated conversational agents. Whether you’re a business owner, developer, or simply intrigued by the future of interactive technology, join us on this journey to unravel the transformative power and endless possibilities of AI chatbots.
Publish AI, ML & data-science insights to a global community of data professionals.
The new GenAI framework "Made in Italy"
Organizations are increasingly investing in AI as these new tools are adopted in everyday operations more and more. This continuous wave of innovation is fueling the demand for more efficient and reliable frameworks. Following this trend, Datapizza (the startup behind Italy's tech community) just released an open-source framework for GenAI with Python, called Datapizza AI.
When creating LLM-powered Agents, you need to pick an AI stack:
Language Model – the brain of the Agent. The first big choice is open-source (i.e. Llama, DeepSeek, Phi) vs paid (i.e. ChatGPT, Claude, Gemini). Then, based on the usecase, one needs to consider the LLM knowledge: generic (knows a little bit of everything like Wikipedia) vs topic-specific (i.e. fine-tuned for coding or finance).
LLM Engine – it's what runs the language model, responding to prompts, inferring meaning, and creating text. Basically, it generates intelligence. The most used are OpenAI (ChatGPT), Anthropic (Claude), Google (Gemini), and Ollama (runs open-source models locally).
AI Framework – it's the orchestration layer to build and manage workflows. To put it in another way, the framework must structure the intelligence created by LLMs. At the moment, the landscape is dominated by LangChain, LLamaIndex, and CrewAI. The new library Datapizza AI falls in this category and wants to be an alternative to the other main frameworks.
In this article, I’m going to show how to use the new Datapizza framework for building LLM-powered AI Agents. I will present some useful Python code that can be easily applied in other similar cases (just copy, paste, run) and walk through every line of code with comments so that you can replicate this example.
I will use Ollama as the LLM engine, because I like to host models locally on my computer. That is the standard practice for all companies with sensitive data. Keeping everything local gives full control over data privacy, model behavior, and cost.
First of all, you need to download Ollama from the website. Then, pick a model and run the command indicated on the page to pull the LLM. I’m going with Alibaba’s Qwen, as it’s both smart and lite (ollama run qwen3).
Datapizza AI supports all the main LLM engines. We can complete the setup by running the following commands:
As indicated in the official documentation, we can quickly test our AI stack by calling the model with a simple prompt and asking a question. The object OpenAILikeClient() is how you connect to the Ollama API, which is usually hosted on the same localhost URL.
Another way to test the capability of the LLM is to build a simple Chatbot and do some conversation. To do so, at every interaction, we need to store the chat history and feed it back to the model, specifying what was said by whom. The Datapizza framework already has a built-in memory system.
If you want to retrieve the chat history, you can just access the memory. Usually, AI frameworks use three roles in the interaction with an LLM: "system" (core instructions), "user" (what was said by the human), "assistant" (what the chatbot replied).
Obviously, the LLM alone is very limited and it can’t do much besides chatting. Therefore, we need to give it the possibility to take action, or in other words, to activate Tools.
Tools are the main difference between a simple LLM and an AI Agent. When the user requests something that goes beyond the LLM knowledge base (i.e. "what time is it now?"), the Agent should understand that it doesn't know the answer, activate a Tool to get additional information (i.e. checking the clock), elaborate the result through the LLM, and generate an answer.
The Datapizza framework allows you to create Tools from scratch very easily. You just need to import the decorator @tool and any function can become actionable for the Agent.
Then, assign the designated Tool to the Agent, and you'll have an AI that combines language understanding + autonomy decision making + tool use.
An LLM-powered AI Agent is an intelligent system built around a language model that doesn’t just respond, but it reasons, decides, and acts. Besides conversation (which means chatting with a general-purpose knowledge base), the most common actions that Agents can do are RAG (chatting with your documents), Querying (chatting with a database), Web Search (chatting with the whole Internet).
For instance, let's try a web searching Tool. In Python, the easiest way to do it is with the famous private browser DuckDuckGo. You can directly use the original library or the Datapizza framework wrapper (pip install datapizza-ai-tools-duckduckgo).
Let's create an Agent that can search the web for us. If you want to make it more interactive, you can structure the AI like I did for the Chatbot.
The real strength of Agents is the ability to collaborate with each other, just like humans do. These teams are called Multi-Agent Systems (MAS), a group of AI Agents that work together in a shared environment to solve complex problems that are too difficult for a single one to handle alone.
This time, let's create a more advanced Tool: code execution. Please note that LLMs know how to code by being exposed to a large corpus of both code and natural language text, where they learn patterns, syntax, and semantics of programming languages. But since they can not complete any real action, the code they create is just text. In short, LLMs can generate Python code but can’t execute it, Agents can.
There are two types of MAS: the sequential process ensures tasks are executed one after the other, following a linear progression. On the other hand, the hierarchical structure simulates traditional organizational hierarchies for efficient task delegation and execution. Personally, I tend to prefer the latter as there is more parallelism and flexibility.
With the Datapizza framework, you can link two or more Agents with the function can_call(). In this way, one Agent can pass the current task to another Agent.
This article has been a tutorial to introduce Datapizza AI, a brand new framework to build LLM-powered Chatbots and AI Agents. The library is very flexible and user-friendly, and can cover different GenAI usecases. I used it with Ollama, but it can be linked with all the famous engines, like OpenAI.
Full code for this article: GitHub
I hope you enjoyed it! Feel free to contact me for questions and feedback or just to share your interesting projects.
👉 Let’s Connect 👈
(All images are by the author unless otherwise noted)
Written By
Share This Article
Towards Data Science is a community publication. Submit your insights to reach our global audience and earn through the TDS Author Payment Program.
#7: Using the previous or next value
Interview Questions from Facebook, Yelp, Amazon, Google, Apple, Netflix, and More
Inside the research that shows algorithmic price-fixing isn't a bug in the code. It's a feature of the math.
Talking with LLMs about images, without training LLMs on images.
AI and Definitions of Terrorism In Social Media
4 key lessons learned the hard way
Create a local CLI Agent from scratch completely for free
How to set the rules that keep agents effective and out of trouble
EuroSAT land cover image classification using a TensorFlow convolutional neural network
Your home for data science and AI. The world's leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.

source

Scroll to Top