From 5724c5dcdff3ef4096e230a819a31b562a168f6d Mon Sep 17 00:00:00 2001 From: Taranjeet Singh Date: Fri, 17 Nov 2023 22:00:08 +0530 Subject: [PATCH] update: import bs4 lazily. This commit lazily loads the bs4 import. This is needed so that not everyone has to install the bs4 package --- embedchain/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/embedchain/utils.py b/embedchain/utils.py index 21a55e79bd..e51bcebd06 100644 --- a/embedchain/utils.py +++ b/embedchain/utils.py @@ -5,7 +5,6 @@ import string from typing import Any -from bs4 import BeautifulSoup from schema import Optional, Or, Schema from embedchain.models.data_type import DataType @@ -16,6 +15,8 @@ def parse_content(content, type): if type not in implemented: raise ValueError(f"Parser type {type} not implemented. Please choose one of {implemented}") + from bs4 import BeautifulSoup + soup = BeautifulSoup(content, type) original_size = len(str(soup.get_text()))