From db3d6925c691b502842fb2b36691ed3c4a0e4cdf Mon Sep 17 00:00:00 2001 From: skucherlapati Date: Wed, 17 Jul 2024 14:54:54 -0700 Subject: [PATCH 1/3] add medlm cost calc --- ...model_prices_and_context_window_backup.json | 18 ++++++++++++++++++ litellm/tests/test_completion_cost.py | 12 ++++++++++++ 2 files changed, 30 insertions(+) diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index 60f812b2bb..61454b2bd5 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -1800,6 +1800,24 @@ "supports_vision": true, "source": "https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#foundation_models" }, + "medlm-medium": { + "max_tokens": 32768, + "max_output_tokens": 8192, + "input_cost_per_character": 0.0000005, + "output_cost_per_character": 0.000001, + "litellm_provider": "vertex_ai-language-models", + "mode": "chat", + "source": "https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#foundation_models" + }, + "medlm-large": { + "max_input_tokens": 8192, + "max_output_tokens": 1024, + "input_cost_per_character": 0.000005, + "output_cost_per_character": 0.000015, + "litellm_provider": "vertex_ai-language-models", + "mode": "chat", + "source": "https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#foundation_models" + }, "vertex_ai/claude-3-sonnet@20240229": { "max_tokens": 4096, "max_input_tokens": 200000, diff --git a/litellm/tests/test_completion_cost.py b/litellm/tests/test_completion_cost.py index 1daf1531cd..761bd054c8 100644 --- a/litellm/tests/test_completion_cost.py +++ b/litellm/tests/test_completion_cost.py @@ -706,6 +706,18 @@ def test_vertex_ai_completion_cost(): print("calculated_input_cost: {}".format(calculated_input_cost)) +def test_vertex_ai_medlm_completion_cost(): + model="medlm-medium" + messages = [{"role": "user", "content": "Test MedLM completion cost."}] + predictive_cost = completion_cost(model=model, messages=messages) + assert predictive_cost > 0 + + model="medlm-large" + messages = [{"role": "user", "content": "Test MedLM completion cost."}] + predictive_cost = completion_cost(model=model, messages=messages) + assert predictive_cost > 0 + + def test_vertex_ai_claude_completion_cost(): from litellm import Choices, Message, ModelResponse from litellm.utils import Usage From 3425c5f506d3024e3475a825ba6d80592af56cd5 Mon Sep 17 00:00:00 2001 From: skucherlapati Date: Wed, 17 Jul 2024 15:30:37 -0700 Subject: [PATCH 2/3] rename input tokens key --- litellm/model_prices_and_context_window_backup.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index 61454b2bd5..6820a5369b 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -1801,7 +1801,7 @@ "source": "https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#foundation_models" }, "medlm-medium": { - "max_tokens": 32768, + "max_input_tokens": 32768, "max_output_tokens": 8192, "input_cost_per_character": 0.0000005, "output_cost_per_character": 0.000001, From 5297d334269527077a18bfe0b081bfe53cc598d8 Mon Sep 17 00:00:00 2001 From: skucherlapati Date: Wed, 17 Jul 2024 15:32:42 -0700 Subject: [PATCH 3/3] max_tokens for compatibility --- litellm/model_prices_and_context_window_backup.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index 6820a5369b..b62c7717c0 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -1801,6 +1801,7 @@ "source": "https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#foundation_models" }, "medlm-medium": { + "max_tokens": 8192, "max_input_tokens": 32768, "max_output_tokens": 8192, "input_cost_per_character": 0.0000005, @@ -1810,6 +1811,7 @@ "source": "https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#foundation_models" }, "medlm-large": { + "max_tokens": 1024, "max_input_tokens": 8192, "max_output_tokens": 1024, "input_cost_per_character": 0.000005,