From 6a1d30e0737a9a091c5d7151209ac0a0fcc34490 Mon Sep 17 00:00:00 2001 From: Tomas Kracmar Date: Mon, 8 Sep 2025 11:04:36 +0200 Subject: [PATCH] Error fix --- scripts/podx-tools.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/podx-tools.sh b/scripts/podx-tools.sh index 3f58721..ea377aa 100755 --- a/scripts/podx-tools.sh +++ b/scripts/podx-tools.sh @@ -260,7 +260,7 @@ print(f\"Indexed {n} document(s).\")" # write response body to tmp_body; write HTTP code to tmp_code; capture exit code from $? curl -sS -H "Authorization: Bearer $OPENWEBUI_API_KEY" \ -F "file=@$file" \ - -w "%{http_code}" --output "$tmp_body" "$(_owui_url)/api/v1/files/" >"$tmp_code" + -w "%{http_code}" --output "$tmp_body" "$(_owui_url)/api/v1/files/" >"$tmp_code" || true curl_exit=$? http_code="$(cat "$tmp_code" 2>/dev/null || echo 0)" @@ -290,7 +290,7 @@ print(f\"Indexed {n} document(s).\")" tmp_body="$(_mktemp)"; tmp_code="$(_mktemp)" curl -sS -H "Authorization: Bearer $OPENWEBUI_API_KEY" \ -F "file=@$file" \ - -w "%{http_code}" --output "$tmp_body" "$(_owui_url)/api/v1/files/" >"$tmp_code" + -w "%{http_code}" --output "$tmp_body" "$(_owui_url)/api/v1/files/" >"$tmp_code" || true curl_exit=$?; http_code="$(cat "$tmp_code" 2>/dev/null || echo 0)" FILE_JSON="$(cat "$tmp_body")" rm -f "$tmp_body" "$tmp_code" @@ -308,12 +308,13 @@ print(f\"Indexed {n} document(s).\")" # 2) Attach KB_ID="$(_kb_id_by_name "$kb_name")" + echo "[owui] attaching to KB: $kb_name (id: $KB_ID)" if [ -z "$KB_ID" ]; then echo "KB '$kb_name' not found"; exit 1; fi tmp_body="$(_mktemp)"; tmp_code="$(_mktemp)" - curl -sS -H "Authorization: Bearer $OPENWEBUI_API_KEY" -H "Content-Type: application/json" \ + curl -sS -X POST -H "Authorization: Bearer $OPENWEBUI_API_KEY" -H "Content-Type: application/json" \ -d "{\"file_id\":\"$FILE_ID\"}" \ - -w "%{http_code}" --output "$tmp_body" "$(_owui_url)/api/v1/knowledge/$KB_ID/file/add" >"$tmp_code" + -w "%{http_code}" --output "$tmp_body" "$(_owui_url)/api/v1/knowledge/$KB_ID/file/add" >"$tmp_code" || true curl_exit=$?; http_code="$(cat "$tmp_code" 2>/dev/null || echo 0)" RESP="$(cat "$tmp_body")" rm -f "$tmp_body" "$tmp_code" @@ -358,7 +359,7 @@ print(f\"Indexed {n} document(s).\")" tmp_body="$(_mktemp)"; tmp_code="$(_mktemp)" curl -sS -H "Authorization: Bearer $OPENWEBUI_API_KEY" \ -F "file=@$f" \ - -w "%{http_code}" --output "$tmp_body" "$(_owui_url)/api/v1/files/" >"$tmp_code" + -w "%{http_code}" --output "$tmp_body" "$(_owui_url)/api/v1/files/" >"$tmp_code" || true curl_up_exit=$?; code_up="$(cat "$tmp_code" 2>/dev/null || echo 0)" FILE_JSON="$(cat "$tmp_body")" rm -f "$tmp_body" "$tmp_code" @@ -373,9 +374,9 @@ print(f\"Indexed {n} document(s).\")" if [ -z "$FILE_ID" ]; then echo " upload failed (no id), skipping"; echo "$FILE_JSON" | ppjson; continue; fi tmp_body="$(_mktemp)"; tmp_code="$(_mktemp)" - curl -sS -H "Authorization: Bearer $OPENWEBUI_API_KEY" -H "Content-Type: application/json" \ + curl -sS -X POST -H "Authorization: Bearer $OPENWEBUI_API_KEY" -H "Content-Type: application/json" \ -d "{\"file_id\":\"$FILE_ID\"}" \ - -w "%{http_code}" --output "$tmp_body" "$(_owui_url)/api/v1/knowledge/$KB_ID/file/add" >"$tmp_code" + -w "%{http_code}" --output "$tmp_body" "$(_owui_url)/api/v1/knowledge/$KB_ID/file/add" >"$tmp_code" || true curl_att_exit=$?; code_att="$(cat "$tmp_code" 2>/dev/null || echo 0)" RESP="$(cat "$tmp_body")" rm -f "$tmp_body" "$tmp_code"