dspy icon indicating copy to clipboard operation
dspy copied to clipboard

[feat] deeplake retriever implementation

Open AniLeo-01 opened this issue 1 year ago • 6 comments

AniLeo-01 avatar Feb 01 '24 20:02 AniLeo-01

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 avatar Feb 01 '24 20:02 okhat

@okhat could you please take a look 👀. I've made the changes that you have requested. Also, sorry for the inconvenience.

AniLeo-01 avatar Feb 02 '24 03:02 AniLeo-01

Thanks! I think that import code needs to be inside init for example

okhat avatar Feb 02 '24 12:02 okhat

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)

AniLeo-01 avatar Feb 02 '24 14:02 AniLeo-01

@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?

AniLeo-01 avatar Feb 02 '24 14:02 AniLeo-01

Could you also update this document?

  • docs/retrieval_models_client.md

insop avatar Feb 19 '24 00:02 insop