From 9514fba6f7a1abac3feee52d140484ba902de4ed Mon Sep 17 00:00:00 2001 From: Richard Hao Date: Tue, 15 Apr 2025 03:33:22 +0800 Subject: [PATCH] copilot_chat: Add Gemini 2.5 Pro support to Copilot Chat (#28660) --- crates/copilot/src/copilot_chat.rs | 10 ++++++++-- crates/language_models/src/provider/copilot_chat.rs | 7 +++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/crates/copilot/src/copilot_chat.rs b/crates/copilot/src/copilot_chat.rs index e2c1499838ced5279fb086c9214fc64ef940c0eb..19267a41ed517e4acf65102d19cc9f9e740a04f4 100644 --- a/crates/copilot/src/copilot_chat.rs +++ b/crates/copilot/src/copilot_chat.rs @@ -50,6 +50,8 @@ pub enum Model { Claude3_7SonnetThinking, #[serde(alias = "gemini-2.0-flash", rename = "gemini-2.0-flash-001")] Gemini20Flash, + #[serde(alias = "gemini-2.5-pro", rename = "gemini-2.5-pro")] + Gemini25Pro, } impl Model { @@ -61,7 +63,7 @@ impl Model { | Self::Claude3_5Sonnet | Self::Claude3_7Sonnet | Self::Claude3_7SonnetThinking => true, - Self::O3Mini | Self::O1 | Self::Gemini20Flash => false, + Self::O3Mini | Self::O1 | Self::Gemini20Flash | Self::Gemini25Pro => false, } } @@ -76,6 +78,7 @@ impl Model { "claude-3-7-sonnet" => Ok(Self::Claude3_7Sonnet), "claude-3.7-sonnet-thought" => Ok(Self::Claude3_7SonnetThinking), "gemini-2.0-flash-001" => Ok(Self::Gemini20Flash), + "gemini-2.5-pro" => Ok(Self::Gemini25Pro), _ => Err(anyhow!("Invalid model id: {}", id)), } } @@ -91,6 +94,7 @@ impl Model { Self::Claude3_7Sonnet => "claude-3-7-sonnet", Self::Claude3_7SonnetThinking => "claude-3.7-sonnet-thought", Self::Gemini20Flash => "gemini-2.0-flash-001", + Self::Gemini25Pro => "gemini-2.5-pro", } } @@ -105,6 +109,7 @@ impl Model { Self::Claude3_7Sonnet => "Claude 3.7 Sonnet", Self::Claude3_7SonnetThinking => "Claude 3.7 Sonnet Thinking", Self::Gemini20Flash => "Gemini 2.0 Flash", + Self::Gemini25Pro => "Gemini 2.5 Pro", } } @@ -118,7 +123,8 @@ impl Model { Self::Claude3_5Sonnet => 200_000, Self::Claude3_7Sonnet => 90_000, Self::Claude3_7SonnetThinking => 90_000, - Model::Gemini20Flash => 128_000, + Self::Gemini20Flash => 128_000, + Self::Gemini25Pro => 128_000, } } } diff --git a/crates/language_models/src/provider/copilot_chat.rs b/crates/language_models/src/provider/copilot_chat.rs index 827ca3f19073ad918b5a9196a53aed33cea4bd44..d0d7e0af0d4dc423ede33c639af5465fd38b3abd 100644 --- a/crates/language_models/src/provider/copilot_chat.rs +++ b/crates/language_models/src/provider/copilot_chat.rs @@ -210,7 +210,9 @@ impl LanguageModel for CopilotChatLanguageModel { CopilotChatModel::Claude3_5Sonnet => count_anthropic_tokens(request, cx), CopilotChatModel::Claude3_7Sonnet => count_anthropic_tokens(request, cx), CopilotChatModel::Claude3_7SonnetThinking => count_anthropic_tokens(request, cx), - CopilotChatModel::Gemini20Flash => count_google_tokens(request, cx), + CopilotChatModel::Gemini20Flash | CopilotChatModel::Gemini25Pro => { + count_google_tokens(request, cx) + } _ => { let model = match self.model { CopilotChatModel::Gpt4o => open_ai::Model::FourOmni, @@ -220,7 +222,8 @@ impl LanguageModel for CopilotChatLanguageModel { CopilotChatModel::Claude3_5Sonnet | CopilotChatModel::Claude3_7Sonnet | CopilotChatModel::Claude3_7SonnetThinking - | CopilotChatModel::Gemini20Flash => { + | CopilotChatModel::Gemini20Flash + | CopilotChatModel::Gemini25Pro => { unreachable!() } };