chainlit
chainlit copied to clipboard
Fix: DynamoDB Typeerror with AWS Bedrock
When using AWS Bedrock, _update_item throws a TypeError as AWS Bedrock returns floats in its response. Dynamodb requires floats to be provided as Decimal. The reverse can also occur if you call get_thread from anywhere in code, as Decimal is not JSON serializable.
The issue can be seen here #1116
I have added two new functions within DynamoDBDataLater that converts floats to decimals and decimals to floats, calling each function from _update_item and get_thread respectively. This change resolves the TypeErrors.