diff --git a/litellm/proxy/_experimental/out/onboarding.html b/litellm/proxy/_experimental/out/onboarding.html deleted file mode 100644 index 72ef6ec5edc..00000000000 --- a/litellm/proxy/_experimental/out/onboarding.html +++ /dev/null @@ -1 +0,0 @@ -LiteLLM Dashboard \ No newline at end of file diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 7dae5c16b58..95fe0601251 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -740,7 +740,7 @@ origins = ["*"] try: current_dir = os.path.dirname(os.path.abspath(__file__)) ui_path = os.path.join(current_dir, "_experimental", "out") - app.mount("/ui", StaticFiles(directory=ui_path, html=True), name="ui") + router.mount("/ui", StaticFiles(directory=ui_path, html=True), name="ui") # Iterate through files in the UI directory for filename in os.listdir(ui_path): if filename.endswith(".html") and filename != "index.html": @@ -787,20 +787,20 @@ app.add_middleware( app.add_middleware(PrometheusAuthMiddleware) swagger_path = os.path.join(current_dir, "swagger") -app.mount("/swagger", StaticFiles(directory=swagger_path), name="swagger") +router.mount("/swagger", StaticFiles(directory=swagger_path), name="swagger") -def swagger_monkey_patch(*args, **kwargs): - return get_swagger_ui_html( - *args, - **kwargs, - swagger_js_url="/swagger/swagger-ui-bundle.js", - swagger_css_url="/swagger/swagger-ui.css", - swagger_favicon_url="/swagger/favicon.png", - ) +# def swagger_monkey_patch(*args, **kwargs): +# return get_swagger_ui_html( +# *args, +# **kwargs, +# swagger_js_url="/swagger/swagger-ui-bundle.js", +# swagger_css_url="/swagger/swagger-ui.css", +# swagger_favicon_url="/swagger/favicon.png", +# ) -applications.get_swagger_ui_html = swagger_monkey_patch +# applications.get_swagger_ui_html = swagger_monkey_patch from typing import Dict diff --git a/tests/test_litellm/proxy/test_custom_proxy.py b/tests/test_litellm/proxy/test_custom_proxy.py new file mode 100644 index 00000000000..ec17537b4f1 --- /dev/null +++ b/tests/test_litellm/proxy/test_custom_proxy.py @@ -0,0 +1,45 @@ +import os +import sys + +import uvicorn +from fastapi import FastAPI, Request +from fastapi.middleware.cors import CORSMiddleware +from fastapi.responses import JSONResponse + +sys.path.insert( + 0, os.path.abspath("../../..") +) # Adds the parent directory to the system path + +from litellm.proxy.proxy_server import app as litellm_app + +# Create main FastAPI app +app = FastAPI(title="Custom LiteLLM Server") + +# Add CORS middleware +app.add_middleware( + CORSMiddleware, + allow_origins=["*"], + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) + +# Mount LiteLLM app at /litellm +app.mount("/litellm", litellm_app) + + +# Default route at / +@app.get("/") +async def root(): + return {"message": "Welcome to the API Gateway", "litellm_endpoint": "/litellm"} + + +# Health check endpoint +@app.get("/health") +async def health_check(): + return {"status": "healthy"} + + +if __name__ == "__main__": + # Run the server on port 8000 + uvicorn.run(app, host="0.0.0.0", port=8000, log_level="info")