Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor according to Vectorize V2 spec #660

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

garvit-gupta
Copy link

@garvit-gupta garvit-gupta commented Oct 22, 2024

Update the Vectorize interface according to the V2 schema.

This PR is built on top of @kflansburg's PR: #609, but includes the changes needed for the V2 spec.

For details about Vectorize, refer to https://developers.cloudflare.com/vectorize/.

API Reference: https://developers.cloudflare.com/api/operations/vectorize-list-vectorize-indexes

@garvit-gupta garvit-gupta changed the base branch from kflansburg/vectorize to main October 25, 2024 15:10
@zebp zebp self-requested a review November 5, 2024 14:33
#[wasm_bindgen(method, catch)]
pub fn query(
this: &VectorizeIndex,
vector: &[f32],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should make this JsValue since according to the generated types it accepts a number array or a Float32Array/Float64Array.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am using wasm for the first time, so I would defer to your guidance on the appropriate type. I have changed the vector type to JsValue, but I wanted to enquire if there is any specific handling needed to ensure that it is processed as Float32Array | Float64Array?

/// Use the provided vector to perform a similarity search across the index.
pub async fn query(
&self,
vector: &[f32],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it'd be nice to just use impl AsRef<[f32]>. Also does Vectorize support 64-bit floating point internally? There JS api supports 64 bit floats with Float64Array.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would this work if the type is JsValue?

worker/src/vectorize.rs Outdated Show resolved Hide resolved
worker/src/vectorize.rs Show resolved Hide resolved
worker/src/vectorize.rs Outdated Show resolved Hide resolved
worker/src/vectorize.rs Outdated Show resolved Hide resolved
worker/src/vectorize.rs Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants