owui-cli 0.2.0__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: owui-cli
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Admin CLI for Open WebUI instances
5
5
  Project-URL: Homepage, https://github.com/rndmcnlly/owui-cli
6
6
  Project-URL: Repository, https://github.com/rndmcnlly/owui-cli
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "owui-cli"
3
- version = "0.2.0"
3
+ version = "0.3.0"
4
4
  description = "Admin CLI for Open WebUI instances"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -0,0 +1 @@
1
+ __version__ = "0.3.0"
@@ -505,6 +505,7 @@ def models_show(url, token, model_id):
505
505
  ("base", info.get("base_model_id","(none)")),
506
506
  ("active", str(info.get("is_active","?"))),
507
507
  ("tools", ", ".join(meta.get("toolIds") or []) or "(none)"),
508
+ ("filters", ", ".join(params.get("filter_ids") or []) or "(none)"),
508
509
  ("knowledge", ", ".join(k.get("name","?") for k in (meta.get("knowledge") or [])) or "(none)"),
509
510
  ("system", f"{len(params.get('system',''))} chars"),
510
511
  ("grants", str(len(info.get("access_grants") or [])))]
@@ -530,6 +531,40 @@ def models_delete(url, token, model_id):
530
531
  _post(c, url, "/api/v1/models/model/delete", token, {"id": model_id})
531
532
  out(f"deleted {model_id}")
532
533
 
534
+ def _models_fetch(c, url, token, model_id):
535
+ """Fetch a model by ID, returning the parsed JSON."""
536
+ r = _get(c, url, f"/api/v1/models/model?id={model_id}", token)
537
+ return r.json()
538
+
539
+ def models_set_tools(url, token, model_id, *tool_ids):
540
+ """Set the tool bindings for a workspace model (pass no IDs to clear)."""
541
+ with httpx.Client(timeout=TIMEOUT) as c:
542
+ model = _models_fetch(c, url, token, model_id)
543
+ info = model.get("info") or {}
544
+ meta = info.setdefault("meta", {})
545
+ params = info.setdefault("params", {})
546
+ ids = list(tool_ids)
547
+ meta["toolIds"] = ids
548
+ # keep params.tool_ids in sync (used by some OWUI versions)
549
+ params["tool_ids"] = ids
550
+ model["info"] = info
551
+ r = _post(c, url, "/api/v1/models/model/update", token, model)
552
+ label = ", ".join(ids) if ids else "(none)"
553
+ out(f"tools for {model_id}: {label}")
554
+
555
+ def models_set_filters(url, token, model_id, *filter_ids):
556
+ """Set the filter bindings for a workspace model (pass no IDs to clear)."""
557
+ with httpx.Client(timeout=TIMEOUT) as c:
558
+ model = _models_fetch(c, url, token, model_id)
559
+ info = model.get("info") or {}
560
+ params = info.setdefault("params", {})
561
+ ids = list(filter_ids)
562
+ params["filter_ids"] = ids
563
+ model["info"] = info
564
+ r = _post(c, url, "/api/v1/models/model/update", token, model)
565
+ label = ", ".join(ids) if ids else "(none)"
566
+ out(f"filters for {model_id}: {label}")
567
+
533
568
 
534
569
  def models_pull_all(url, token, out_dir="."):
535
570
  """Pull all workspace models into <out_dir>/<id>/model.json, extracting profile images."""
@@ -1007,6 +1042,8 @@ COMMANDS.update({
1007
1042
  ("models", "create"): (models_create, "<model.json>", (1, 1)),
1008
1043
  ("models", "update"): (models_update, "<model.json>", (1, 1)),
1009
1044
  ("models", "delete"): (models_delete, "<id>", (1, 1)),
1045
+ ("models", "set-tools"): (models_set_tools, "<id> [tool-id]...", (1, 999)),
1046
+ ("models", "set-filters"): (models_set_filters, "<id> [filter-id]...", (1, 999)),
1010
1047
  ("models", "pull-all"): (models_pull_all, "[dir]", (0, 1)),
1011
1048
  ("knowledge", "list"): (knowledge_list, "", (0, 0)),
1012
1049
  ("knowledge", "show"): (knowledge_show, "<id>", (1, 1)),
@@ -1 +0,0 @@
1
- __version__ = "0.2.0"
File without changes
File without changes
File without changes
File without changes