Merge pull request #4142 from BerriAI/litellm_ui_on_server_root_url

[FIX] allow setting UI BASE path
This commit is contained in:
Ishaan Jaff 2024-08-05 11:17:55 -07:00 committed by GitHub
commit e978c6b056
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 62 additions and 50 deletions

View file

@ -7,18 +7,17 @@
echo echo
pwd pwd
# if UI_BASE_PATH env is set
if [ -z "$UI_BASE_PATH" ]; then
# only run this step for litellm enterprise, we run this if enterprise/enterprise_ui/_enterprise.json exists
if [ ! -f "enterprise/enterprise_ui/enterprise_colors.json" ]; then
echo "Admin UI - using default LiteLLM UI"
exit 0
fi
echo "Building Custom Admin UI..." # only run this step for litellm enterprise, we run this if enterprise/enterprise_ui/_enterprise.json exists or env var UI_BASE_PATH is set
if [ -f "enterprise/enterprise_ui/enterprise_colors.json" ] || [ -n "${UI_BASE_PATH:-}" ]; then
echo "Building Admin UI..."
# Install dependencies # Install dependencies
# Check if we are on macOS # Check if we are on macOS
if [[ "$(uname)" == "Darwin" ]]; then if [[ "$(uname)" == "Darwin" ]]; then
# Install dependencies using Homebrew # Install dependencies using Homebrew
if ! command -v brew &> /dev/null; then if ! command -v brew &> /dev/null; then
echo "Error: Homebrew not found. Please install Homebrew and try again." echo "Error: Homebrew not found. Please install Homebrew and try again."
@ -26,7 +25,7 @@ if [[ "$(uname)" == "Darwin" ]]; then
fi fi
brew update brew update
brew install curl brew install curl
else else
# Assume Linux, try using apt-get # Assume Linux, try using apt-get
if command -v apt-get &> /dev/null; then if command -v apt-get &> /dev/null; then
apt-get update apt-get update
@ -39,24 +38,37 @@ else
echo "Error: Unsupported package manager. Cannot install dependencies." echo "Error: Unsupported package manager. Cannot install dependencies."
exit 1 exit 1
fi fi
fi
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
source ~/.nvm/nvm.sh
nvm install v18.17.0
nvm use v18.17.0
npm install -g npm
if [ -n "${UI_BASE_PATH:-}" ]; then
echo "Using UI_BASE_PATH: $UI_BASE_PATH"
# make a file call .env in ui/litellm-dashboard and store the UI_BASE_PATH in it
echo "UI_BASE_PATH=$UI_BASE_PATH" > ui/litellm-dashboard/.env
fi
# copy _enterprise.json from this directory to /ui/litellm-dashboard, and rename it to ui_colors.json
cp enterprise/enterprise_ui/enterprise_colors.json ui/litellm-dashboard/ui_colors.json
# cd in to /ui/litellm-dashboard
cd ui/litellm-dashboard
# ensure have access to build_ui.sh
chmod +x ./build_ui.sh
# run ./build_ui.sh
./build_ui.sh
# return to root directory
cd ../..
else
echo "Admin UI - using default LiteLLM UI"
exit 0
fi fi
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
source ~/.nvm/nvm.sh
nvm install v18.17.0
nvm use v18.17.0
npm install -g npm
# copy _enterprise.json from this directory to /ui/litellm-dashboard, and rename it to ui_colors.json
cp enterprise/enterprise_ui/enterprise_colors.json ui/litellm-dashboard/ui_colors.json
# cd in to /ui/litellm-dashboard
cd ui/litellm-dashboard
# ensure have access to build_ui.sh
chmod +x ./build_ui.sh
# run ./build_ui.sh
./build_ui.sh
# return to root directory
cd ../..

View file

@ -1,7 +1,7 @@
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
const nextConfig = { const nextConfig = {
output: 'export', output: 'export',
basePath: '/ui', basePath: process.env.UI_BASE_PATH || '/ui',
}; };
nextConfig.experimental = { nextConfig.experimental = {