# -*- coding: utf-8 -*-"""The embedding cache base class."""fromabcimportabstractmethodfromtypingimportList,Anyfrom..typesimport(JSONSerializableObject,Embedding,)
[docs]classEmbeddingCacheBase:"""Base class for embedding caches, which is responsible for storing and retrieving embeddings."""
[docs]@abstractmethodasyncdefstore(self,embeddings:List[Embedding],identifier:JSONSerializableObject,overwrite:bool=False,**kwargs:Any,)->None:"""Store the embeddings with the given identifier. Args: embeddings (`List[Embedding]`): The embeddings to store. identifier (`JSONSerializableObject`): The identifier to distinguish the embeddings. overwrite (`bool`, defaults to `False`): Whether to overwrite existing embeddings with the same identifier. If `True`, existing embeddings will be replaced. """
[docs]@abstractmethodasyncdefretrieve(self,identifier:JSONSerializableObject,)->List[Embedding]|None:"""Retrieve the embeddings with the given identifier. If not found, return `None`. Args: identifier (`JSONSerializableObject`): The identifier to retrieve the embeddings. """
[docs]@abstractmethodasyncdefremove(self,identifier:JSONSerializableObject,)->None:"""Remove the embeddings with the given identifier. Args: identifier (`JSONSerializableObject`): The identifier to remove the embeddings. """
[docs]@abstractmethodasyncdefclear(self)->None:"""Clear all cached embeddings."""