chainlit icon indicating copy to clipboard operation
chainlit copied to clipboard

fix: Handle float/Decimal conversion for DynamoDB persistence

Open ee-juni opened this issue 6 months ago • 0 comments
trafficstars

DynamoDB does not natively support float types, requiring conversion to Decimal for storage. This was causing issues when attempting to persist data containing floats.

This commit introduces helper functions within the serialization and deserialization methods (_serialize_item, _deserialize_item) in the DynamoDBDataLayer to address this:

  • convert_floats: Recursively converts float values to Decimal before serialization.
  • convert_decimals: Recursively converts Decimal values back to float after deserialization.

This ensures that numeric data, including floating-point numbers, is correctly persisted and retrieved from DynamoDB, fixing the previous inability to handle these types.

ee-juni avatar Apr 25 '25 08:04 ee-juni