Attach co-op docs knowledge collection to every model (auto-RAG, no KB browsing wandering)

This commit is contained in:
Inferencebot committed 2026-10-07 10:52:08 -06:00
1 parent e18cd4b703
commit 1a227642d9
1 file changed
+20
+20
View File
@@ -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)