Skip to content

The agent engineering platform.

Exclude Bedrock client and credentials_profile_name fields from serialisation (#13603)

David Duong947daaf83388
diff --git a/libs/langchain/langchain/chat_models/bedrock.py b/libs/langchain/langchain/chat_models/bedrock.py
index 546562fa26..ac4e256e97 100644
--- a/libs/langchain/langchain/chat_models/bedrock.py
+++ b/libs/langchain/langchain/chat_models/bedrock.py
@@ -54,8 +54,6 @@ class BedrockChat(BaseChatModel, BedrockBase):
def lc_attributes(self) -> Dict[str, Any]:
attributes: Dict[str, Any] = {}
- print(self.region_name)
-
if self.region_name:
attributes["region_name"] = self.region_name
diff --git a/libs/langchain/langchain/llms/bedrock.py b/libs/langchain/langchain/llms/bedrock.py
index 3238c7c723..acc977a0a9 100644
--- a/libs/langchain/langchain/llms/bedrock.py
+++ b/libs/langchain/langchain/llms/bedrock.py
@@ -4,7 +4,7 @@ from abc import ABC
from typing import Any, Dict, Iterator, List, Mapping, Optional
from langchain_core.outputs import GenerationChunk
-from langchain_core.pydantic_v1 import BaseModel, Extra, root_validator
+from langchain_core.pydantic_v1 import BaseModel, Extra, Field, root_validator
from langchain.callbacks.manager import CallbackManagerForLLMRun
from langchain.llms.base import LLM
@@ -148,14 +148,14 @@ class LLMInputOutputAdapter:
class BedrockBase(BaseModel, ABC):
"""Base class for Bedrock models."""
- client: Any #: :meta private:
+ client: Any = Field(exclude=True) #: :meta private:
region_name: Optional[str] = None
"""The aws region e.g., `us-west-2`. Fallsback to AWS_DEFAULT_REGION env variable
or region specified in ~/.aws/config in case it is not provided here.
"""
- credentials_profile_name: Optional[str] = None
+ credentials_profile_name: Optional[str] = Field(default=None, exclude=True)
"""The name of the profile in the ~/.aws/credentials or ~/.aws/config files, which
has either access keys or role information specified.
If not specified, the default credential profile or, if on an EC2 instance,