anthropic: Add support for Claude 4 (#31203)
This PR adds support for [Claude 4](https://www.anthropic.com/news/claude-4). Release Notes: - Added support for Claude Opus 4 and Claude Sonnet 4. --------- Co-authored-by: Antonio Scandurra <me@as-cii.com> Co-authored-by: Richard Feldman <oss@rtfeldman.com>
This commit is contained in:
parent
dd4e8b9e66
commit
1475ace6f1
4 changed files with 68 additions and 80 deletions
|
@ -16,7 +16,6 @@ use gpui::{AnyElement, AnyView, App, AsyncApp, SharedString, Task, Window};
|
|||
use http_client::http::{HeaderMap, HeaderValue};
|
||||
use icons::IconName;
|
||||
use parking_lot::Mutex;
|
||||
use proto::Plan;
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize, de::DeserializeOwned};
|
||||
use std::fmt;
|
||||
|
@ -48,15 +47,6 @@ pub fn init_settings(cx: &mut App) {
|
|||
registry::init(cx);
|
||||
}
|
||||
|
||||
/// The availability of a [`LanguageModel`].
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
pub enum LanguageModelAvailability {
|
||||
/// The language model is available to the general public.
|
||||
Public,
|
||||
/// The language model is available to users on the indicated plan.
|
||||
RequiresPlan(Plan),
|
||||
}
|
||||
|
||||
/// Configuration for caching language model messages.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
|
||||
pub struct LanguageModelCacheConfiguration {
|
||||
|
@ -242,11 +232,6 @@ pub trait LanguageModel: Send + Sync {
|
|||
None
|
||||
}
|
||||
|
||||
/// Returns the availability of this language model.
|
||||
fn availability(&self) -> LanguageModelAvailability {
|
||||
LanguageModelAvailability::Public
|
||||
}
|
||||
|
||||
/// Whether this model supports images
|
||||
fn supports_images(&self) -> bool;
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ use smol::lock::{RwLock, RwLockUpgradableReadGuard, RwLockWriteGuard};
|
|||
use strum::EnumIter;
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::{LanguageModelAvailability, LanguageModelToolSchemaFormat};
|
||||
use crate::LanguageModelToolSchemaFormat;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
|
||||
#[serde(tag = "provider", rename_all = "lowercase")]
|
||||
|
@ -60,59 +60,6 @@ impl CloudModel {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns the availability of this model.
|
||||
pub fn availability(&self) -> LanguageModelAvailability {
|
||||
match self {
|
||||
Self::Anthropic(model) => match model {
|
||||
anthropic::Model::Claude3_5Sonnet
|
||||
| anthropic::Model::Claude3_7Sonnet
|
||||
| anthropic::Model::Claude3_7SonnetThinking => {
|
||||
LanguageModelAvailability::RequiresPlan(Plan::Free)
|
||||
}
|
||||
anthropic::Model::Claude3Opus
|
||||
| anthropic::Model::Claude3Sonnet
|
||||
| anthropic::Model::Claude3Haiku
|
||||
| anthropic::Model::Claude3_5Haiku
|
||||
| anthropic::Model::Custom { .. } => {
|
||||
LanguageModelAvailability::RequiresPlan(Plan::ZedPro)
|
||||
}
|
||||
},
|
||||
Self::OpenAi(model) => match model {
|
||||
open_ai::Model::ThreePointFiveTurbo
|
||||
| open_ai::Model::Four
|
||||
| open_ai::Model::FourTurbo
|
||||
| open_ai::Model::FourOmni
|
||||
| open_ai::Model::FourOmniMini
|
||||
| open_ai::Model::FourPointOne
|
||||
| open_ai::Model::FourPointOneMini
|
||||
| open_ai::Model::FourPointOneNano
|
||||
| open_ai::Model::O1Mini
|
||||
| open_ai::Model::O1Preview
|
||||
| open_ai::Model::O1
|
||||
| open_ai::Model::O3Mini
|
||||
| open_ai::Model::O3
|
||||
| open_ai::Model::O4Mini
|
||||
| open_ai::Model::Custom { .. } => {
|
||||
LanguageModelAvailability::RequiresPlan(Plan::ZedPro)
|
||||
}
|
||||
},
|
||||
Self::Google(model) => match model {
|
||||
google_ai::Model::Gemini15Pro
|
||||
| google_ai::Model::Gemini15Flash
|
||||
| google_ai::Model::Gemini20Pro
|
||||
| google_ai::Model::Gemini20Flash
|
||||
| google_ai::Model::Gemini20FlashThinking
|
||||
| google_ai::Model::Gemini20FlashLite
|
||||
| google_ai::Model::Gemini25ProExp0325
|
||||
| google_ai::Model::Gemini25ProPreview0325
|
||||
| google_ai::Model::Gemini25FlashPreview0417
|
||||
| google_ai::Model::Custom { .. } => {
|
||||
LanguageModelAvailability::RequiresPlan(Plan::ZedPro)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tool_input_format(&self) -> LanguageModelToolSchemaFormat {
|
||||
match self {
|
||||
Self::Anthropic(_) | Self::OpenAi(_) => LanguageModelToolSchemaFormat::JsonSchema,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue