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

Add Embeddings context manager #832

Closed
davidmezzetti opened this issue Dec 6, 2024 · 0 comments
Closed

Add Embeddings context manager #832

davidmezzetti opened this issue Dec 6, 2024 · 0 comments
Assignees
Milestone

Comments

@davidmezzetti
Copy link
Member

To make resource management easier, add __enter__ and __exit__ methods to the Embeddings instance. The __exit__ method should call close.

This change will enable the following patterns.

with Embeddings() as embeddings:
  embeddings.index(...)
  embeddings.save(path)

with Embeddings().load(path) as embeddings:
  embeddings.search(query)
@davidmezzetti davidmezzetti added this to the v8.1.0 milestone Dec 6, 2024
@davidmezzetti davidmezzetti self-assigned this Dec 6, 2024
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