mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-05 14:43:08 +00:00
Improve error messages formatting in doc loaders (#4586)
# Cosmetic in errors formatting Added appropriate spacing to the `ImportError` message in a bunch of document loaders to enhance trace readability (including Google Drive, Youtube, Confluence and others). This change ensures that the error messages are not displayed as a single line block, and that the `pip install xyz` commands can be copied to clipboard from terminal easily. ## Who can review? @eyurtsev
This commit is contained in:
parent
570d057db4
commit
1e5d25b93c
@ -40,8 +40,8 @@ class ImageCaptionLoader(BaseLoader):
|
|||||||
from transformers import BlipForConditionalGeneration, BlipProcessor
|
from transformers import BlipForConditionalGeneration, BlipProcessor
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"transformers package not found, please install with"
|
"`transformers` package not found, please install with "
|
||||||
"`pip install transformers`"
|
"`pip install transformers`."
|
||||||
)
|
)
|
||||||
|
|
||||||
processor = BlipProcessor.from_pretrained(self.blip_processor)
|
processor = BlipProcessor.from_pretrained(self.blip_processor)
|
||||||
@ -67,7 +67,7 @@ class ImageCaptionLoader(BaseLoader):
|
|||||||
from PIL import Image
|
from PIL import Image
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"PIL package not found, please install with `pip install pillow`"
|
"`PIL` package not found, please install with `pip install pillow`"
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -194,7 +194,7 @@ class PDFMinerLoader(BasePDFLoader):
|
|||||||
from pdfminer.high_level import extract_text # noqa:F401
|
from pdfminer.high_level import extract_text # noqa:F401
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"pdfminer package not found, please install it with "
|
"`pdfminer` package not found, please install it with "
|
||||||
"`pip install pdfminer.six`"
|
"`pip install pdfminer.six`"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ class PDFMinerPDFasHTMLLoader(BasePDFLoader):
|
|||||||
from pdfminer.high_level import extract_text_to_fp # noqa:F401
|
from pdfminer.high_level import extract_text_to_fp # noqa:F401
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"pdfminer package not found, please install it with "
|
"`pdfminer` package not found, please install it with "
|
||||||
"`pip install pdfminer.six`"
|
"`pip install pdfminer.six`"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ class PyMuPDFLoader(BasePDFLoader):
|
|||||||
import fitz # noqa:F401
|
import fitz # noqa:F401
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"PyMuPDF package not found, please install it with "
|
"`PyMuPDF` package not found, please install it with "
|
||||||
"`pip install pymupdf`"
|
"`pip install pymupdf`"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class S3FileLoader(BaseLoader):
|
|||||||
import boto3
|
import boto3
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"Could not import boto3 python package. "
|
"Could not import `boto3` python package. "
|
||||||
"Please install it with `pip install boto3`."
|
"Please install it with `pip install boto3`."
|
||||||
)
|
)
|
||||||
s3 = boto3.client("s3")
|
s3 = boto3.client("s3")
|
||||||
|
Loading…
Reference in New Issue
Block a user