Error fix

This commit is contained in:
2025-09-08 11:04:36 +02:00
parent 9b86b0886e
commit 6a1d30e073

View File

@@ -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 $? # write response body to tmp_body; write HTTP code to tmp_code; capture exit code from $?
curl -sS -H "Authorization: Bearer $OPENWEBUI_API_KEY" \ curl -sS -H "Authorization: Bearer $OPENWEBUI_API_KEY" \
-F "file=@$file" \ -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=$? curl_exit=$?
http_code="$(cat "$tmp_code" 2>/dev/null || echo 0)" 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)" tmp_body="$(_mktemp)"; tmp_code="$(_mktemp)"
curl -sS -H "Authorization: Bearer $OPENWEBUI_API_KEY" \ curl -sS -H "Authorization: Bearer $OPENWEBUI_API_KEY" \
-F "file=@$file" \ -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)" curl_exit=$?; http_code="$(cat "$tmp_code" 2>/dev/null || echo 0)"
FILE_JSON="$(cat "$tmp_body")" FILE_JSON="$(cat "$tmp_body")"
rm -f "$tmp_body" "$tmp_code" rm -f "$tmp_body" "$tmp_code"
@@ -308,12 +308,13 @@ print(f\"Indexed {n} document(s).\")"
# 2) Attach # 2) Attach
KB_ID="$(_kb_id_by_name "$kb_name")" 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 if [ -z "$KB_ID" ]; then echo "KB '$kb_name' not found"; exit 1; fi
tmp_body="$(_mktemp)"; tmp_code="$(_mktemp)" 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\"}" \ -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)" curl_exit=$?; http_code="$(cat "$tmp_code" 2>/dev/null || echo 0)"
RESP="$(cat "$tmp_body")" RESP="$(cat "$tmp_body")"
rm -f "$tmp_body" "$tmp_code" rm -f "$tmp_body" "$tmp_code"
@@ -358,7 +359,7 @@ print(f\"Indexed {n} document(s).\")"
tmp_body="$(_mktemp)"; tmp_code="$(_mktemp)" tmp_body="$(_mktemp)"; tmp_code="$(_mktemp)"
curl -sS -H "Authorization: Bearer $OPENWEBUI_API_KEY" \ curl -sS -H "Authorization: Bearer $OPENWEBUI_API_KEY" \
-F "file=@$f" \ -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)" curl_up_exit=$?; code_up="$(cat "$tmp_code" 2>/dev/null || echo 0)"
FILE_JSON="$(cat "$tmp_body")" FILE_JSON="$(cat "$tmp_body")"
rm -f "$tmp_body" "$tmp_code" 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 if [ -z "$FILE_ID" ]; then echo " upload failed (no id), skipping"; echo "$FILE_JSON" | ppjson; continue; fi
tmp_body="$(_mktemp)"; tmp_code="$(_mktemp)" 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\"}" \ -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)" curl_att_exit=$?; code_att="$(cat "$tmp_code" 2>/dev/null || echo 0)"
RESP="$(cat "$tmp_body")" RESP="$(cat "$tmp_body")"
rm -f "$tmp_body" "$tmp_code" rm -f "$tmp_body" "$tmp_code"