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

This commit is contained in:
David Duong 2023-11-28 22:34:46 +01:00 committed by GitHub
parent 48fbc5513d
commit 947daaf833
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 5 deletions

View File

@ -54,8 +54,6 @@ class BedrockChat(BaseChatModel, BedrockBase):
def lc_attributes(self) -> Dict[str, Any]: def lc_attributes(self) -> Dict[str, Any]:
attributes: Dict[str, Any] = {} attributes: Dict[str, Any] = {}
print(self.region_name)
if self.region_name: if self.region_name:
attributes["region_name"] = self.region_name attributes["region_name"] = self.region_name

View File

@ -4,7 +4,7 @@ from abc import ABC
from typing import Any, Dict, Iterator, List, Mapping, Optional from typing import Any, Dict, Iterator, List, Mapping, Optional
from langchain_core.outputs import GenerationChunk 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.callbacks.manager import CallbackManagerForLLMRun
from langchain.llms.base import LLM from langchain.llms.base import LLM
@ -148,14 +148,14 @@ class LLMInputOutputAdapter:
class BedrockBase(BaseModel, ABC): class BedrockBase(BaseModel, ABC):
"""Base class for Bedrock models.""" """Base class for Bedrock models."""
client: Any #: :meta private: client: Any = Field(exclude=True) #: :meta private:
region_name: Optional[str] = None region_name: Optional[str] = None
"""The aws region e.g., `us-west-2`. Fallsback to AWS_DEFAULT_REGION env variable """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. 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 """The name of the profile in the ~/.aws/credentials or ~/.aws/config files, which
has either access keys or role information specified. has either access keys or role information specified.
If not specified, the default credential profile or, if on an EC2 instance, If not specified, the default credential profile or, if on an EC2 instance,