====================== AI ChatBot with Web UI ====================== Prerequisites ============= To run Open WebUI, we will utilize Docker. Docker is the easiest way to get this web interface installed and running on your Pi. 1. Install Docker ----------------- Download and run the official Docker setup script by running the following command. .. code-block:: bash curl -sSL https://get.docker.com | sh By default, only the Docker user can interact with Docker but there is a way to work around this. For another user to be able to interact with Docker, it needs to be added to the docker group. The next step is to add our current user to the docker group by using the usermod command as shown below. By using “$USER” we are inserting the environment variable that stores the current users name. .. code-block:: bash sudo usermod -aG docker $USER Since we made some changes to our user, we will now need to log out and log back in for it to take effect. You can log out by running the following command in the terminal. .. code-block:: bash logout After logging back, verify that the docker group has been successfully added to your user by running the following command. .. code-block:: bash groups To test if Docker is working, we are going to go ahead and run the following command on our Pi. This command will tell Docker to download, setup and run a docker container called “hello-world". .. code-block:: bash docker run hello-world 2. Install Ollama and Open Web UI --------------------------------- .. note:: sources: https://pimylifeup.com/raspberry-pi-ollama/, https://pimylifeup.com/raspberry-pi-open-webui/ .. code-block:: bash curl -fsSL https://ollama.com/install.sh | sh Using the command below, we can verify that we just successfully installed Ollama on our Raspberry Pi. This command gets Ollama to output its version to the terminal. .. code-block:: bash ollama --version Open WebUI doesn’t process messages; it just provides a sleek interface for interacting with large language models. In our case, we will use Ollama to process any messages we send to the interface. By default, Ollama is configured to only listen on the local loopback address. Luckily, we can change this to listen on all addresses. If we don’t, Open WebUI on our Raspberry Pi won’t be able to communicate with Ollama. To start this process, we need to edit the Ollama service using the following command. .. code-block:: bash sudo systemctl edit ollama.service Within this file, you will want to find the following line. It should be near the top of this file. .. code-block:: bash ### Anything between here and the comment below will become the new contents of the file After finding this line, you must add the following. This line sets an environment variable that tells Ollama to listen on all IP addresses. .. code-block:: bash [Service] Environment="OLLAMA_HOST=0.0.0.0" Since we made some changes to the Ollama service we will need to restart the Systemd daemon using the following command. .. code-block:: bash sudo systemctl daemon-reload After the daemon has been reloaded, you can restart Ollama by running the command below within the terminal. .. code-block:: bash sudo systemctl restart ollama .. note:: To install a model (i.e. tinyllama) type the following: `ollama run tinyllama` and to remove `ollama rm tinyllama` With Ollama now reconfigured, we can install Open WebUI on our Raspberry Pi. The first part of this process is to create a directory to store the Open WebUI Compose file and give it a place to store its data. You can create this directory using the mkdir command, as shown below. .. code-block:: bash sudo mkdir -p /opt/stacks/openwebui cd /opt/stacks/openwebui **Writing a Docker Compose File for Open WebUI on the Raspberry Pi**: - After changing to the Open WebUI directory, we can move on to writing the Compose file for the software. - This Compose file will tell Docker how to install and run Open WebUI on your Raspberry Pi. .. code-block:: bash sudo nano compose.yaml .. code-block:: bash services: open-webui: image: ghcr.io/open-webui/open-webui:main container_name: open-webui volumes: - ./data:/app/backend/data ports: - 3000:8080 # Changed to 3001:8079 extra_hosts: - host.docker.internal:host-gateway restart: unless-stopped **Starting Open WebUI**: - After you have finished writing the Compose file, you can start up Open WebUI container on your Raspberry Pi by running the command below. - This process can take a few minutes as Docker downloads the various layers and starts the service. .. code-block:: bash docker compose up -d **Accessing the Open WebUI Interface**: - Now that you have Open WebUI up and running on your Raspberry Pi, you will want to access its interface. - If you don’t know the IP address of your Raspberry Pi, you can use the hostname command. .. code-block:: bash hostname -I - In your favorite web browser, go to the following URL. - Ensure that you replace “” with the IP of your Pi to continue. .. code-block:: bash http://:3000 .. note:: To stop a container enter the following: `$ docker stop open-webui` Create a account. 3. Configure Ollama and Web UI ------------------------------ Selecting a Model for Open WebUI to Run on your Raspberry Pi Now that you have Open WebUI installed on your Raspberry Pi, you will probably want to know how to use it. First, you must select a model for Open WebUI by clicking the select box (1.) at the top of the screen. Following our Ollama guide, you should already have some LLMs referenced in this list. Select the AI model you want Open WebUI to use for the current session (2.). Please note: If you are missing models here, Ollama is either not running or you haven’t yet installed any models. You can visit our Ollama tutorial to see how to pull a new LLM, or you can skip to the next section to see how to do this through the web interface. Once a language model is selected, you can type in a message in the textbox at the bottom of the screen and press ENTER. OpenWeb UI will send this message to your runner, which in this case will be Ollama, and then return the result as it becomes available.