Skip to content

Commit

Permalink
fix: dependencies (#416)
Browse files Browse the repository at this point in the history
  • Loading branch information
cachho authored Aug 24, 2023
1 parent d8d0e0e commit ed31953
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 50 deletions.
1 change: 1 addition & 0 deletions docs/advanced/app_types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion embedchain/apps/CustomApp.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def get_llm_model_answer(self, prompt, config: ChatConfig):
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:
Expand Down
4 changes: 2 additions & 2 deletions embedchain/apps/OpenSourceApp.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def _get_instance(model):
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)
Expand Down
8 changes: 7 additions & 1 deletion embedchain/config/apps/OpenSourceAppConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,10 @@ def default_embedding_function():
: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
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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]
Expand Down
46 changes: 0 additions & 46 deletions setup.py

This file was deleted.

0 comments on commit ed31953

Please sign in to comment.