From 5b6efa4c02c66627f659d118a4e41a02fa5b8a03 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 2df2ff8ca0..bc9308f7fe 100644 --- a/crates/copilot/src/copilot_chat.rs +++ b/crates/copilot/src/copilot_chat.rs @@ -52,6 +52,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 { @@ -64,7 +66,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, } } @@ -80,6 +82,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)), } } @@ -96,6 +99,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", } } @@ -111,6 +115,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", } } @@ -125,7 +130,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 81aac43f33..cde252e04a 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, @@ -221,7 +223,8 @@ impl LanguageModel for CopilotChatLanguageModel { CopilotChatModel::Claude3_5Sonnet | CopilotChatModel::Claude3_7Sonnet | CopilotChatModel::Claude3_7SonnetThinking - | CopilotChatModel::Gemini20Flash => { + | CopilotChatModel::Gemini20Flash + | CopilotChatModel::Gemini25Pro => { unreachable!() } };