Remove unwanted libraries and lighten package (#1391)

This commit is contained in:
Dev Khant
2024-07-09 04:30:16 +05:30
committed by GitHub
parent ebbf90f4aa
commit 1a5d0d236a
28 changed files with 235 additions and 1541 deletions

View File

@@ -12,8 +12,7 @@ try:
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

View File

@@ -11,7 +11,7 @@ try:
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

View File

@@ -15,7 +15,7 @@ try:
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

View File

@@ -20,7 +20,7 @@ class WhatsAppBot(BaseBot):
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__()

View File

@@ -8,7 +8,18 @@ load_dotenv(".env")
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(

View File

@@ -23,7 +23,7 @@ class AWSBedrockLlm(BaseLlm):
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"))
@@ -38,8 +38,7 @@ class AWSBedrockLlm(BaseLlm):
}
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)

View File

@@ -180,7 +180,7 @@ class BaseLlm(JSONSerializable):
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}")

View File

@@ -24,7 +24,7 @@ class ClarifaiLlm(BaseLlm):
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

View File

@@ -22,7 +22,7 @@ class HuggingFaceLlm(BaseLlm):
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)

View File

@@ -24,7 +24,7 @@ class BeehiivLoader(BaseLoader):
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"):

View File

@@ -8,7 +8,7 @@ try:
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

View File

@@ -3,9 +3,7 @@ import hashlib
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

View File

@@ -17,9 +17,7 @@ class DropboxLoader(BaseLoader):
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)

View File

@@ -30,7 +30,8 @@ class GithubLoader(BaseLoader):
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

View File

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

View File

@@ -28,12 +28,11 @@ class RSSFeedLoader(BaseLoader):
@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 = []

View File

@@ -12,7 +12,7 @@ try:
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

View File

@@ -24,7 +24,7 @@ class SubstackLoader(BaseLoader):
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"):

View File

@@ -7,7 +7,7 @@ try:
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

View File

@@ -18,7 +18,7 @@ class YoutubeChannelLoader(BaseLoader):
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 = []

View File

@@ -5,14 +5,12 @@ import logging
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