diff --git a/libs/ragstack-ai-llamaindex/ragstack_ai_llamaindex/__init__.py b/libs/ragstack-ai-llamaindex/ragstack_ai_llamaindex/__init__.py index 90fca6dd0..205633a03 100644 --- a/libs/ragstack-ai-llamaindex/ragstack_ai_llamaindex/__init__.py +++ b/libs/ragstack-ai-llamaindex/ragstack_ai_llamaindex/__init__.py @@ -11,7 +11,7 @@ # LlamaHub is disabled while using RAGStack AI, because it would download unknown software from the Internet. -def disabled_download_loader(): +def disabled_download_loader(*args, **kwargs): raise ImportError( "LlamaHub is disabled while using RAGStack AI, because it would download unknown software from the Internet.") diff --git a/libs/ragstack-ai-llamaindex/tests/test_ragstack_llamaindex.py b/libs/ragstack-ai-llamaindex/tests/test_ragstack_llamaindex.py index 3247f6bfb..fab6bbcfe 100644 --- a/libs/ragstack-ai-llamaindex/tests/test_ragstack_llamaindex.py +++ b/libs/ragstack-ai-llamaindex/tests/test_ragstack_llamaindex.py @@ -1,5 +1,20 @@ +import pytest + + def test_import(): from ragstack_ai_llamaindex import __version__ # noqa from llama_index.vector_stores import AstraDBVectorStore, CassandraVectorStore # noqa import astrapy # noqa import cassio # noqa + + +def test_dont_download(): + # TODO: if you don't have the llama_index package installed, this test will fail because the monkey patch is not + # executed + from ragstack_ai_llamaindex import __version__ + from llama_index import download_loader + try: + download_loader("PDFReader") + pytest.fail("Should have raised an ImportError") + except ImportError as error: + assert "LlamaHub is disabled while using RAGStack AI" in str(error)