I've been browsing through messages in the past and documentations on vectorize, looks like now it's

I've been browsing through messages in the past and documentations on vectorize, looks like now it's a great time to jump in, considering the beta release of workflow as well. though my concern is full RAG pipeline still needs a long way to go, so I'd prefer develop locally using llamaindex+chromadb(or equivalent)+litellm(embedding, inference, rerank, whisper, etc) first, before switching to cloudflare edge side completely, which I do need at a certain point because the product I am building requires global coverage. may I ask guy who already had previous experiences here, that, is this a viable plan, or anything I should keep in mind for choosing tech stack or develop or doing gitops? thanks a million!
14 Replies
Rubi
Rubi2mo ago
Hi, is Cloudflare Vectorize now support $in metadata filter ?
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
CedricHadjian
CedricHadjian2mo ago
How can I see what vectors I have in my index? I checked the commands I could run, and none mentioned showing the vectors I got in my index. I want to be able to delete and test stuff before I run the actual thing. Any guidance would be appreciated.
Unknown User
Unknown User5w ago
Message Not Public
Sign In & Join Server To View
momegas
momegas4w ago
Hello, Quick question, I get really slow response times in Vectorise. Like seconds of response time. My code is very simple, so nothing else should be slowing it down. I am in Greece btw, so not sure if that plays a role. I get the same speeds when deploying the worker.
}),
async (c) => {
const text = "XXX";
const e = await embedText(c, text);
const r = await c.env.VECTORIZE.query(e, {
topK: 5,
returnValues: false,
returnMetadata: "none",
});

return c.json({ matches: r.matches });
}
);
}),
async (c) => {
const text = "XXX";
const e = await embedText(c, text);
const r = await c.env.VECTORIZE.query(e, {
topK: 5,
returnValues: false,
returnMetadata: "none",
});

return c.json({ matches: r.matches });
}
);
Isaac McFadyen
@Kingsley Michael I removed your message as this is the channel for #vectorize, please use #off-topic for anything unrelated to Cloudflare products
odysseus
odysseus4w ago
The limits page says that there's a maximum of 5,000,000 vectors per index, but I'm getting a 4002 error when attempting to upsert past 240,000. any idea why or things I should change? EDIT: RESOLVED, I was using V1 instead of V2
CedricHadjian
CedricHadjian4w ago
TypeError: vectors.map is not a function What does this mean when it's triggered from this: await vectorIndex.insert({ id: String(data[0][dataId]), values: vectorArray, metadata }); EDIT: I tested it on a small function:
if (request.method === 'GET' && pathname === `/embed`) {
try {
const text = "Liam Marshall"

const response = await env.AI.run("@cf/baai/bge-small-en-v1.5", {
text,
});

await env.TESTVECTORS.insert({
id: 1,
values: response.data[0],
metadata: {
key: "value"
}
})

return new Response(JSON.stringify(response), {
headers: {
'content-type': 'text/plain;charset=UTF-8',
'Access-Control-Allow-Origin': '*',
},
});
} catch (error) {
console.log(error);
}

}
if (request.method === 'GET' && pathname === `/embed`) {
try {
const text = "Liam Marshall"

const response = await env.AI.run("@cf/baai/bge-small-en-v1.5", {
text,
});

await env.TESTVECTORS.insert({
id: 1,
values: response.data[0],
metadata: {
key: "value"
}
})

return new Response(JSON.stringify(response), {
headers: {
'content-type': 'text/plain;charset=UTF-8',
'Access-Control-Allow-Origin': '*',
},
});
} catch (error) {
console.log(error);
}

}
I got the same error: vectors.map is not a function... @yevgen Any help would be appreciated, we're a high tier client and we want to implement vectorize over our app. But we're facing vectors.map is not a function on simple calls as well.
ggu
ggu3w ago
Does this happen just locally or also when deployed?
CedricHadjian
CedricHadjian3w ago
Both This wasn't an issue before, it suddenly became an issue. I also created a fresh new worker and the issue still happened.
garvitg
garvitg3w ago
Hi @CedricHadjian. Thanks for reaching out! I was able to tweak the code you have shared a bit and was able to get it to work. This is a codeblock that works as expected.
try {
const text = 'Liam Marshall';

const ai_response = await env.AI.run('@cf/baai/bge-small-en-v1.5', {
text,
});

const vectorize_response = await env.TESTVECTORS.insert([
{
id: '1',
values: ai_response.data[0],
metadata: {
key: 'value',
},
},
]);

return new Response(JSON.stringify(vectorize_response), {
headers: {
'content-type': 'text/plain;charset=UTF-8',
'Access-Control-Allow-Origin': '*',
},
});
} catch (error) {
console.log(error);
}
try {
const text = 'Liam Marshall';

const ai_response = await env.AI.run('@cf/baai/bge-small-en-v1.5', {
text,
});

const vectorize_response = await env.TESTVECTORS.insert([
{
id: '1',
values: ai_response.data[0],
metadata: {
key: 'value',
},
},
]);

return new Response(JSON.stringify(vectorize_response), {
headers: {
'content-type': 'text/plain;charset=UTF-8',
'Access-Control-Allow-Origin': '*',
},
});
} catch (error) {
console.log(error);
}
Summary of the fixes: 1. I enclosed the object being passed to the Vectorize insert operation in square brackets. This is needed because the insert function requires the input to be of an Array type. 2. I converted the id from 1 to '1'. This is needed because Vectorize vector identifiers need to be of a String type. Feel free to reach out if you need additional support for Vectorize!
CedricHadjian
CedricHadjian3w ago
Thank you so much, I spent 6 hours trying to figure out what the issue is and it turns out to be the brackets, I also remember trying stringifying the id but it still never worked.
garvitg
garvitg3w ago
Happens to the best of us, I am glad we could help you out with this! Something that helps us when we develop Worker code is to setup the Worker locally as an npm project. Then you can load the project into your preferred IDE which would almost certainly display relevant packages and method signatures from node_modules. This project code can also be pushed to your preferred Version Control System if it is a collaborative project. You can refer to https://developers.cloudflare.com/vectorize/get-started/embeddings/ for an example on setting up the project from scratch.
Cloudflare Docs
Vectorize and Workers AI · Vectorize
Vectorize allows you to generate vector embeddings using a machine-learning model, including the models available in Workers AI.
CedricHadjian
CedricHadjian3w ago
Thank you, I had it working on another test worker that I was playing around with and when it came to production, I got stuck at this because I didn't notice the brackets Is it possible to insert 5000 at the same time using insert function? As far as I know it's possible to do it through embeddings.ndjson file, but would 5000 work or is there another limit?
Want results from more Discord servers?
Add your server