From 5490eeb2fce454780c6f24d2005ff2d900c8d4a2 Mon Sep 17 00:00:00 2001 From: inference-bot Date: Sun, 6 Sep 2026 22:27:06 -0600 Subject: [PATCH] Annotate /v1/models with OpenWebUI web_search capability (default-on) --- app/main.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/app/main.py b/app/main.py index 1ccb23c..0dcf71d 100644 --- a/app/main.py +++ b/app/main.py @@ -489,17 +489,33 @@ async def opencollective_webhook(request: Request, token: str): @app.get("/v1/models") async def list_models(): - """List models (same for everyone — no per-user auth needed).""" + """List models (same for everyone — no per-user auth needed). + + Annotates each model with OpenWebUI metadata so web search is enabled by + default (defaultFeatureIds includes 'web_search'). Without this, OpenWebUI + leaves web search off for these models and members must toggle it manually. + """ async with httpx.AsyncClient() as client: r = await client.get( f"{LITELLM_BASE}/v1/models", headers={"Authorization": f"Bearer {LITELLM_MASTER_KEY}"}, ) - return Response( - content=r.content, - status_code=r.status_code, - headers={"content-type": r.headers.get("content-type", "application/json")}, - ) + if r.status_code != 200: + return Response( + content=r.content, + status_code=r.status_code, + headers={"content-type": r.headers.get("content-type", "application/json")}, + ) + + payload = r.json() + for model in payload.get("data", []): + model.setdefault("info", {}).setdefault("meta", {}) + model["info"]["meta"].setdefault("capabilities", {})["web_search"] = True + model["info"]["meta"].setdefault("defaultFeatureIds", []) + if "web_search" not in model["info"]["meta"]["defaultFeatureIds"]: + model["info"]["meta"]["defaultFeatureIds"].append("web_search") + + return JSONResponse(content=payload) @app.api_route("/v1/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH"])