[HTTP] Fix /GET HTTP route when ollama endpoint is not set. (#20494)

This commit is contained in:
Liangsheng Yin
2026-03-12 20:54:32 -07:00
committed by GitHub
parent 154af9e46c
commit f605612b87

View File

@@ -1617,12 +1617,22 @@ async def v1_rerank_request(request: V1RerankReqInput, raw_request: Request):
##### Ollama-compatible API endpoints #####
_ollama_root_route = os.environ.get("SGLANG_OLLAMA_ROOT_ROUTE")
if _ollama_root_route is not None:
@app.get(os.environ.get("SGLANG_OLLAMA_ROOT_ROUTE", "/"))
@app.head(os.environ.get("SGLANG_OLLAMA_ROOT_ROUTE", "/"))
async def ollama_root():
"""Ollama-compatible root endpoint for health check."""
return "Ollama is running"
@app.get(_ollama_root_route)
@app.head(_ollama_root_route)
async def ollama_root():
"""Ollama-compatible root endpoint."""
return "Ollama is running"
else:
@app.get("/")
@app.head("/")
async def sglang_root():
"""Default root endpoint."""
return "SGLang is running"
@app.post(os.environ.get("SGLANG_OLLAMA_CHAT_ROUTE", "/api/chat"))