From dcd688ee8b649cd457784e71f124e95b0c2aaedf Mon Sep 17 00:00:00 2001 From: kigland Date: Sat, 1 Aug 2026 22:32:51 +0800 Subject: [PATCH] preserve abbreviated month spellings --- litellm/litellm_core_utils/duration_parser.py | 2 ++ tests/test_litellm/litellm_core_utils/test_duration_parser.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/litellm/litellm_core_utils/duration_parser.py b/litellm/litellm_core_utils/duration_parser.py index a82e0883720..2a6b0116b6d 100644 --- a/litellm/litellm_core_utils/duration_parser.py +++ b/litellm/litellm_core_utils/duration_parser.py @@ -46,7 +46,9 @@ _DURATION_UNIT_ALIASES: Final[dict[str, str]] = { # mutable-ok: constant lookup "week": "w", "weeks": "w", "mo": "mo", + "mos": "mo", "mon": "mo", + "mons": "mo", "month": "mo", "months": "mo", } diff --git a/tests/test_litellm/litellm_core_utils/test_duration_parser.py b/tests/test_litellm/litellm_core_utils/test_duration_parser.py index 60ca2d1d38d..df0fc9938c6 100644 --- a/tests/test_litellm/litellm_core_utils/test_duration_parser.py +++ b/tests/test_litellm/litellm_core_utils/test_duration_parser.py @@ -421,6 +421,9 @@ class TestDurationInSeconds(unittest.TestCase): with self.subTest(duration=duration): self.assertEqual(duration_in_seconds(duration), expected) + self.assertEqual(duration_in_seconds("1mos"), duration_in_seconds("1mo")) + self.assertEqual(duration_in_seconds("2mons"), duration_in_seconds("2mo")) + def test_long_unit_spelling_sets_reset_interval(self): now = datetime(2023, 5, 15, 15, 0, 0, tzinfo=timezone.utc) self.assertEqual(