Error fix
This commit is contained in:
@@ -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"
|
||||
|
Reference in New Issue
Block a user