mirror of
https://github.com/hwchase17/langchain
synced 2024-11-08 07:10:35 +00:00
fix telegram imports (#1110)
This commit is contained in:
parent
6fafcd0a70
commit
3f50feb280
@ -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…
Reference in New Issue
Block a user