In this video we get started with Open WebUI which is is an extensible, self-hosted AI interface. Basically a web interface for your locally or remote hosted LLMs.
Here are all the resources for the video and the commands I typed in the command line, so you can easily copy paste them. This is not a step by step guide, you need to follow the video to get the whole content.
Requirements: To follow this video I recommend you are already familiar with Docker and the command line interface. If you are not, checkout these videos: – Docker / Docker compose (video) – Familiarity with the command line interface (video)
If you already have docker the steps followed in the video are:
We can also use the run command to pull the model and it will do it all in one go.
Docker compose file called docker-compose.yml to run Open WebUI. This is a very basic docker compose file, you can extend the capabilities from here as much as you want. Check the Open WebUI git repository for more information.
From the same directory the docker compose file is located, run the docker compose command to start Open WebUI
dockercomposeup-d
To install LiteLLM, clone the repository in some local folder
gitclonegit@github.com:BerriAI/litellm.git
Move to that folder and create an .env file with the following content. For the password you only need to keep the sk- at the beginning and then add whatever password you want.
We will setup a local kubernetes cluster using k3d which is a wrapper around another tool called k3s, which is a lightweight Kubernetes distribution designed for resource-constrained environments. The beauty of k3d is that you can spin up a multi-node cluster on your machine with a single command. In our example the cluster will provide a simple website with a hello world message. This will give you the basis to setup any other complex cluster running your application. I tested this with heavy applications and works really well. I wouldn’t use it for a production environment handling a heavy load, but it’s perfect to replicate a production cluster locally for testing or developing purposes.
Prerequisites
Before we start we need to install some basic tools and also I would recommend some other extra, not necessary tools, that will make your like easier like k9s.
I assume you are familiar with the command line interface, if not, check my video here! I also assume you have docker installed and you are familiar with it as well, otherwise check this other video here. Also I assume you have some familiarity with Kubernetes, if not I recommend The Kubernetes Book by Nigel Poulton.
In this video I’m going to use homebrew for Mac and for Linux as well. For those not familiar with it, homebrew is a package manager for macOS and Linux, which will simplify the installation process. In case of Linux some might think “why using another package manager, we already have one for Linux!” that’s true, but installing these tools in Linux without Homebrew require more steps because not all of them are available in the usual repositories. There’s plenty of documentation on how to install them on Linux and at of this post, I left instructions.
If you don’t have Homebrew go to this link and install it. The process is straight forward. Once you have it installed continue here:
brewinstallk3dkubectlk9s
k9s is not strictly necessary but I really recommend installing it. We will use it in this tutorial, it’s an extremely helpful and handy tool to have. You can do everything k9s does with kubectl but why wasting time when we have a took that makes our life way easier.
Create the registry
Before we create the cluster, it’s not mandatory, but we better create a registry. This will allow us to upload our Docker images similar to a real scenario.
Here I’m using port 5001 because on macOS the port 5000 is already used. You can use any port you want, as long as it’s free to use.
k3dregistrycreateregistry--port5001
Create the cluster
We need to create the cluster first. It will deploy a series of Docker containers that will be responsible to run our cluster. We won’t have to deal with these containers, it’s all managed internally by k3d.
In this case we won’t bother to setup a namespace because for testing purposes the default is fine. But k3d is powerful enough to handle almost all kubernetes operations. It’s a great tool for learning and testing.
To deploy we just do the same as if we have a cluster running in the cloud or anywhere else. In this case we use simple manifests, but we can also use helm.
You can download the files from the repository associated to this video and run the following commands inside the repo:
This is how Python is usually installed in a development environment to be used with other developers. This is the way I usually installed it with my teams and the way other developers use it. If you are using Python only for your own projects, then maybe there’s no need to go the extra mile.
We are going to use a command called pyenv, which basically allows you to have multiple versions of Python installed in your system. This is useful because you might clone different projects that were developed using a particular version of Python, so you can run them with the right version.
The instructions here are command line based and for Linux, but they are very similar for macOS as well. This doesn’t cover how to install it on Windows.
I’m going to assume a minimum Linux installation, so you can see exactly all that is required.
I also assume you have some knowledge of the command line interface, if you don’t, then checkout my video about getting from zero to hero with the command line.
Installation
macOS
If you are using macOS just go to brew.sh follow the instructions to install Homebrew, which is a package manager for macOS. Then run:
brewinstallpyenv
And that’s pretty much it, pyenv will be installed in your system. Ir order to configure it, you can follow the same instructions at the end of the Linux installation where we talk about configuring the shell init script.
Linux
If you want to save time and you don’t care much about the details, you can run this command:
curlhttps://pyenv.run|bash
Basically it downloads a script and does the rest for you. I found some issues running it in some systems, so I will go ahead and do the manual part, but if it works for you and that’s all you care, feel free to skip to the next section where we learn how to use pyenv.
Here I’m using Debian, this works on any Debian derivative Linux distribution. For other distributions the process is very similar, just make sure you are using the right package manager:
This part is common for macOS and Linux. Basically add the following lines to your shell init script. It could be .bashrc or .zshrc depending on which shell you are using.
That’s it, now when you login again in your machine, you should have fully functional pyenv.
Using pyenv
This part is common for macOS and Linux. At this point, most probably you already have some version of Python installed in your system, but we don’t really care about it at this point because we will manage all of that with pyenv.
$pyenvversions$pyenvversions* system (setby/home/mc/.pyenv/version)$
This means that no particular version of Python has been installed. To get a full list of all the versions and flavours of Python that pyenv supports, execute:
pyenvinstall--list
The list is huge, so let’s just focus for now to install the latest version, that at the time of writing this article the latest version is 3.12.2, just run:
pyenvinstall3.12
This will install the latest version of 3.12, in your system. It might take some time depending on how fast is your machine. If you run again:
$pyenvversions* system (setby/home/mc/.pyenv/version)3.12.2
We can confirm that 3.12.2 has been installed. We want to make it global so we can use it every time we open a terminal. To do that, type: