I ended up transferring my home project dashboard into a chatbot. I even used Telegram's BotFather platform to do so. This platform is rich in that it has buttons, conversations, media processing, and even a web view framework. I was able to fulfill the most complex scenarios, and since then, I’ve stopped using the dashboard except for certain flows where I haven’t migrated yet.

This project is all about personal finance management, providing detailed insights and statistics on my spending. The foundation of my approach comes from two classics: Total Money Makeover by Dave Ramsey and Rich Dad, Poor Dad by Robert Kiyosaki. As a proof of concept, I’m really happy with how it turned out, and I plan to refine it even more.

Chatbots and LLMs: A Perfect Match?

Chatbots scream LLM. Take a simple flow such as creating a new expense. It is about choosing a category for this expense, a sub-category, and a store if necessary, along with the expense amount, date, description, and payment method used. It is a long conversation with intertwined dependencies resembling a graph traversal. If I were to implement it with an LLM, I could not do so without using an agentic platform such as PydanticAI or LangChain.

I am amazed by the subtle architecture created by the Pydantic team. They built an agentic platform that is simple yet very powerful. PydanticAI helps with integrating tools into the chatbot. These tools can be plain, as they call them. In our terms, these are stateless tools. And there are stateful tools that depend on context. Dependencies are a powerful objective within the architecture, enabling the tools to share resources, whether it is database connections, connection pools, or anything else. PydanticAI features include the dynamic function. In their terms, they call it "prepare." It is a decorator that uses a function to decide whether to omit or add tools as a next step in the LLM messaging graph. In the scenario above, it comes in handy when picking the next field. If we want to add an expense that doesn't have a store, for example, a parking ticket, I won’t care who got the payment as long as it went down the drain.

PydanticAI is powerful when it comes to AI model orchestration. It enables orchestrating several models through several agents to perform different tasks. If I want to run a task that requires accuracy, I would pick Claude rather than CoPilot. Or if I want to execute a simple task, I will go through the cheapest model, and only if the output is not satisfactory or even fails, I will fall back to a bigger and more expensive tool.

pydanticai #telegram