set PROXY_BASE_URL when server root path set

This commit is contained in:
Ishaan Jaff 2024-08-05 15:48:44 -07:00
parent 81c2c919e1
commit e6f4d7a81d

View file

@ -281,9 +281,12 @@ except Exception as e:
except Exception as e: except Exception as e:
pass pass
server_root_path = os.getenv("SERVER_ROOT_PATH", "")
if server_root_path != "" and os.getenv("PROXY_BASE_URL") is None:
os.environ["PROXY_BASE_URL"] = server_root_path
_license_check = LicenseCheck() _license_check = LicenseCheck()
premium_user: bool = _license_check.is_premium() premium_user: bool = _license_check.is_premium()
ui_link = f"/ui/" ui_link = f"{server_root_path}/ui/"
ui_message = ( ui_message = (
f"👉 [```LiteLLM Admin Panel on /ui```]({ui_link}). Create, Edit Keys with SSO" f"👉 [```LiteLLM Admin Panel on /ui```]({ui_link}). Create, Edit Keys with SSO"
) )
@ -303,14 +306,13 @@ _description = (
else f"Proxy Server to call 100+ LLMs in the OpenAI format. {custom_swagger_message}\n\n{ui_message}" else f"Proxy Server to call 100+ LLMs in the OpenAI format. {custom_swagger_message}\n\n{ui_message}"
) )
app = FastAPI( app = FastAPI(
docs_url=_docs_url, docs_url=_docs_url,
title=_title, title=_title,
description=_description, description=_description,
version=version, version=version,
root_path=os.environ.get( root_path=server_root_path, # check if user passed root path, FastAPI defaults this value to ""
"SERVER_ROOT_PATH", ""
), # check if user passed root path, FastAPI defaults this value to ""
) )