dspy
dspy copied to clipboard
[feat] deeplake retriever implementation
This looks good, but we usually like to have the import for external dependencies happen inside the class, so that it does not affect people who don’t need the library
@okhat could you please take a look 👀. I've made the changes that you have requested. Also, sorry for the inconvenience.
Thanks! I think that import code needs to be inside init for example
But putting the import inside init would lead to an error in the type hinting of the deeplake_client which would be VectorStore.
def __init__(
self,
deeplake_vectorstore_name: str,
deeplake_client: VectorStore, #this will throw: "VectorStore" is not defined
k: int = 3,
):
try:
from deeplake import VectorStore
except ImportError:
raise ImportError(
"The 'deeplake' extra is required to use DeepLakeRM. Install it with `pip install dspy-ai[deeplake]`"
)
self._deeplake_vectorstore_name = deeplake_vectorstore_name
self._deeplake_client = deeplake_client
super().__init__(k=k)
@okhat Except for that import part, I have fixed the code and made it workable (it's working if the import check is made outside init). Should I create a notebook for the demonstration of the retriever?
Could you also update this document?
-
docs/retrieval_models_client.md