owui-cli 0.5.1__tar.gz → 0.5.2__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
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: owui-cli
3
- Version: 0.5.1
3
+ Version: 0.5.2
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.5.1"
3
+ version = "0.5.2"
4
4
  description = "Admin CLI for Open WebUI instances"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -0,0 +1 @@
1
+ __version__ = "0.5.2"
@@ -602,20 +602,56 @@ def models_show(url, token, model_id):
602
602
  ("grants", str(len(m.get("access_grants") or [])))]
603
603
  out_kv(pairs)
604
604
 
605
+ _MIME_BY_EXT = {
606
+ "png": "image/png",
607
+ "jpg": "image/jpeg",
608
+ "jpeg": "image/jpeg",
609
+ "gif": "image/gif",
610
+ "webp": "image/webp",
611
+ }
612
+
613
+
614
+ def _inline_sibling_images(json_path: str, payload: dict) -> list[str]:
615
+ """Replace bare sibling-image references in meta.profile_image_url with data URIs.
616
+
617
+ The repo convention stores the icon as a sibling file referenced by bare
618
+ filename (e.g. "profile.png"). OWUI's stored-model validator (utils/validate.py)
619
+ rejects bare filenames and silently clears them to null, so push must inline
620
+ the sibling image instead — the mirror of models_pull_all's extraction.
621
+ Returns the list of inlined filenames.
622
+ """
623
+ inlined = []
624
+ meta = payload.get("meta") if isinstance(payload, dict) else None
625
+ ref = (meta or {}).get("profile_image_url")
626
+ if not isinstance(ref, str) or not ref or ref.startswith(("data:", "http://", "https://", "/")):
627
+ return inlined
628
+ image_path = os.path.join(os.path.dirname(os.path.abspath(json_path)), ref)
629
+ ext = os.path.splitext(ref)[1].lstrip(".").lower()
630
+ mime = _MIME_BY_EXT.get(ext)
631
+ if mime and os.path.isfile(image_path):
632
+ with open(image_path, "rb") as f:
633
+ b64 = base64.b64encode(f.read()).decode()
634
+ payload["meta"]["profile_image_url"] = f"data:{mime};base64,{b64}"
635
+ inlined.append(ref)
636
+ return inlined
637
+
638
+
605
639
  def models_create(url, token, json_path):
606
640
  with open(json_path) as f:
607
641
  payload = json.load(f)
642
+ inlined = _inline_sibling_images(json_path, payload)
608
643
  with httpx.Client(timeout=TIMEOUT) as c:
609
644
  r = _post(c, url, "/api/v1/models/create", token, payload)
610
645
  m = r.json()
611
- out(f"created {m.get('id')}")
646
+ out(f"created {m.get('id')}" + (f" (inlined {', '.join(inlined)})" if inlined else ""))
612
647
 
613
648
  def models_update(url, token, json_path):
614
649
  with open(json_path) as f:
615
650
  payload = json.load(f)
651
+ inlined = _inline_sibling_images(json_path, payload)
616
652
  with httpx.Client(timeout=TIMEOUT) as c:
617
653
  r = _post(c, url, "/api/v1/models/model/update", token, payload)
618
- out(f"updated {r.json().get('id')}")
654
+ out(f"updated {r.json().get('id')}" + (f" (inlined {', '.join(inlined)})" if inlined else ""))
619
655
 
620
656
  def models_delete(url, token, model_id):
621
657
  with httpx.Client(timeout=TIMEOUT) as c:
@@ -72,7 +72,7 @@ wheels = [
72
72
 
73
73
  [[package]]
74
74
  name = "owui-cli"
75
- version = "0.2.0"
75
+ version = "0.5.2"
76
76
  source = { editable = "." }
77
77
  dependencies = [
78
78
  { name = "httpx" },
@@ -1 +0,0 @@
1
- __version__ = "0.5.1"
File without changes
File without changes
File without changes
File without changes
File without changes