langchain-aws
langchain-aws copied to clipboard
Refactor ChatBedrock to improve support for providers
Problem
Bedrock supports several providers (AI21, Anthropic, Amazon, Mistral, Meta etc.), each of which has a slightly different request/response structure. The current ChatBedrock class currently accommodates these providers by incorporating several conditional blocks which have become unsustainable as more providers, models and features have been introduced in Bedrock. This has also made it difficult and error prone to debug and add bug fixes over time.
Solution
Refactor the ChatBedrock class to individual provider classes, for example ChatBedrockAnthropic
, and provide a mechanism in ChatBedrock to switch to these, so the users of don't have to create these classes separately.