Temp User commited on
Commit
22c6426
·
0 Parent(s):

Initial setup for Open WebUI on Hugging Face Space

Browse files
Files changed (5) hide show
  1. .env +5 -0
  2. Dockerfile +43 -0
  3. README.md +39 -0
  4. app.py +16 -0
  5. start.sh +10 -0
.env ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ PORT=7860
2
+ HOST=0.0.0.0
3
+ WEBUI_AUTH=false
4
+ ENABLE_OLLAMA_API=false
5
+ ENABLE_OPENAI_API=true
Dockerfile ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ WORKDIR /app
4
+
5
+ # Install dependencies
6
+ RUN apt-get update && apt-get install -y \
7
+ git \
8
+ curl \
9
+ build-essential \
10
+ nodejs \
11
+ npm \
12
+ && rm -rf /var/lib/apt/lists/*
13
+
14
+ # Clone Open WebUI
15
+ RUN git clone https://github.com/open-webui/open-webui.git .
16
+
17
+ # Install requirements
18
+ WORKDIR /app/backend
19
+ RUN pip install --no-cache-dir -r requirements.txt
20
+ RUN pip install --no-cache-dir python-dotenv
21
+
22
+ # Set up frontend
23
+ WORKDIR /app
24
+ RUN npm install
25
+ RUN npm run build
26
+
27
+ # Set environment variables
28
+ ENV ENV=prod
29
+ ENV PORT=7860
30
+ ENV HOST=0.0.0.0
31
+ # HF token will be set via Hugging Face Spaces secrets
32
+ ENV WEBUI_AUTH=false
33
+
34
+ # Create start script
35
+ WORKDIR /app/backend
36
+ COPY start.sh /app/backend/
37
+ RUN chmod +x /app/backend/start.sh
38
+
39
+ # Expose port
40
+ EXPOSE 7860
41
+
42
+ # Start the application
43
+ CMD ["/app/backend/start.sh"]
README.md ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Open WebUI
3
+ colorFrom: blue
4
+ colorTo: green
5
+ sdk: docker
6
+ app_port: 7860
7
+ ---
8
+
9
+ # Open WebUI on Hugging Face Space
10
+
11
+ This is a deployment of [Open WebUI](https://github.com/open-webui/open-webui) on Hugging Face Space.
12
+
13
+ ## Features
14
+
15
+ - Chat with AI models through a user-friendly interface
16
+ - Integrated with Hugging Face models using your API token
17
+ - Customizable UI and settings
18
+ - File uploads and multi-modal capabilities
19
+ - Responsive design for desktop and mobile use
20
+
21
+ ## Configuration
22
+
23
+ This deployment uses Hugging Face Space secrets to securely store your API token. The token is accessed by Open WebUI to connect to Hugging Face models.
24
+
25
+ ## How to Use
26
+
27
+ 1. Set up your Hugging Face API token as a secret named `HUGGINGFACE_API_KEY` in this Space
28
+ 2. Wait for the Space to build and deploy
29
+ 3. Visit the Space URL
30
+ 4. Configure your preferred models in the settings
31
+ 5. Start chatting with AI models!
32
+
33
+ ## Custom Models
34
+
35
+ You can add custom models in the settings page by providing the model ID and your Hugging Face API token is already configured.
36
+
37
+ ---
38
+
39
+ Powered by Open WebUI
app.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Open WebUI Hugging Face Space configuration
3
+ """
4
+ import os
5
+ import subprocess
6
+ import sys
7
+
8
+ # Check if we're running in a Hugging Face Space
9
+ if "SPACE_ID" in os.environ:
10
+ print("Running in Hugging Face Space")
11
+
12
+ # Start the Open WebUI server
13
+ subprocess.run(["uvicorn", "open_webui.main:app", "--host", "0.0.0.0", "--port", "7860", "--forwarded-allow-ips", "*"])
14
+ else:
15
+ print("Not running in Hugging Face Space. Please use the Dockerfile to build and run the application.")
16
+ sys.exit(1)
start.sh ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ cd /app/backend
5
+
6
+ # Initialize database and migrations
7
+ python -m open_webui.env
8
+
9
+ # Start the application
10
+ uvicorn open_webui.main:app --host 0.0.0.0 --port 7860 --forwarded-allow-ips '*'