[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
+14 -4
View File
@@ -1617,13 +1617,23 @@ async def v1_rerank_request(request: V1RerankReqInput, raw_request: Request):
##### Ollama-compatible API endpoints ##### ##### 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.get(_ollama_root_route)
@app.head(os.environ.get("SGLANG_OLLAMA_ROOT_ROUTE", "/")) @app.head(_ollama_root_route)
async def ollama_root(): async def ollama_root():
"""Ollama-compatible root endpoint for health check.""" """Ollama-compatible root endpoint."""
return "Ollama is running" 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")) @app.post(os.environ.get("SGLANG_OLLAMA_CHAT_ROUTE", "/api/chat"))
async def ollama_chat(request: OllamaChatRequest, raw_request: Request): async def ollama_chat(request: OllamaChatRequest, raw_request: Request):