On this page
Introduction to ToolJet and Ollama
ToolJet is a low-code platform that enables developers to build custom internal tools quickly and efficiently. Ollama, on the other hand, is a self-hosted Large Language Model (LLM) that can be used to power conversational AI agents. In this tutorial, we will show you how to connect a locally hosted Ollama LLM to ToolJet as a conversational AI agent, enabling natural-language data lookup, form assistance, and automated reporting within self-hosted internal tools.
Prerequisites
Before you start, you will need:
- A $5 VPS with a supported operating system (e.g., Ubuntu)
- Docker and Docker Compose installed on your VPS
- Basic knowledge of Docker and Docker Compose
- A ToolJet instance set up on your VPS
- An Ollama LLM instance set up on your VPS
Setting up ToolJet
To set up ToolJet on your VPS, you can use the following Docker Compose example:
version: '3'
services:
tooljet:
image: tooljet/tooljet:latest
ports:
- "80:3000"
environment:
- TOOLJET_DB_HOST=postgres
- TOOLJET_DB_PORT=5432
- TOOLJET_DB_USER=tooljet
- TOOLJET_DB_PASSWORD=tooljet
- TOOLJET_DB_NAME=tooljet
depends_on:
- postgres
restart: always
postgres:
image: postgres:latest
environment:
- POSTGRES_USER=tooljet
- POSTGRES_PASSWORD=tooljet
- POSTGRES_DB=tooljet
volumes:
- tooljet-pg-data:/var/lib/postgresql/data
restart: always
volumes:
tooljet-pg-data:
You can then run docker-compose up -d to start the ToolJet service in detached mode.
Setting up Ollama
To set up Ollama on your VPS, you can use the following command:
git clone https://github.com/ollama/ollama.git
cd ollama
docker build -t ollama .
docker run -d -p 8080:8080 ollama
This will build and run the Ollama LLM instance on your VPS.
Connecting Ollama to ToolJet
To connect Ollama to ToolJet, you will need to create a new API endpoint in ToolJet that will forward requests to the Ollama LLM instance. You can do this by creating a new file called ollama.js in the tooljet/plugins directory:
const axios = require('axios');
module.exports = {
name: 'Ollama',
description: 'Ollama LLM plugin',
methods: {
query: async (query) => {
const response = await axios.post('http://localhost:8080/query', {
query,
});
return response.data;
},
},
};
You can then register the plugin in ToolJet by creating a new file called plugins.js in the tooljet directory:
module.exports = {
plugins: [
{
name: 'Ollama',
file: 'ollama.js',
},
],
};
Using the Ollama Chatbot in ToolJet
To use the Ollama chatbot in ToolJet, you can create a new app that uses the Ollama plugin. For example, you can create a new app called Chatbot that uses the Ollama plugin to power a conversational AI agent.
Pros and Cons
The pros of using Ollama with ToolJet include:
- Self-hosted LLM instance for increased security and control
- Customizable conversational AI agent
- Integration with ToolJet for seamless data lookup and form assistance
The cons of using Ollama with ToolJet include:
- Requires technical expertise to set up and configure
- May require significant computational resources to run
Who should use this?
This solution is ideal for developers, sysadmins, homelab users, and technical founders who want to embed AI chat capabilities into self-hosted internal applications without relying on external APIs.
When not to use this?
This solution may not be suitable for:
- Small teams or individuals who do not have the technical expertise to set up and configure Ollama and ToolJet
- Teams that require a high level of scalability and reliability, as the self-hosted LLM instance may require significant computational resources to run
FAQ
- What is Ollama? Ollama is a self-hosted Large Language Model (LLM) that can be used to power conversational AI agents.
- What is ToolJet? ToolJet is a low-code platform that enables developers to build custom internal tools quickly and efficiently.
- How do I set up Ollama on my VPS? You can set up Ollama on your VPS by cloning the Ollama repository, building the Docker image, and running the container.
- How do I connect Ollama to ToolJet? You can connect Ollama to ToolJet by creating a new API endpoint in ToolJet that forwards requests to the Ollama LLM instance.
- What are the pros and cons of using Ollama with ToolJet? The pros of using Ollama with ToolJet include self-hosted LLM instance, customizable conversational AI agent, and integration with ToolJet. The cons include requiring technical expertise to set up and configure, and may require significant computational resources to run.
In conclusion, adding an Ollama-powered AI chatbot to ToolJet low-code apps on a $5 VPS is a cost-effective and secure way to embed AI chat capabilities into self-hosted internal applications. For more information on self-hosted AI and local LLM solutions, visit mahbuburriad.com.