wagtail / wagtail-vector-index

Store Wagtail pages & Django models as embeddings in vector databases
https://wagtail-vector-index.readthedocs.io/en/latest/
MIT License
15 stars 10 forks source link

Ditch backend-agnostic index classes #63

Closed ababic closed 2 months ago

ababic commented 3 months ago

Well, I think they should become 'base classes' that the backend-specific ones should be based on. This way, they can still be used in type-hints for other backend-agnostic components.

To make it possible to reuse custom index code across multiple backends, backend modules should define their overrides/custom methods in a mixin that can be easily applied to generic index classes to make them work for that backend. Where developers want to register the same index with multiple backends (an unlikely scenario, but hey), they would just define and register multiple subclasses of their generic version, using the relevant backend-specific mixins.

Vector index backends can then easily identify the indexes that apply to them, by checking whether registered indexes use their specific mixin class.

Downsides of this approach would be:

tomusher commented 3 months ago

Thanks @ababic, your feedback on this is really useful.

I like this idea, the separation of VectorIndex from backend-specific Index classes has always felt a bit awkward and this seems like a sensible way to rationalise that - it also brings it more in line with Wagtail's search backends which might make it easier for developers to understand.

tomusher commented 2 months ago

I've attempted an implementation of this change over at #65

ababic commented 2 months ago

Resolved by #65