diff --git a/docs/my-website/docs/proxy/ui.md b/docs/my-website/docs/proxy/ui.md index 9dcf992eb..1f98bc077 100644 --- a/docs/my-website/docs/proxy/ui.md +++ b/docs/my-website/docs/proxy/ui.md @@ -187,7 +187,21 @@ We allow you to - Customize the UI color scheme -#### Usage +#### Set Custom Logo +We allow you to pass a local image or a an http/https url of your image + +Set `UI_LOGO_PATH` on your env. We recommend using a hosted image, it's a lot easier to set up and configure / debug + +Exaple setting Hosted image +```shell +UI_LOGO_PATH="https://litellm-logo-aws-marketplace.s3.us-west-2.amazonaws.com/berriai-logo-github.png" +``` + +Exaple setting a local image (on your container) +```shell +UI_LOGO_PATH="ui_images/logo.jpg" +``` +#### Set Custom Color Theme - Navigate to [/enterprise/enterprise_ui](https://github.com/BerriAI/litellm/blob/main/enterprise/enterprise_ui/_enterprise_colors.json) - Inside the `enterprise_ui` directory, rename `_enterprise_colors.json` to `enterprise_colors.json` - Set your companies custom color scheme in `enterprise_colors.json` @@ -206,8 +220,6 @@ Set your colors to any of the following colors: https://www.tremor.so/docs/layou } ``` - -- Set the path to your custom png/jpg logo as `UI_LOGO_PATH` in your .env - Deploy LiteLLM Proxy Server diff --git a/litellm/proxy/cached_logo.jpg b/litellm/proxy/cached_logo.jpg new file mode 100644 index 000000000..ddf8b9e82 Binary files /dev/null and b/litellm/proxy/cached_logo.jpg differ diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 2a2a17f9f..7a1632fcd 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -5211,7 +5211,25 @@ def get_image(): logo_path = os.getenv("UI_LOGO_PATH", default_logo) verbose_proxy_logger.debug(f"Reading logo from {logo_path}") - return FileResponse(path=logo_path) + + # Check if the logo path is an HTTP/HTTPS URL + if logo_path.startswith(("http://", "https://")): + # Download the image and cache it + response = requests.get(logo_path) + if response.status_code == 200: + # Save the image to a local file + cache_path = os.path.join(current_dir, "cached_logo.jpg") + with open(cache_path, "wb") as f: + f.write(response.content) + + # Return the cached image as a FileResponse + return FileResponse(cache_path, media_type="image/jpeg") + else: + # Handle the case when the image cannot be downloaded + return FileResponse(default_logo, media_type="image/jpeg") + else: + # Return the local image file if the logo path is not an HTTP/HTTPS URL + return FileResponse(logo_path, media_type="image/jpeg") @app.get("/sso/callback", tags=["experimental"])