From d59dbf8230fbb0ed5cd7095cfc6cf40fa703effe Mon Sep 17 00:00:00 2001 From: Ayush Chaurasia Date: Fri, 10 Nov 2023 15:02:38 +0530 Subject: [PATCH] fix: Pydantic 1.x compat for weak_lru caching in embeddings API (#643) Colab has pydantic 1.x by default and pydantic 1.x BaseModel objects don't support weakref creation by default that we use to cache embedding models https://github.com/lancedb/lancedb/blob/main/python/lancedb/embeddings/utils.py#L206 . It needs to be added to slot. --- python/lancedb/embeddings/base.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/lancedb/embeddings/base.py b/python/lancedb/embeddings/base.py index 04d1360d..41474227 100644 --- a/python/lancedb/embeddings/base.py +++ b/python/lancedb/embeddings/base.py @@ -33,6 +33,7 @@ class EmbeddingFunction(BaseModel, ABC): 3. ndims method which returns the number of dimensions of the vector column """ + __slots__ = ("__weakref__",) # pydantic 1.x compatibility max_retries: int = ( 7 # Setitng 0 disables retires. Maybe this should not be enabled by default, )