Skip to content

Commit

Permalink
copilot: Add Claude 3.7 Sonnet to Copilot Chat (#25529)
Browse files Browse the repository at this point in the history
- Follow-up to: #25488

Co-authored-by: Peter Tripp <peter@zed.dev>
  • Loading branch information
zhaopengme and notpeter authored Feb 25, 2025
1 parent 7075bd7 commit b12b834
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
14 changes: 12 additions & 2 deletions crates/copilot/src/copilot_chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,20 @@ pub enum Model {
O3Mini,
#[serde(alias = "claude-3-5-sonnet", rename = "claude-3.5-sonnet")]
Claude3_5Sonnet,
#[serde(alias = "claude-3-7-sonnet", rename = "claude-3.7-sonnet")]
Claude3_7Sonnet,
#[serde(alias = "gemini-2.0-flash", rename = "gemini-2.0-flash-001")]
Gemini20Flash,
}

impl Model {
pub fn uses_streaming(&self) -> bool {
match self {
Self::Gpt4o | Self::Gpt4 | Self::Gpt3_5Turbo | Self::Claude3_5Sonnet => true,
Self::Gpt4o
| Self::Gpt4
| Self::Gpt3_5Turbo
| Self::Claude3_5Sonnet
| Self::Claude3_7Sonnet => true,
Self::O3Mini | Self::O1 | Self::Gemini20Flash => false,
}
}
Expand All @@ -60,6 +66,7 @@ impl Model {
"o1" => Ok(Self::O1),
"o3-mini" => Ok(Self::O3Mini),
"claude-3-5-sonnet" => Ok(Self::Claude3_5Sonnet),
"claude-3-7-sonnet" => Ok(Self::Claude3_7Sonnet),
"gemini-2.0-flash-001" => Ok(Self::Gemini20Flash),
_ => Err(anyhow!("Invalid model id: {}", id)),
}
Expand All @@ -73,6 +80,7 @@ impl Model {
Self::O3Mini => "o3-mini",
Self::O1 => "o1",
Self::Claude3_5Sonnet => "claude-3-5-sonnet",
Self::Claude3_7Sonnet => "claude-3-7-sonnet",
Self::Gemini20Flash => "gemini-2.0-flash-001",
}
}
Expand All @@ -85,6 +93,7 @@ impl Model {
Self::O3Mini => "o3-mini",
Self::O1 => "o1",
Self::Claude3_5Sonnet => "Claude 3.5 Sonnet",
Self::Claude3_7Sonnet => "Claude 3.7 Sonnet",
Self::Gemini20Flash => "Gemini 2.0 Flash",
}
}
Expand All @@ -96,7 +105,8 @@ impl Model {
Self::Gpt3_5Turbo => 12_288,
Self::O3Mini => 64_000,
Self::O1 => 20_000,
Self::Claude3_5Sonnet => 128_000,
Self::Claude3_5Sonnet => 200_000,
Self::Claude3_7Sonnet => 90_000,
Model::Gemini20Flash => 128_000,
}
}
Expand Down
5 changes: 4 additions & 1 deletion crates/language_models/src/provider/copilot_chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,17 @@ impl LanguageModel for CopilotChatLanguageModel {
) -> BoxFuture<'static, Result<usize>> {
match self.model {
CopilotChatModel::Claude3_5Sonnet => count_anthropic_tokens(request, cx),
CopilotChatModel::Claude3_7Sonnet => count_anthropic_tokens(request, cx),
CopilotChatModel::Gemini20Flash => count_google_tokens(request, cx),
_ => {
let model = match self.model {
CopilotChatModel::Gpt4o => open_ai::Model::FourOmni,
CopilotChatModel::Gpt4 => open_ai::Model::Four,
CopilotChatModel::Gpt3_5Turbo => open_ai::Model::ThreePointFiveTurbo,
CopilotChatModel::O1 | CopilotChatModel::O3Mini => open_ai::Model::Four,
CopilotChatModel::Claude3_5Sonnet | CopilotChatModel::Gemini20Flash => {
CopilotChatModel::Claude3_5Sonnet
| CopilotChatModel::Claude3_7Sonnet
| CopilotChatModel::Gemini20Flash => {
unreachable!()
}
};
Expand Down

0 comments on commit b12b834

Please sign in to comment.