Skip to content

Commit

Permalink
Remove unwanted libraries and lighten package (#1391)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dev-Khant authored Jul 8, 2024
1 parent ebbf90f commit 1a5d0d2
Show file tree
Hide file tree
Showing 28 changed files with 238 additions and 1,544 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ PROJECT_NAME := embedchain
install:
poetry install

# TODO: use a more efficient way to install these packages
install_all:
poetry install --all-extras
poetry run pip install pinecone-text pinecone-client langchain-anthropic "unstructured[local-inference, all-docs]" ollama langchain_together==0.1.3 langchain_cohere==0.1.5 deepgram-sdk==3.2.7 langchain-huggingface psutil
poetry run pip install pinecone-text pinecone-client langchain-anthropic "unstructured[local-inference, all-docs]" ollama langchain_together==0.1.3 \
langchain_cohere==0.1.5 deepgram-sdk==3.2.7 langchain-huggingface psutil clarifai==10.0.1 flask==2.3.3 twilio==8.5.0 fastapi-poe==0.0.16 discord==2.3.2 \
slack-sdk==3.21.3 huggingface_hub==0.23.0 gitpython==3.1.38 yt_dlp==2023.11.14 PyGithub==1.59.1 feedparser==6.0.10 newspaper3k==0.2.8 listparser==0.19 \
modal==0.56.4329 dropbox==11.36.2 boto3==1.34.20 youtube-transcript-api==0.6.1 pytube==15.0.0 beautifulsoup4==4.12.3

install_es:
poetry install --extras elasticsearch
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/poe_bot.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ title: '🔮 Poe Bot'
1. Install embedchain python package:

```bash
pip install --upgrade "embedchain[poe]"
pip install fastapi-poe==0.0.16
```

2. Create a free account on [Poe](https://www.poe.com?utm_source=embedchain).
Expand Down
3 changes: 1 addition & 2 deletions embedchain/bots/discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
from discord.ext import commands
except ModuleNotFoundError:
raise ModuleNotFoundError(
"The required dependencies for Discord are not installed."
'Please install with `pip install "embedchain[discord]"`'
"The required dependencies for Discord are not installed." "Please install with `pip install discord==2.3.2`"
) from None


Expand Down
2 changes: 1 addition & 1 deletion embedchain/bots/poe.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from fastapi_poe import PoeBot, run
except ModuleNotFoundError:
raise ModuleNotFoundError(
"The required dependencies for Poe are not installed." 'Please install with `pip install "embedchain[poe]"`'
"The required dependencies for Poe are not installed." "Please install with `pip install fastapi-poe==0.0.16`"
) from None


Expand Down
2 changes: 1 addition & 1 deletion embedchain/bots/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
except ModuleNotFoundError:
raise ModuleNotFoundError(
"The required dependencies for Slack are not installed."
'Please install with `pip install --upgrade "embedchain[slack]"`'
"Please install with `pip install slack-sdk==3.21.3 flask==2.3.3`"
) from None


Expand Down
2 changes: 1 addition & 1 deletion embedchain/bots/whatsapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self):
except ModuleNotFoundError:
raise ModuleNotFoundError(
"The required dependencies for WhatsApp are not installed. "
'Please install with `pip install --upgrade "embedchain[whatsapp]"`'
"Please install with `pip install twilio==8.5.0 flask==2.3.3`"
) from None
super().__init__()

Expand Down
13 changes: 12 additions & 1 deletion embedchain/deployment/modal.com/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,18 @@

image = Image.debian_slim().pip_install(
"embedchain",
"embedchain[dataloaders]",
"lanchain_community==0.2.6",
"youtube-transcript-api==0.6.1",
"pytube==15.0.0",
"beautifulsoup4==4.12.3",
"slack-sdk==3.21.3",
"huggingface_hub==0.23.0",
"gitpython==3.1.38",
"yt_dlp==2023.11.14",
"PyGithub==1.59.1",
"feedparser==6.0.10",
"newspaper3k==0.2.8",
"listparser==0.19",
)

stub = Stub(
Expand Down
5 changes: 2 additions & 3 deletions embedchain/llm/aws_bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def _get_answer(self, prompt: str, config: BaseLlmConfig) -> str:
except ModuleNotFoundError:
raise ModuleNotFoundError(
"The required dependencies for AWSBedrock are not installed."
'Please install with `pip install --upgrade "embedchain[aws-bedrock]"`'
"Please install with `pip install boto3==1.34.20`"
) from None

self.boto_client = boto3.client("bedrock-runtime", "us-west-2" or os.environ.get("AWS_REGION"))
Expand All @@ -38,8 +38,7 @@ def _get_answer(self, prompt: str, config: BaseLlmConfig) -> str:
}

if config.stream:
from langchain.callbacks.streaming_stdout import \
StreamingStdOutCallbackHandler
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler

callbacks = [StreamingStdOutCallbackHandler()]
llm = Bedrock(**kwargs, streaming=config.stream, callbacks=callbacks)
Expand Down
2 changes: 1 addition & 1 deletion embedchain/llm/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def access_search_and_get_results(input_query: str):
from langchain.tools import DuckDuckGoSearchRun
except ImportError:
raise ImportError(
'Searching requires extra dependencies. Install with `pip install --upgrade "embedchain[dataloaders]"`'
"Searching requires extra dependencies. Install with `pip install duckduckgo-search==6.1.5`"
) from None
search = DuckDuckGoSearchRun()
logger.info(f"Access search to get answers for {input_query}")
Expand Down
2 changes: 1 addition & 1 deletion embedchain/llm/clarifai.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def _get_answer(prompt: str, config: BaseLlmConfig) -> str:
except ModuleNotFoundError:
raise ModuleNotFoundError(
"The required dependencies for Clarifai are not installed."
'Please install with `pip install --upgrade "embedchain[clarifai]"`'
"Please install with `pip install clarifai==10.0.1`"
) from None

model_name = config.model
Expand Down
2 changes: 1 addition & 1 deletion embedchain/llm/huggingface.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, config: Optional[BaseLlmConfig] = None):
except ModuleNotFoundError:
raise ModuleNotFoundError(
"The required dependencies for HuggingFaceHub are not installed."
'Please install with `pip install --upgrade "embedchain[huggingface-hub]"`'
"Please install with `pip install huggingface-hub==0.23.0`"
) from None

