How to Deploy Flowise Application As A Hugging Face Space

Ifeanyi Idiaye
4 min readSep 21, 2023

--

In this post, I will show you how to deploy Flowise application as a Space on Hugging Face.

Flowise is a no-code system that allows you to easily build and deploy large language model (LLM) applications using the Langchain framework. With it, you can easily build chatbots, AI assistants, web scrapers, and document analyzers without writing a single line of code.

It uses a drag & drop interface that makes it easy to create and run an application.

Installation

I tried before to install Flowise on my machine using the command:

npm install -g flowise

But I ran into some issues that necessitated me jumping into its config file and making some changes in there. After that, I started the application with the command:

npx flowise start

Then, I accessed it at http://localhost:3000 in my browser. Nevertheless, there was still a problem, as the AI application flows I built always returned an error whenever I ran them.

However, I came across a better way to use Flowise, which is to deploy it as a Hugging Face Space. And ever since I did so, I have been able to build and run LLM applications without any hassle.

The reason is because the Flowise app is deployed with Docker on Hugging Face, and so it is running as a self-contained application, where all its dependencies are installed inside a container and the application runs from inside that container independent of your local machine’s settings and configurations.

Now, let me show you how I deployed the app on Hugging Face with the following steps so you too can do the same.

Step 1: Create A New Space on Hugging Face

  • Go to Hugging Face and sign in if you already have an account, otherwise create one.
  • Create a new Space and give it a name. A Hugging Face Space is built on top of GitHub. So, as a GitHub user, it should not look too strange to you
  • Select Docker as Space SDK and choose Blank as the Docker template.
  • Select CPU basic ∙ 2 vCPU ∙ 16GB ∙ FREE as Space hardware.
  • Click Create Space.

Step 2: Set Environment Variables

  • Go to Settings of your new space and find the Variables and Secrets section
  • Click on New variable and add the name as PORT with value 7860
  • Click on Save

As an option, you can click on New secret and enter your environment variables, such as database credentials, file paths and so on.

Step 3: Create A Dockerfile

  • At the files tab, click on button + Add file and click on Create a new file
  • Create a Dockerfile and paste the following:
FROM node:18-alpine
USER root

# Arguments that can be passed at build time
ARG FLOWISE_PATH=/usr/local/lib/node_modules/flowise
ARG BASE_PATH=/root/.flowise
ARG DATABASE_PATH=$BASE_PATH
ARG APIKEY_PATH=$BASE_PATH
ARG SECRETKEY_PATH=$BASE_PATH
ARG LOG_PATH=$BASE_PATH/logs

# Install dependencies
RUN apk add --no-cache git python3 py3-pip make g++ build-base cairo-dev pango-dev chromium

ENV PUPPETEER_SKIP_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser

# Install Flowise globally
RUN npm install -g flowise

# Configure Flowise directories using the ARG
RUN mkdir -p $LOG_PATH $FLOWISE_PATH/uploads && chmod -R 777 $LOG_PATH $FLOWISE_PATH

WORKDIR /data

CMD ["npx", "flowise", "start"]
  • Click on Commit file to main and it will start to build your app.

The build will take several minutes to complete. Once it is done, you should see the launched Flowise interface that looks like this.

Flowise interface on Hugging Face

And done! You have now successfully deployed the Flowise application as a Hugging Face Space.

From the Dockerfile above, it is clear that the Flowise application is running from a Docker container, which means that there won’t be any configuration incompatibility with your local machine specifications.

Now you can start building LLM applications with ease and deploying them as well.

To help you get started building LLM apps with Flowise, you may check out these posts:

Langflow & Flowise Step by Step Tutorial (ai-jason.com)

Flowise Is A Graphical User Interface (GUI) for 🦜🔗LangChain | by Cobus Greyling | Medium

🦜🔗Langchain without code -> Flowise — DEV Community

I hope you enjoyed reading this post! Leave a 👏if you did.

Follow me on Medium: Ifeanyi Idiaye

Follow me on X (formerly Twitter): @Ifeanyidiaye

You can read my other posts on Medium too:

Easily Convert PDF File to Word Using {Convert2Docx} R Package | by Ifeanyi Idiaye | Medium

How to Connect Local Folder on Your Computer to A GitHub Repository | by Ifeanyi Idiaye | Medium

How to Use Gephi to Analyze Social Network Data for Beginners | by Ifeanyi Idiaye | Aug, 2023 | Medium

How to Deploy an R Shiny App as a Hugging Face Space | by Ifeanyi Idiaye | Medium

--

--

Ifeanyi Idiaye

I am a data scientist, who is passionate about AI and building AI-driven applications. I am also a data analytics developer and writer for Dev Genius.