Hello, is it possible to use Vectorize with Cloudflare Pages?
Hello, is it possible to use Vectorize with Cloudflare Pages?

upsert or insert method to work for me via the REST API or the cloudflare npm package but keep getting errors: [ { code: 1005, message: 'vectorize.unknown_content_type' } ] https://api.cloudflare.com/client/v4/accounts/${ACCOUNT_IDENTIFIER}/vectorize/indexes/${indexName}/query;wrangler.toml with:{
"message": [
"Response from Index =>",
"{\"count\":0,\"ids\":[]}"
],
"level": "log",
"timestamp": 1711117766889
},upsertinsertcloudflare errors: [ { code: 1005, message: 'vectorize.unknown_content_type' } ] https://api.cloudflare.com/client/v4/accounts/${ACCOUNT_IDENTIFIER}/vectorize/indexes/${indexName}/query{
"result": null,
"success": false,
"errors": [
{
"code": 4000,
"message": "vectorize.vector.missing_part"
}
],
"messages": []
}const blob = new Blob([JSON.stringify({ id, values }) + '\n'], { type: 'application/x-ndjson' });
console.log('blob :', blob);
const formData = new FormData();
formData.append('file', blob, 'data.ndjson');
const response = await fetch(`${c.env.CLOUDFLARE_API_URL}/accounts/${c.env.CLOUDFLARE_ACCOUNT_ID}/vectorize/indexes/${vectorize}/insert`, {
method: 'POST',
headers: {
Authorization: `Bearer ${c.env.CLOUDFLARE_API_TOKEN}`,
},
body: formData,
});import http.client
conn = http.client.HTTPSConnection("api.cloudflare.com")
headers = {
'Content-Type': "application/json",
'Authorization': f"Bearer {vectorize_token}"
}
conn.request("GET", f"/client/v4/accounts/{account_id}/vectorize/indexes", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))import http.client
conn = http.client.HTTPSConnection("api.cloudflare.com")
payload = "/home/ubuntu/jupy/notebooks/test_vector.ndjson"
headers = {
'Content-Type': "application/x-ndjson",
'Authorization': f"Bearer {vectorize_token}"
}
conn.request("POST", f"client/v4/accounts/{account_id}/vectorize/indexes/hey-hi-index/upsert", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))!ls -lh test_vector.ndjson
-rw-r--r-- 1 ubuntu ubuntu 17K Apr 12 15:49 test_vector.ndjsoncurl --request POST --url https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/vectorize/indexes/hey-hi-index/upsert --header "Authorization: Bearer ${VECTORIZE_API_TOKEN}" --header 'Content-Type: application/x-ndjson' --data test_vector.ndjson
{
"result": null,
"success": false,
"errors": [
{
"message": "unexpected - Internal server error"
}
],
"messages": []
}curl --request POST --url https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/vectorize/indexes/hey-hi-index/upsert --header "Authorization: Bearer ${VECTORIZE_API_TOKEN}" --header 'Content-Type: application/x-ndjson' --data test_vector.ndjson
{
"result": null,
"success": false,
"errors": [
{
"message": "unexpected - Internal server error"
}
],
"messages": []
}[0.032991889864206314, 0.0012868141056969762, ,,,][0.032991889864206314, 0.0012868141056969762, ,,,]import requests
from requests_toolbelt import MultipartEncoder
def upsert(url, file_name, content_type, authorization_token):
"""Sends a POST request.
:param url: URL for the new :class:`Request` object.
:param file_name: File to be sent/attached in the body of the request.
:content_type: File content type
:authorization_token: Cloudflare authorization token
:return: :class:`Response <Response>` object.
"""
payload = MultipartEncoder(
fields = {'field1': ('filename', open(file_name, 'rb'), content_type)}
)
headers = {
'Content-Type': payload.content_type,
'Authorization': f"Bearer {authorization_token}"
}
return requests.post(url, data = payload, headers = headers)
upsert(
f"https://api.cloudflare.com/client/v4/accounts/{account_id}/vectorize/indexes/hey-hi-index/upsert",
"test_vector.ndjson",
"application/x-ndjson",
vectorize_token
)
<Response [400]>$ npx wrangler vectorize insert hey-hi-index --file test_vector.ndjson
✨ Uploading vector batch (1 vectors)
✘ [ERROR] A request to the Cloudflare API (/accounts/account_id/vectorize/indexes/hey-hi-index/insert) failed.
vectorize.invalid_body_payload [code: 1006][[vectorize]]
binding = "VECTOR_INDEX"
index_name = "vector-index"