Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

copilot_chat: Add Gemini 2.5 Pro support to Copilot Chat (#28660)

Richard Hao5b6efa4c02c6
diff --git a/crates/copilot/src/copilot_chat.rs b/crates/copilot/src/copilot_chat.rs
index 2df2ff8ca08..bc9308f7fe7 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 81aac43f33d..cde252e04a9 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!()
}
};