From 1a227642d954bbf3015297b044af021bd6c4fd80 Mon Sep 17 00:00:00 2001 From: Inferencebot Date: Wed, 7 Oct 2026 10:52:08 -0600 Subject: [PATCH] Attach co-op docs knowledge collection to every model (auto-RAG, no KB browsing wandering) --- app/main.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/main.py b/app/main.py index 6509514..cff8776 100644 --- a/app/main.py +++ b/app/main.py @@ -81,6 +81,12 @@ OWUI_API_KEY = os.environ.get("OWUI_API_KEY", "") OWUI_BASE = os.environ.get("OWUI_BASE", "http://chat:8080") # internal Cloudron network OWUI_MEMBERS_GROUP_ID = os.environ.get("OWUI_MEMBERS_GROUP_ID", "eb348e1a-059a-4a8f-8920-0f73942f6272") +# Open WebUI knowledge collection id for the co-op docs RAG. Attached to every +# model in /v1/models so answers are grounded by automatic RAG injection (and +# the model's knowledge tools are scoped to the docs rather than browsing all +# knowledge bases). Env-driven; empty disables the attachment. +DOCS_KNOWLEDGE_ID = os.environ.get("DOCS_KNOWLEDGE_ID", "946e18ef-c1bc-4c57-b23e-7f5fc5b66e51") + # Shared secret that the member dashboard uses to authenticate broker requests. # The dashboard is Cloudron-SSO-gated and passes the authenticated member's # email; the portal trusts that email only because it carries this secret. Kept @@ -1950,6 +1956,20 @@ async def list_models(request: Request): if "web_search" not in model["info"]["meta"]["defaultFeatureIds"]: model["info"]["meta"]["defaultFeatureIds"].append("web_search") + # Attach the co-op docs knowledge collection to every model. This + # makes Open WebUI treat the docs as the model's own knowledge: + # automatic RAG injection grounds answers without tool-calling, and + # the knowledge toolset is scoped to the attached collection instead + # of exposing browse-all-knowledge tools (the "explored + # search_knowledge_files… view_knowledge_file" wandering that new + # members saw from the getting-started prompt). Env-driven so the + # collection id can be rotated without a code change. + if DOCS_KNOWLEDGE_ID: + model["info"]["meta"].setdefault("knowledge", []) + kb_entry = {"id": DOCS_KNOWLEDGE_ID, "type": "collection"} + if kb_entry not in model["info"]["meta"]["knowledge"]: + model["info"]["meta"]["knowledge"].append(kb_entry) + return JSONResponse(content=payload)