From 07fc2a6c249bd4d4a06f2bdc917bc2d2b00f99f0 Mon Sep 17 00:00:00 2001 From: "aaron.dsouza1" Date: Wed, 26 Feb 2025 19:09:09 +0530 Subject: [PATCH] amount interval bug fix --- dialogy/types/entity/amount_of_money/__init__.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/dialogy/types/entity/amount_of_money/__init__.py b/dialogy/types/entity/amount_of_money/__init__.py index 0a619808..c8d8cb65 100644 --- a/dialogy/types/entity/amount_of_money/__init__.py +++ b/dialogy/types/entity/amount_of_money/__init__.py @@ -51,7 +51,17 @@ def get_value(self) -> Any: def from_duckling( cls, d: Dict[str, Any], alternative_index: int, **kwargs: Any ) -> CurrencyEntity: - value = d[const.VALUE][const.VALUE] + val_dict = d[const.VALUE] + if val_dict.get(const.TYPE) == const.INTERVAL: + if const.FROM in val_dict: + value = val_dict[const.FROM][const.VALUE] + unit = val_dict[const.FROM].get(const.UNIT) + elif const.TO in val_dict: + value = val_dict[const.TO][const.VALUE] + unit = val_dict[const.TO].get(const.UNIT) + else: + value = val_dict[const.VALUE] + unit = val_dict[const.UNIT] return cls( range={const.START: d[const.START], const.END: d[const.END]}, body=d[const.BODY], @@ -59,5 +69,5 @@ def from_duckling( alternative_index=alternative_index, values=[{const.VALUE: value}], latent=d[const.LATENT], - unit=d[const.VALUE][const.UNIT], + unit=unit, )