super().__init__(config=config)
Expand Down
2 changes: 1 addition & 1 deletion embedchain/loaders/beehiiv.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def load_data(self, url: str):
from bs4.builder import ParserRejectedMarkup
except ImportError:
raise ImportError(
'Beehiiv requires extra dependencies. Install with `pip install --upgrade "embedchain[dataloaders]"`'
"Beehiiv requires extra dependencies. Install with `pip install beautifulsoup4==4.12.3`"
) from None

if not url.endswith("sitemap.xml"):
Expand Down
2 changes: 1 addition & 1 deletion embedchain/loaders/docs_site_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from bs4 import BeautifulSoup
except ImportError:
raise ImportError(
'DocsSite requires extra dependencies. Install with `pip install --upgrade "embedchain[dataloaders]"`'
"DocsSite requires extra dependencies. Install with `pip install beautifulsoup4==4.12.3`"
) from None


Expand Down
4 changes: 1 addition & 3 deletions embedchain/loaders/docx_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
try:
from langchain_community.document_loaders import Docx2txtLoader
except ImportError:
raise ImportError(
'Docx file requires extra dependencies. Install with `pip install --upgrade "embedchain[dataloaders]"`'
) from None
raise ImportError("Docx file requires extra dependencies. Install with `pip install docx2txt==0.8`") from None
from embedchain.helpers.json_serializable import register_deserializable
from embedchain.loaders.base_loader import BaseLoader

Expand Down
4 changes: 1 addition & 3 deletions embedchain/loaders/dropbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ def __init__(self):
try:
from dropbox import Dropbox, exceptions
except ImportError:
raise ImportError(
'Dropbox requires extra dependencies. Install with `pip install --upgrade "embedchain[dropbox]"`'
)
raise ImportError("Dropbox requires extra dependencies. Install with `pip install dropbox==11.36.2`")

try:
dbx = Dropbox(access_token)
Expand Down
3 changes: 2 additions & 1 deletion embedchain/loaders/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def __init__(self, config: Optional[dict[str, Any]] = None):
from github import Github
except ImportError as e:
raise ValueError(
"GithubLoader requires extra dependencies. Install with `pip install --upgrade 'embedchain[github]'`"
"GithubLoader requires extra dependencies. \
Install with `pip install gitpython==3.1.38 PyGithub==1.59.1`"
) from e

self.config = config
Expand Down
7 changes: 1 addition & 6 deletions embedchain/loaders/pdf_file.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import hashlib

try:
from langchain_community.document_loaders import PyPDFLoader
except ImportError:
raise ImportError(
'PDF File requires extra dependencies. Install with `pip install --upgrade "embedchain[dataloaders]"`'
) from None
from langchain_community.document_loaders import PyPDFLoader
from embedchain.helpers.json_serializable import register_deserializable
from embedchain.loaders.base_loader import BaseLoader
from embedchain.utils.misc import clean_string
Expand Down
5 changes: 2 additions & 3 deletions embedchain/loaders/rss_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ def serialize_metadata(metadata):
@staticmethod
def get_rss_content(url: str):
try:
from langchain_community.document_loaders import \
RSSFeedLoader as LangchainRSSFeedLoader
from langchain_community.document_loaders import RSSFeedLoader as LangchainRSSFeedLoader
except ImportError:
raise ImportError(
"""RSSFeedLoader file requires extra dependencies.
Install with `pip install --upgrade "embedchain[rss_feed]"`"""
Install with `pip install feedparser==6.0.10 newspaper3k==0.2.8 listparser==0.19`"""
) from None

output = []
Expand Down
2 changes: 1 addition & 1 deletion embedchain/loaders/sitemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from bs4.builder import ParserRejectedMarkup
except ImportError:
raise ImportError(
'Sitemap requires extra dependencies. Install with `pip install --upgrade "embedchain[dataloaders]"`'
"Sitemap requires extra dependencies. Install with `pip install beautifulsoup4==4.12.3`"
) from None

from embedchain.helpers.json_serializable import register_deserializable
Expand Down
2 changes: 1 addition & 1 deletion embedchain/loaders/substack.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def load_data(self, url: str):
from bs4.builder import ParserRejectedMarkup
except ImportError:
raise ImportError(
'Substack requires extra dependencies. Install with `pip install --upgrade "embedchain[dataloaders]"`'
"Substack requires extra dependencies. Install with `pip install beautifulsoup4==4.12.3`"
) from None

if not url.endswith("sitemap.xml"):
Expand Down
2 changes: 1 addition & 1 deletion embedchain/loaders/web_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from bs4 import BeautifulSoup
except ImportError:
raise ImportError(
'Webpage requires extra dependencies. Install with `pip install --upgrade "embedchain[dataloaders]"`'
"Webpage requires extra dependencies. Install with `pip install beautifulsoup4==4.12.3`"
) from None

from embedchain.helpers.json_serializable import register_deserializable
Expand Down
2 changes: 1 addition & 1 deletion embedchain/loaders/youtube_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def load_data(self, channel_name):
import yt_dlp
except ImportError as e:
raise ValueError(
"YoutubeLoader requires extra dependencies. Install with `pip install --upgrade 'embedchain[youtube_channel]'`" # noqa: E501
"YoutubeChannelLoader requires extra dependencies. Install with `pip install yt_dlp==2023.11.14 youtube-transcript-api==0.6.1`" # noqa: E501
) from e

data = []
Expand Down
6 changes: 2 additions & 4 deletions embedchain/loaders/youtube_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
try:
from youtube_transcript_api import YouTubeTranscriptApi
except ImportError:
raise ImportError('YouTube video requires extra dependencies. Install with `pip install youtube-transcript-api "`')
raise ImportError("YouTube video requires extra dependencies. Install with `pip install youtube-transcript-api`")
try:
from langchain_community.document_loaders import YoutubeLoader
from langchain_community.document_loaders.youtube import _parse_video_id
except ImportError:
raise ImportError(
'YouTube video requires extra dependencies. Install with `pip install --upgrade "embedchain[dataloaders]"`'
) from None
raise ImportError("YouTube video requires extra dependencies. Install with `pip install pytube==15.0.0`") from None
from embedchain.helpers.json_serializable import register_deserializable
from embedchain.loaders.base_loader import BaseLoader
from embedchain.utils.misc import clean_string
Expand Down
12 changes: 11 additions & 1 deletion examples/api_server/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
flask==2.3.2
embedchain[dataloaders]==0.0.78
youtube-transcript-api==0.6.1
pytube==15.0.0
beautifulsoup4==4.12.3
slack-sdk==3.21.3
huggingface_hub==0.23.0
gitpython==3.1.38
yt_dlp==2023.11.14
PyGithub==1.59.1
feedparser==6.0.10
newspaper3k==0.2.8
listparser==0.19
20 changes: 19 additions & 1 deletion examples/rest-api/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
fastapi==0.104.0
uvicorn==0.23.2
streamlit==1.29.0
embedchain==0.1.3
embedchain[streamlit, community, opensource, elasticsearch, opensearch, poe, discord, slack, whatsapp, weaviate, pinecone, qdrant, images, huggingface_hub, cohere, together, milvus, dataloaders, vertexai, llama2, gmail, json]==0.1.3
slack-sdk==3.21.3
flask==2.3.3
fastapi-poe==0.0.16
discord==2.3.2
twilio==8.5.0
huggingface-hub==0.17.3
embedchain[community, opensource, elasticsearch, opensearch, weaviate, pinecone, qdrant, images, cohere, together, milvus, vertexai, llama2, gmail, json]==0.1.3
sqlalchemy==2.0.22
python-multipart==0.0.6
youtube-transcript-api==0.6.1
pytube==15.0.0
beautifulsoup4==4.12.3
slack-sdk==3.21.3
huggingface_hub==0.23.0
gitpython==3.1.38
yt_dlp==2023.11.14
PyGithub==1.59.1
feedparser==6.0.10
newspaper3k==0.2.8
listparser==0.19
4 changes: 3 additions & 1 deletion examples/slack_bot/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
embedchain[slack, poe]==0.1.7
slack-sdk==3.21.3
flask==2.3.3
fastapi-poe==0.0.16
Loading

0 comments on commit 1a5d0d2

Please sign in to comment.