Are you interested in creating a chatbot that can interact with IBM Process Mining? Well, you're in luck! In this blog, we'll explore how to create a chatbot that allows users to manage their personal IBM Process Mining projects in a conversational interface.
Let's dive in! Large Language Models (LLMs) have been making waves in the tech industry, especially since the announcement of ChatGPT. These models can produce text and conversational interfaces, making them perfect for chatbot applications and that's exactly what we'll be using them for! We'll be utilizing Langchain, an open-source framework in Python to create our chatbot.
See the chatbot in action:
Langchain makes it easy to create chatbots and virtual agents that can interact with large language models. With Langchain, we can focus on building the chatbot's logic and user interface, without worrying about the underlying complexities of natural language processing. You can get more information on Langchain here https://python.langchain.com/docs/get_started/introduction
Langchain can work with the large language models hosted in various place and you can also use langchain with model hosted on the WatsonX.ai platform thanks to a Langchain WatsonX.ai module created by IBM (see https://www.ibm.com/topics/langchain).
In this chatbot we want to make it possible for a user to do the major actions when managing a process mining project such as creating a new project, uploading data, mining the data, and getting some information on the result. In Langchain we define each one of those actions using the Langchain notion of Tool. Each tool comes with a name, a description, and a set of input data and code to perform the action.
So now how does the chatbot knows which tool the user wants to use? This is where the natural language processing of LLM comes into play.
In a chatbot application like this one, there are a lot of interactions that are happening under the hood with the LLM that are invisible to the user, in particular here the LLM is used to understand the intent of the user and decide on what tool to use based on the tool description and the question of the user.
To understand what action to perform when a user types a question in the chat such as ‘can you create a process mining project named test’. A first question or prompt will be sent to the LLM model with the description of all the tools available and the user question, asking the LLM to find the best tools to answer the question, the expected answer from the LLM is the name of the tool and the input parameters extracted from the question. The LLM is also asked to provide an answer in a JSON format that we can easily parse.
All this interaction is performed by Langchain, under the hood. Langchain helps assembling and sending prompts to the LLM such as: ‘ You are an assistant, knowing that you have the followings tools, what tool should be used to answer the following question:’. And Langchain also help you parse the answer and run the correct tool, in our case invoking IBM Process Mining.
The main work remaining is then to implement the various tools and for our case the tools will be using the IBM Process Mining REST API that allows to perform most of the operations in IBM Process Mining.
Another interesting usage of LLM capabilities in this chatbot is to use the LLM to help the user to configure the process mining project. In IBM Process mining, when uploading event logs in CSV format you have to indicate the name of columns that represent the activity name, the activity start time and an identification of the process to which the activity belongs. The chatbot here is asking the LLM to make a recommendation by providing the names of the columns with a prompt like:
“with the columns of the csv file: {columns}, suggest the column index and column name of the column that best corresponds to 'activity name', the 'start time ' and the 'case id'.
The LLM is capable of making a suggestion as you can see in the video.
If you want to run the chatbot you will have to have an IBM Process Mining account, a WatsonX.AI account to be able to access the large language model and an IBM Cloud Object Storage service as the tool to upload data to process mining expects the data source to be hosted in IBM Cloud Object storage.
The full code is available here: https://github.com/IBM/processmining/tree/main/LLM/chat-with-api