mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-10 17:04:47 +00:00
00be76abf4
* fix(proxy_server.py): working swagger on custom base removes the swagger monkey patch - this seems to render the swagger on custom base paths * fix(ui/): working custom auth uptil login success event * fix(ui/): working custom server root path for login * fix(proxy_server.py): create typed dict for ui returned token allows better documentation of expected params * refactor(proxy_server.py): refactor all ui login endpoints to use same returned ui token object * feat(ui_sso.py): add server root path to ui token * feat(ui_sso.py): allows ui to call correct endpoint * fix(networking.tsx): update proxy base url with custom root path * fix(networking.tsx): handle updating proxy base url for non-local instances * refactor: remove uneccessary references to proxybaseurl in ui code - reduce potential for errors * fix: fix linting error * fix(onboarding_link.tsx): fix onboarding link when custom server path is set * feat(ui_discovery_endpoints.py): add new public .well-known/ route for litellm ui config returns the server root path and proxy base url for constructing api calls * feat(_types.py): add litellm well known config as public route allows ui to query it * fix(/_types.py): add .well-known config to as public route * fix(page.tsx): create pattern for loading in ui config before making network requests ensures requests are formatted correctly * fix(page.tsx): call credential endpoint once ui config is loaded * fix(page.tsx): route correctly to litellm dashboard from new user login * fix(page.tsx): remove hardcoded `/litellm` for /sso/key/generate request * fix(proxy_server.py): re-add moderations endpoint * fix(proxy_server.py): mount __next__ at / and /litellm allows it to work when proxy is mounted on root * docs(contributing.md): remove /ui on ui doc - it will now run on root * docs(custom_root_ui.md): add docs on custom root path
49 lines
1.1 KiB
Python
49 lines
1.1 KiB
Python
import os
|
|
import sys
|
|
|
|
import uvicorn
|
|
from dotenv import load_dotenv
|
|
from fastapi import FastAPI, Request
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from fastapi.responses import JSONResponse
|
|
|
|
load_dotenv()
|
|
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
|
|
from litellm.proxy.proxy_server import proxy_startup_event
|
|
|
|
# Create main FastAPI app
|
|
app = FastAPI(title="Custom LiteLLM Server", lifespan=proxy_startup_event)
|
|
|
|
# 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=4000, log_level="info")
|