fix(bedrock): fix error 'Key cache already exists' (#2423)
* bedrock: fix error 'Key cache already exists' * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
0494bc2122
commit
9bc683bdc7
2 changed files with 11 additions and 10 deletions
|
|
@ -3,7 +3,8 @@ from langchain_aws import ChatBedrock
|
|||
from langflow.base.constants import STREAM_INFO_TEXT
|
||||
from langflow.base.models.model import LCModelComponent
|
||||
from langflow.field_typing import LanguageModel
|
||||
from langflow.io import BoolInput, DictInput, DropdownInput, MessageInput, Output, StrInput
|
||||
from langflow.inputs import MessageTextInput
|
||||
from langflow.io import BoolInput, DictInput, DropdownInput, MessageInput, Output
|
||||
|
||||
|
||||
class AmazonBedrockComponent(LCModelComponent):
|
||||
|
|
@ -51,12 +52,11 @@ class AmazonBedrockComponent(LCModelComponent):
|
|||
],
|
||||
value="anthropic.claude-3-haiku-20240307-v1:0",
|
||||
),
|
||||
StrInput(name="credentials_profile_name", display_name="Credentials Profile Name"),
|
||||
StrInput(name="region_name", display_name="Region Name"),
|
||||
DictInput(name="model_kwargs", display_name="Model Kwargs", advanced=True),
|
||||
StrInput(name="endpoint_url", display_name="Endpoint URL"),
|
||||
BoolInput(name="cache", display_name="Cache"),
|
||||
StrInput(
|
||||
MessageTextInput(name="credentials_profile_name", display_name="Credentials Profile Name"),
|
||||
MessageTextInput(name="region_name", display_name="Region Name", value="us-east-1"),
|
||||
DictInput(name="model_kwargs", display_name="Model Kwargs", advanced=True, is_list=True),
|
||||
MessageTextInput(name="endpoint_url", display_name="Endpoint URL", advanced=True),
|
||||
MessageTextInput(
|
||||
name="system_message",
|
||||
display_name="System Message",
|
||||
info="System message to pass to the model.",
|
||||
|
|
@ -75,7 +75,6 @@ class AmazonBedrockComponent(LCModelComponent):
|
|||
region_name = self.region_name
|
||||
model_kwargs = self.model_kwargs
|
||||
endpoint_url = self.endpoint_url
|
||||
cache = self.cache
|
||||
stream = self.stream
|
||||
try:
|
||||
output = ChatBedrock( # type: ignore
|
||||
|
|
@ -85,7 +84,6 @@ class AmazonBedrockComponent(LCModelComponent):
|
|||
model_kwargs=model_kwargs,
|
||||
endpoint_url=endpoint_url,
|
||||
streaming=stream,
|
||||
cache=cache,
|
||||
)
|
||||
except Exception as e:
|
||||
raise ValueError("Could not connect to AmazonBedrock API.") from e
|
||||
|
|
|
|||
|
|
@ -86,7 +86,10 @@ class Component(CustomComponent):
|
|||
_attributes = {}
|
||||
for key, value in params.items():
|
||||
if key in self.__dict__:
|
||||
raise ValueError(f"Key {key} already exists in {self.__class__.__name__}")
|
||||
raise ValueError(
|
||||
f"{self.__class__.__name__} defines an input parameter named '{key}' "
|
||||
f"that is a reserved word and cannot be used."
|
||||
)
|
||||
_attributes[key] = value
|
||||
for key, input_obj in self._inputs.items():
|
||||
if key not in _attributes:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue