Cheshire Cat AI Conversation Logger

Today, with a great help of my pal Ilario Febi, we kicked-off a new plugin for the marvelous Cheshire Cat AI Framework.

Cheshire Cat AI is a production-ready AI framework. With few lines of Python code you can build your own custom AI assistant and have it available as a microservice.

Why the Conversation Logger?

Recently I introduced the usage of Cheshire Cat AI in OCTO Telematics as the backend for the Chatbot that is hosted on the Home Page of OCTO’s Website. I’ll write some more details on this later on.

As soon as the Chatbot was online we felt the need to understand how the AI was dealing with the users: was it helpful? was it’s knowledge base complete? could we insert more contents?

Cheshire Cat AI basically logs anything that is going on in console in order to allow you to deeply debug it’s interaction. It’s useful, but actually we quickly found it was a bit too much for our easier need of just understanding how the conversations were flowing.

Luckily Cheshire Cat AI features a powerful Hooks-based plugin system. In a few minutes the idea of hooking to the “Before Cat sends message” hook was running wild into my head.

So Ilario, with his knowledge of Python came to rescue and we quickly hacked a version 0.0.1 of the Plugin.

How does it work?

The usage is actually super simple. You drop the Plugin into Cheshire Cat AI and enable it.

The plugin management interface

Then you can configure a Database where the conversion will be logged:

The Database Configuration Section

We spent some minutes to support multiple DBs out of the box:

  • SQLite: to give a quick “local” solution with no hassle
  • Oracle MySQL / MariaDB and PostgreSQL: to give the possibility of hosting a centralized Database, shared among different Cheshire Cat AI instances.

Yep, in fact the conversations are logged with full tracking of the originating Cheshire Cat AI Instance and of the user dealing with the bot inside a “ccat_conversation” table with the following structure:

CREATE TABLE `ccat_conversations` (
  `id` int NOT NULL AUTO_INCREMENT,
  `instance` varchar(256) NOT NULL,
  `username` varchar(256) NOT NULL,
  `input` text NOT NULL,
  `output` text NOT NULL,
  `ts` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `instance` (`instance`),
  KEY `ts` (`ts`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
  • instance represent the hostname of the Cheshire Cat AI instance logging the conversation,
  • username represent the user interacting with Cheshire Cat AI
  • input represent the statement coming from the user
  • output represent the statement coming out from Cheshire Cat AI
  • ts is the actual timestamp of the message

In the next days we’ll start analyzing the conversation that has been logged in order to understand how we can improve the Knowledge Base used by the Chatbot, how we can improve the prompt for the Chatbot and which are the hottest topics our users are interested in.

Me like it, me want it!

Yep! If you want to try the plugin in your instance of Cheshire Cat AI, we just released it in the official Cheshire Cat Plugin Repository, so as soon as the pull request will be accepted the plugin will be globally available!

Have fun!

Lascia un commento

Questo sito utilizza Akismet per ridurre lo spam. Scopri come vengono elaborati i dati derivati dai commenti.