Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Include any files or directories that you don't want to be copied to your
# container here (e.g., local build artifacts, temporary files, etc.).
#
# For more help, visit the .dockerignore file reference guide at
# https://docs.docker.com/go/build-context-dockerignore/

**/.DS_Store
**/__pycache__
**/.venv
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/bin
**/charts
**/docker-compose*
**/compose.y*ml
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ARG PYTHON_VERSION=3.10.14
FROM python:${PYTHON_VERSION}-slim as base
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /app
ARG UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
appuser
RUN --mount=type=cache,target=/root/.cache/pip \
--mount=type=bind,source=requirements.txt,target=requirements.txt \
python -m pip install -r requirements.txt
USER appuser
COPY . .
EXPOSE 5001
CMD gunicorn 'main:app' --bind=0.0.0.0:5001 --timeout 30000
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
openwebui-proxy:
build:
context: .
ports:
- 5001:5001
environment:
- OPENWEBUI_BASE_URL=host.docker.internal:5000
7 changes: 4 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from flask import Flask, request, jsonify
import requests
import os

app = Flask(__name__)

# Configuration for OpenWebUI
OPENWEBUI_BASE_URL = "YOUR_OPENWEBUI_URL"
OPENWEBUI_BASE_URL = os.getenv("OPENWEBUI_BASE_URL", "host.docker.internal:5000")

@app.route('/v1/models', methods=['GET'])
def get_models():
Expand All @@ -16,7 +17,7 @@ def get_models():
}

try:
response = requests.get(f"{OPENWEBUI_BASE_URL}/api/models", headers=headers, timeout=30)
response = requests.get(f"{OPENWEBUI_BASE_URL}/api/models", headers=headers, timeout=1200)

if response.status_code == 200:
return jsonify(response.json())
Expand Down Expand Up @@ -44,7 +45,7 @@ def chat_completions():
}

try:
response = requests.post(f"{OPENWEBUI_BASE_URL}/api/chat/completions", headers=headers, json=openwebui_payload, timeout=120) # Increased to 120 seconds
response = requests.post(f"{OPENWEBUI_BASE_URL}/api/chat/completions", headers=headers, json=openwebui_payload, timeout=1200) # Increased to 120 seconds

if response.status_code == 200:
return jsonify(response.json())
Expand Down