Tools update

This commit is contained in:
2025-09-08 17:55:00 +02:00
parent 8719f0084d
commit 8df91ccac5

View File

@@ -191,6 +191,40 @@ PY
printf '%s' "${__id:-}"
}
# --- OWUI file helpers -------------------------------------------------------
_owui_file_get() {
# usage: _owui_file_get <file_id>
local fid="$1"
curl -sS -H "Authorization: Bearer $OPENWEBUI_API_KEY" \
"$(_owui_url)/api/v1/files/$fid"
}
_owui_wait_file() {
# usage: _owui_wait_file <file_id> [timeout_secs]
local fid="$1"
local timeout="${2:-120}" # default 2 minutes
local start now status content_len
start="$(date +%s)"
while :; do
now="$(date +%s)"
if [ $((now - start)) -ge "$timeout" ]; then
return 1
fi
# Fetch status and content length
read -r status content_len <<EOF
$(_owui_file_get "$fid" \
| python3 -c 'import sys, json
d=json.load(sys.stdin)
s=((d.get("data") or {}).get("status") or "")
c=len(((d.get("data") or {}).get("content") or ""))
print(s, c)')
EOF
[ "$status" = "completed" ] && [ "${content_len:-0}" -gt 0 ] && return 0
sleep 2
done
}
_help() {
cat <<EOF
podx-tools — Meili & OpenWebUI helpers