Optionalfields: BedrockChatFieldsAWS Credentials.
If no credentials are provided, the default credentials from @aws-sdk/credential-provider-node will be used.
A custom fetch function for low-level access to AWS API. Defaults to fetch().
Optionalinit: RequestInitOptionalinit: RequestInitIdentifier for the guardrail configuration.
Version for the guardrail configuration.
Model to use. For example, "amazon.titan-tg1-large", this is equivalent to the modelId property in the list-foundation-models api.
The AWS region e.g. us-west-2.
Fallback to AWS_DEFAULT_REGION env variable or region specified in ~/.aws/config in case it is not provided here.
Whether or not to stream responses
OptionalendpointOverride the default endpoint hostname.
OptionalguardrailRequired when Guardrail is in use.
OptionalmaxMax tokens.
OptionalmodelAdditional kwargs to pass to the model.
OptionalstopOptionaltemperatureTemperature.
OptionaltraceTrace settings for the Bedrock Guardrails.
Optionaloptions: unknown
A type of Large Language Model (LLM) that interacts with the Bedrock service. It extends the base
LLMclass and implements theBaseBedrockInputinterface. The class is designed to authenticate and interact with the Bedrock service, which is a part of Amazon Web Services (AWS). It uses AWS credentials for authentication and can be configured with various parameters such as the model to use, the AWS region, and the maximum number of tokens to generate.The
BedrockChatclass supports both synchronous and asynchronous interactions with the model, allowing for streaming responses and handling new token callbacks. It can be configured with optional parameters like temperature, stop sequences, and guardrail settings for enhanced control over the generated responses.Example
For streaming responses, use the following example:
Example