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

Feature Request: Query should optionally return the embedding as well. #103

Open
dan-jacobson opened this issue Mar 14, 2025 · 1 comment

Comments

@dan-jacobson
Copy link

dan-jacobson commented Mar 14, 2025

Summary

The .query() method can currently optionally return 1) the distance value, and 2) the metadata for records, along with the vector ids. However, AFAIK, the developer has to take those returned vector IDs, instantiate a separate supabase client, and use those ids to actually pull down the embeddings for the records. It'd be nice (and clean) to allow the developer to just get the embeddings back too. That way, you just need to make the one .query() call in order to get your records.

Rationale

It's frustrating to have to make a whole second db call just to get back the embeddings.

Design

Feels like you could just add an include_embedding argument that would do this:

if include_embedding:
    cols.append(self.table.c.vec)

Examples

From the vecs Introduction docs:

docs.query(
    data=[0.4,0.5,0.6],              # required
    limit=1,                         # number of records to return
    filters={"year": {"$eq": 2012}}, # metadata filters
    include_embedding=true,
)

# Returns: [("vec1", [0.7, 0.8, 0.9])]

Drawbacks

I dunno what's happening on the db side to know if this is awful for some reason.

Alternatives

I can make another db call if I have to.

@dan-jacobson
Copy link
Author

Maybe I just test to see if this works and then throw up the worlds simplest PR if it does.

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

No branches or pull requests

1 participant