fix telegram imports (#1110)

searx-api
Harrison Chase 1 year ago committed by GitHub
parent 6fafcd0a70
commit 3f50feb280
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -3,8 +3,6 @@ import json
from pathlib import Path from pathlib import Path
from typing import List from typing import List
import pandas as pd
from langchain.docstore.document import Document from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader from langchain.document_loaders.base import BaseLoader
@ -26,6 +24,13 @@ class TelegramChatLoader(BaseLoader):
def load(self) -> List[Document]: def load(self) -> List[Document]:
"""Load documents.""" """Load documents."""
try:
import pandas as pd
except ImportError:
raise ValueError(
"pandas is needed for Telegram loader, "
"please install with `pip install pandas`"
)
p = Path(self.file_path) p = Path(self.file_path)
with open(p, encoding="utf8") as f: with open(p, encoding="utf8") as f:

Loading…
Cancel
Save