diff --git a/app/main.py b/app/main.py index 3c288e9..d1435af 100644 --- a/app/main.py +++ b/app/main.py @@ -1970,6 +1970,29 @@ async def list_models(request: Request): if kb_entry not in model["info"]["meta"]["knowledge"]: model["info"]["meta"]["knowledge"].append(kb_entry) + # Steering: with knowledge attached, the model gets a + # query_knowledge_files tool and tends to call it on every + # prompt — including questions unrelated to the co-op — which + # adds an embedding call + vector search (latency) before + # answering. params.system is merged ahead of any system + # content by Open WebUI's middleware, so a short instruction + # here keeps the tool for co-op questions without suppressing + # it entirely. + model.setdefault("params", {}) + steering = ( + "The attached knowledge contains the Inference Cooperative's " + "own documentation (membership, models, API, governance). " + "Query it only when the user's question actually concerns " + "the co-op, its services, or its governance — for general " + "questions, just answer directly." + ) + existing = model["params"].get("system") + if existing: + if "Inference Cooperative's" not in existing: + model["params"]["system"] = existing + "\n\n" + steering + else: + model["params"]["system"] = steering + return JSONResponse(content=payload)