diff --git a/libs/community/langchain_community/document_loaders/pdf.py b/libs/community/langchain_community/document_loaders/pdf.py index d4a636c69be..fc49be4e25c 100644 --- a/libs/community/langchain_community/document_loaders/pdf.py +++ b/libs/community/langchain_community/document_loaders/pdf.py @@ -670,7 +670,7 @@ class AmazonTextractPDFLoader(BasePDFLoader): raise ValueError( "Could not load credentials to authenticate with AWS client. " "Please check that credentials in the specified " - "profile name are valid." + f"profile name are valid. {e}" ) from e self.parser = AmazonTextractPDFParser( textract_features=features, diff --git a/libs/community/langchain_community/embeddings/bedrock.py b/libs/community/langchain_community/embeddings/bedrock.py index 7ab94df4dcb..3cfa977fd91 100644 --- a/libs/community/langchain_community/embeddings/bedrock.py +++ b/libs/community/langchain_community/embeddings/bedrock.py @@ -107,7 +107,7 @@ class BedrockEmbeddings(BaseModel, Embeddings): raise ValueError( "Could not load credentials to authenticate with AWS client. " "Please check that credentials in the specified " - "profile name are valid." + f"profile name are valid. Bedrock error: {e}" ) from e return values diff --git a/libs/community/langchain_community/embeddings/sagemaker_endpoint.py b/libs/community/langchain_community/embeddings/sagemaker_endpoint.py index 4e906133f76..1f01e1ecf4d 100644 --- a/libs/community/langchain_community/embeddings/sagemaker_endpoint.py +++ b/libs/community/langchain_community/embeddings/sagemaker_endpoint.py @@ -142,7 +142,7 @@ class SagemakerEndpointEmbeddings(BaseModel, Embeddings): raise ValueError( "Could not load credentials to authenticate with AWS client. " "Please check that credentials in the specified " - "profile name are valid." + f"profile name are valid. {e}" ) from e except ImportError: diff --git a/libs/community/langchain_community/llms/bedrock.py b/libs/community/langchain_community/llms/bedrock.py index 8ab5ad276ea..203110f87bc 100644 --- a/libs/community/langchain_community/llms/bedrock.py +++ b/libs/community/langchain_community/llms/bedrock.py @@ -427,11 +427,13 @@ class BedrockBase(BaseModel, ABC): "Could not import boto3 python package. " "Please install it with `pip install boto3`." ) + except ValueError as e: + raise ValueError(f"Error raised by bedrock service: {e}") except Exception as e: raise ValueError( "Could not load credentials to authenticate with AWS client. " "Please check that credentials in the specified " - "profile name are valid." + f"profile name are valid. Bedrock error: {e}" ) from e return values diff --git a/libs/experimental/langchain_experimental/comprehend_moderation/amazon_comprehend_moderation.py b/libs/experimental/langchain_experimental/comprehend_moderation/amazon_comprehend_moderation.py index 3298f2843f3..197d789e32e 100644 --- a/libs/experimental/langchain_experimental/comprehend_moderation/amazon_comprehend_moderation.py +++ b/libs/experimental/langchain_experimental/comprehend_moderation/amazon_comprehend_moderation.py @@ -109,7 +109,7 @@ class AmazonComprehendModerationChain(Chain): raise ValueError( "Could not load credentials to authenticate with AWS client. " "Please check that credentials in the specified " - "profile name are valid." + f"profile name are valid. {e}" ) from e @property