From 1cecdc46903897b8f5c5b9056d484277c134bdfe Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Fri, 17 May 2024 22:18:41 -0700 Subject: [PATCH] fix(utils.py): fix replicate completion cost calculation --- litellm/tests/test_completion.py | 2 ++ litellm/utils.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/litellm/tests/test_completion.py b/litellm/tests/test_completion.py index 5fe83bebe35..3caf0c277ac 100644 --- a/litellm/tests/test_completion.py +++ b/litellm/tests/test_completion.py @@ -2301,6 +2301,8 @@ def test_completion_azure_deployment_id(): # test_completion_azure_deployment_id() +import asyncio + @pytest.mark.parametrize("sync_mode", [False, True]) @pytest.mark.asyncio diff --git a/litellm/utils.py b/litellm/utils.py index 6442ecf6eb7..6d0231e8f2d 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -3853,7 +3853,7 @@ def get_replicate_completion_pricing(completion_response=None, total_time=0.0): ) if total_time == 0.0: # total time is in ms start_time = completion_response["created"] - end_time = completion_response["ended"] + end_time = getattr(completion_response, "ended", time.time()) total_time = end_time - start_time return a100_80gb_price_per_second_public * total_time / 1000