diff --git a/docs/advanced/app_types.mdx b/docs/advanced/app_types.mdx index fa8546e6..89019b3b 100644 --- a/docs/advanced/app_types.mdx +++ b/docs/advanced/app_types.mdx @@ -63,6 +63,7 @@ app = OpenSourceApp() - Here there is no need to setup any api keys. You just need to install embedchain package and these will get automatically installed. 📦 - Once you have imported and instantiated the app, every functionality from here onwards is the same for either type of app. 📚 - `OpenSourceApp` is opinionated. It uses the best open source embedding model and LLM on the market. +- extra dependencies are required for this app type. Install them with `pip install embedchain[opensource]`. ### CustomApp diff --git a/embedchain/apps/CustomApp.py b/embedchain/apps/CustomApp.py index a4cd78af..21774bde 100644 --- a/embedchain/apps/CustomApp.py +++ b/embedchain/apps/CustomApp.py @@ -68,7 +68,7 @@ class CustomApp(EmbedChain): return CustomApp._get_azure_openai_answer(prompt, config) except ImportError as e: - raise ImportError(e.msg) from None + raise ModuleNotFoundError(e.msg) from None @staticmethod def _get_openai_answer(prompt: str, config: ChatConfig) -> str: diff --git a/embedchain/apps/OpenSourceApp.py b/embedchain/apps/OpenSourceApp.py index eaf04cab..12f7f8e6 100644 --- a/embedchain/apps/OpenSourceApp.py +++ b/embedchain/apps/OpenSourceApp.py @@ -43,8 +43,8 @@ class OpenSourceApp(EmbedChain): try: from gpt4all import GPT4All except ModuleNotFoundError: - raise ValueError( - "The GPT4All python package is not installed. Please install it with `pip install GPT4All`" + raise ModuleNotFoundError( + "The GPT4All python package is not installed. Please install it with `pip install embedchain[opensource]`" # noqa E501 ) from None return GPT4All(model) diff --git a/embedchain/config/apps/OpenSourceAppConfig.py b/embedchain/config/apps/OpenSourceAppConfig.py index c2c8e9ed..7907deee 100644 --- a/embedchain/config/apps/OpenSourceAppConfig.py +++ b/embedchain/config/apps/OpenSourceAppConfig.py @@ -50,4 +50,10 @@ class OpenSourceAppConfig(BaseAppConfig): :returns: The default embedding function """ - return embedding_functions.SentenceTransformerEmbeddingFunction(model_name="all-MiniLM-L6-v2") + try: + return embedding_functions.SentenceTransformerEmbeddingFunction(model_name="all-MiniLM-L6-v2") + except ValueError as e: + print(e) + raise ModuleNotFoundError( + "The open source app requires extra dependencies. Install with `pip install embedchain[opensource]`" + ) from None diff --git a/pyproject.toml b/pyproject.toml index 03e5a393..a8886f7e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -91,6 +91,10 @@ beautifulsoup4 = "^4.12.2" pypdf = "^3.11.0" pytube = "^15.0.0" llama-index = { version = "^0.7.21", optional = true } +sentence-transformers = { version = "^2.2.2", optional = true } +torch = { version = ">=2.0.0, !=2.0.1", optional = true } +# Torch 2.0.1 is not compatible with poetry (https://github.com/pytorch/pytorch/issues/100974) +gpt4all = { version = "^1.0.8", optional = true } elasticsearch = { version = "^8.9.0", optional = true } flask = "^2.3.3" twilio = "^8.5.0" @@ -110,6 +114,7 @@ isort = "^5.12.0" [tool.poetry.extras] streamlit = ["streamlit"] community = ["llama-index"] +opensource = ["sentence-transformers", "torch", "gpt4all"] elasticsearch = ["elasticsearch"] [tool.poetry.group.docs.dependencies] diff --git a/setup.py b/setup.py deleted file mode 100644 index 165a2acf..00000000 --- a/setup.py +++ /dev/null @@ -1,46 +0,0 @@ -import setuptools - -with open("README.md", "r", encoding="utf-8") as fh: - long_description = fh.read() - -setuptools.setup( - name="embedchain", - version="0.0.41", - author="Taranjeet Singh", - author_email="reachtotj@gmail.com", - description="embedchain is a framework to easily create LLM powered bots over any dataset", # noqa:E501 - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/embedchain/embedchain", - packages=setuptools.find_packages(), - classifiers=[ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: Apache Software License", - "Operating System :: OS Independent", - ], - python_requires=">=3.8", - py_modules=["embedchain"], - install_requires=[ - "langchain>=0.0.205", - "requests", - "openai", - "chromadb>=0.4.2", - "youtube-transcript-api", - "beautifulsoup4", - "pypdf", - "pytube", - "lxml", - "gpt4all", - "sentence_transformers", - "docx2txt", - "pydantic==1.10.8", - "replicate==0.9.0", - "duckduckgo-search==3.8.4", - ], - extras_require={ - "dev": ["black", "ruff", "isort", "pytest"], - "community": ["llama-index==0.7.21"], - "elasticsearch": ["elasticsearch>=8.9.0"], - "whatsapp": ["twilio==8.5.0", "flask==1.1.2"], - }, -)