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"])