From 8239ef97b2cec723588886ddc5b5a929eea9ef60 Mon Sep 17 00:00:00 2001 From: blackwhite084 <53146034+blackwhite084@users.noreply.github.com> Date: Mon, 23 Dec 2024 11:11:55 +0800 Subject: [PATCH 1/3] Update model_prices_and_context_window.json support gemini-2.0-flash-thinking-exp-1219 --- model_prices_and_context_window.json | 42 ++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index bf6f78d187..faaed41eb1 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -3244,6 +3244,48 @@ "rpm": 10, "source": "https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-2.0-flash" }, + "gemini-2.0-flash-thinking-exp-1219": { + "max_tokens": 32000, + "max_input_tokens": 32000, + "max_output_tokens": 32000, + "max_images_per_prompt": 3000, + "max_videos_per_prompt": 10, + "max_video_length": 1, + "max_audio_length_hours": 8.4, + "max_audio_per_prompt": 1, + "max_pdf_size_mb": 30, + "input_cost_per_token": 0.00000035, + "input_cost_per_token_above_128k_tokens": 0.0000007, + "output_cost_per_token": 0.00000105, + "output_cost_per_token_above_128k_tokens": 0.0000021, + "litellm_provider": "gemini", + "mode": "chat", + "supports_system_messages": true, + "supports_function_calling": true, + "supports_vision": true, + "source": "https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#foundation_models" + }, + "gemini/gemini-2.0-flash-thinking-exp-1219": { + "max_tokens": 32000, + "max_input_tokens": 32000, + "max_output_tokens": 32000, + "max_images_per_prompt": 3000, + "max_videos_per_prompt": 10, + "max_video_length": 1, + "max_audio_length_hours": 8.4, + "max_audio_per_prompt": 1, + "max_pdf_size_mb": 30, + "input_cost_per_token": 0.00000035, + "input_cost_per_token_above_128k_tokens": 0.0000007, + "output_cost_per_token": 0.00000105, + "output_cost_per_token_above_128k_tokens": 0.0000021, + "litellm_provider": "gemini", + "mode": "chat", + "supports_system_messages": true, + "supports_function_calling": true, + "supports_vision": true, + "source": "https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#foundation_models" + }, "vertex_ai/claude-3-sonnet": { "max_tokens": 4096, "max_input_tokens": 200000, From 61f9e00cf7449191526a990b11e45558391aa182 Mon Sep 17 00:00:00 2001 From: blackwhite084 <53146034+blackwhite084@users.noreply.github.com> Date: Mon, 23 Dec 2024 11:30:17 +0800 Subject: [PATCH 2/3] Update vertex_and_google_ai_studio_gemini.py --- .../vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py index 1a08de9342..a3958f0913 100644 --- a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py +++ b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py @@ -1577,7 +1577,9 @@ class ModelResponseIterator: and "parts" in gemini_chunk["content"] ): if "text" in gemini_chunk["content"]["parts"][0]: - text = gemini_chunk["content"]["parts"][0]["text"] + text = "" + for part in gemini_chunk["content"]["parts"]: + text += part["text"] elif "functionCall" in gemini_chunk["content"]["parts"][0]: function_call = ChatCompletionToolCallFunctionChunk( name=gemini_chunk["content"]["parts"][0]["functionCall"][ From 97901a630f3855ff63a611b101489f035e344b0c Mon Sep 17 00:00:00 2001 From: blackwhite084 <53146034+blackwhite084@users.noreply.github.com> Date: Mon, 23 Dec 2024 11:39:44 +0800 Subject: [PATCH 3/3] Update vertex_and_google_ai_studio_gemini.py --- .../vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py index a3958f0913..8988a1c6df 100644 --- a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py +++ b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py @@ -1577,9 +1577,9 @@ class ModelResponseIterator: and "parts" in gemini_chunk["content"] ): if "text" in gemini_chunk["content"]["parts"][0]: - text = "" - for part in gemini_chunk["content"]["parts"]: - text += part["text"] + text = VertexGeminiConfig().get_assistant_content_message( + parts=gemini_chunk["content"]["parts"] + ) elif "functionCall" in gemini_chunk["content"]["parts"][0]: function_call = ChatCompletionToolCallFunctionChunk( name=gemini_chunk["content"]["parts"][0]["functionCall"][