From 91ed05df2962b8eee8492374b048d27cc144d08c Mon Sep 17 00:00:00 2001 From: Krish Dholakia Date: Sat, 1 Feb 2025 09:05:20 -0800 Subject: [PATCH] Litellm dev contributor prs 01 31 2025 (#8168) * Add O3-Mini for Azure and Remove Vision Support (#8161) * Azure Released O3-mini at the same time as OAI, so i've added support here. Confirmed to work with Sweden Central. * [FIX] replace cgi for python 3.13 with email.Message as suggested in PEP 594 (#8160) * Update model_prices_and_context_window.json (#8120) codestral2501 pricing on vertex_ai * Fix/db view names (#8119) * Fix to case sensitive DB Views name * Fix to case sensitive DB View names * Added quotes to check query as well * Added quotes to create view query * test: handle server error for flaky test vertex ai has unstable endpoints --------- Co-authored-by: Wanis Elabbar <70503629+elabbarw@users.noreply.github.com> Co-authored-by: Honghua Dong Co-authored-by: superpoussin22 Co-authored-by: Miguel Armenta <37154380+ma-armenta@users.noreply.github.com> --- db_scripts/create_views.py | 4 +- .../prompt_templates/factory.py | 7 ++-- ...odel_prices_and_context_window_backup.json | 38 ++++++++++++++++++- litellm/proxy/db/create_views.py | 4 +- model_prices_and_context_window.json | 38 ++++++++++++++++++- tests/local_testing/test_batch_completions.py | 3 ++ 6 files changed, 83 insertions(+), 11 deletions(-) diff --git a/db_scripts/create_views.py b/db_scripts/create_views.py index 43226db23c15..3027b38958d9 100644 --- a/db_scripts/create_views.py +++ b/db_scripts/create_views.py @@ -168,11 +168,11 @@ async def check_view_exists(): # noqa: PLR0915 print("MonthlyGlobalSpendPerUserPerKey Created!") # noqa try: - await db.query_raw("""SELECT 1 FROM DailyTagSpend LIMIT 1""") + await db.query_raw("""SELECT 1 FROM "DailyTagSpend" LIMIT 1""") print("DailyTagSpend Exists!") # noqa except Exception: sql_query = """ - CREATE OR REPLACE VIEW DailyTagSpend AS + CREATE OR REPLACE VIEW "DailyTagSpend" AS SELECT jsonb_array_elements_text(request_tags) AS individual_request_tag, DATE(s."startTime") AS spend_date, diff --git a/litellm/litellm_core_utils/prompt_templates/factory.py b/litellm/litellm_core_utils/prompt_templates/factory.py index d1a25ce4505f..dcc4ef00fa37 100644 --- a/litellm/litellm_core_utils/prompt_templates/factory.py +++ b/litellm/litellm_core_utils/prompt_templates/factory.py @@ -2153,7 +2153,7 @@ def stringify_json_tool_call_content(messages: List) -> List: import base64 import mimetypes -from cgi import parse_header +from email.message import Message import httpx @@ -2174,8 +2174,9 @@ def stringify_json_tool_call_content(messages: List) -> List: def _parse_content_type(content_type: str) -> str: - main_type, _ = parse_header(content_type) - return main_type + m = Message() + m['content-type'] = content_type + return m.get_content_type() class BedrockImageProcessor: diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index d23fbed81fa5..477edc331183 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -211,7 +211,7 @@ "cache_read_input_token_cost": 0.00000055, "litellm_provider": "openai", "mode": "chat", - "supports_vision": true, + "supports_vision": false, "supports_prompt_caching": true }, "o3-mini-2025-01-31": { @@ -223,7 +223,7 @@ "cache_read_input_token_cost": 0.00000055, "litellm_provider": "openai", "mode": "chat", - "supports_vision": true, + "supports_vision": false, "supports_prompt_caching": true }, "o1-mini-2024-09-12": { @@ -929,6 +929,30 @@ "input_cost_per_character": 0.000030, "litellm_provider": "openai" }, + "azure/o3-mini": { + "max_tokens": 100000, + "max_input_tokens": 200000, + "max_output_tokens": 100000, + "input_cost_per_token": 0.0000011, + "output_cost_per_token": 0.0000044, + "cache_read_input_token_cost": 0.00000055, + "litellm_provider": "openai", + "mode": "chat", + "supports_vision": false, + "supports_prompt_caching": true + }, + "azure/o3-mini-2025-01-31": { + "max_tokens": 100000, + "max_input_tokens": 200000, + "max_output_tokens": 100000, + "input_cost_per_token": 0.0000011, + "output_cost_per_token": 0.0000044, + "cache_read_input_token_cost": 0.00000055, + "litellm_provider": "openai", + "mode": "chat", + "supports_vision": false, + "supports_prompt_caching": true + }, "azure/tts-1": { "mode": "audio_speech", "input_cost_per_character": 0.000015, @@ -3876,6 +3900,16 @@ "mode": "chat", "supports_function_calling": true }, + "vertex_ai/codestral@2405": { + "max_tokens": 128000, + "max_input_tokens": 128000, + "max_output_tokens": 128000, + "input_cost_per_token": 0.0000002, + "output_cost_per_token": 0.0000006, + "litellm_provider": "vertex_ai-mistral_models", + "mode": "chat", + "supports_function_calling": true + }, "vertex_ai/imagegeneration@006": { "output_cost_per_image": 0.020, "litellm_provider": "vertex_ai-image-models", diff --git a/litellm/proxy/db/create_views.py b/litellm/proxy/db/create_views.py index 2fff3d085266..e9303077b187 100644 --- a/litellm/proxy/db/create_views.py +++ b/litellm/proxy/db/create_views.py @@ -158,11 +158,11 @@ async def create_missing_views(db: _db): # noqa: PLR0915 print("MonthlyGlobalSpendPerUserPerKey Created!") # noqa try: - await db.query_raw("""SELECT 1 FROM DailyTagSpend LIMIT 1""") + await db.query_raw("""SELECT 1 FROM "DailyTagSpend" LIMIT 1""") print("DailyTagSpend Exists!") # noqa except Exception: sql_query = """ - CREATE OR REPLACE VIEW DailyTagSpend AS + CREATE OR REPLACE VIEW "DailyTagSpend" AS SELECT jsonb_array_elements_text(request_tags) AS individual_request_tag, DATE(s."startTime") AS spend_date, diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index d23fbed81fa5..477edc331183 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -211,7 +211,7 @@ "cache_read_input_token_cost": 0.00000055, "litellm_provider": "openai", "mode": "chat", - "supports_vision": true, + "supports_vision": false, "supports_prompt_caching": true }, "o3-mini-2025-01-31": { @@ -223,7 +223,7 @@ "cache_read_input_token_cost": 0.00000055, "litellm_provider": "openai", "mode": "chat", - "supports_vision": true, + "supports_vision": false, "supports_prompt_caching": true }, "o1-mini-2024-09-12": { @@ -929,6 +929,30 @@ "input_cost_per_character": 0.000030, "litellm_provider": "openai" }, + "azure/o3-mini": { + "max_tokens": 100000, + "max_input_tokens": 200000, + "max_output_tokens": 100000, + "input_cost_per_token": 0.0000011, + "output_cost_per_token": 0.0000044, + "cache_read_input_token_cost": 0.00000055, + "litellm_provider": "openai", + "mode": "chat", + "supports_vision": false, + "supports_prompt_caching": true + }, + "azure/o3-mini-2025-01-31": { + "max_tokens": 100000, + "max_input_tokens": 200000, + "max_output_tokens": 100000, + "input_cost_per_token": 0.0000011, + "output_cost_per_token": 0.0000044, + "cache_read_input_token_cost": 0.00000055, + "litellm_provider": "openai", + "mode": "chat", + "supports_vision": false, + "supports_prompt_caching": true + }, "azure/tts-1": { "mode": "audio_speech", "input_cost_per_character": 0.000015, @@ -3876,6 +3900,16 @@ "mode": "chat", "supports_function_calling": true }, + "vertex_ai/codestral@2405": { + "max_tokens": 128000, + "max_input_tokens": 128000, + "max_output_tokens": 128000, + "input_cost_per_token": 0.0000002, + "output_cost_per_token": 0.0000006, + "litellm_provider": "vertex_ai-mistral_models", + "mode": "chat", + "supports_function_calling": true + }, "vertex_ai/imagegeneration@006": { "output_cost_per_image": 0.020, "litellm_provider": "vertex_ai-image-models", diff --git a/tests/local_testing/test_batch_completions.py b/tests/local_testing/test_batch_completions.py index e8fef5249f59..0883fd36d777 100644 --- a/tests/local_testing/test_batch_completions.py +++ b/tests/local_testing/test_batch_completions.py @@ -43,6 +43,9 @@ def test_batch_completions(): except Timeout as e: print(f"IN TIMEOUT") pass + except litellm.InternalServerError as e: + print(f"IN INTERNAL SERVER ERROR") + pass except Exception as e: pytest.fail(f"An error occurred: {e}")