diff --git a/crates/anthropic/src/anthropic.rs b/crates/anthropic/src/anthropic.rs index e9f0ea51a9..0339f65390 100644 --- a/crates/anthropic/src/anthropic.rs +++ b/crates/anthropic/src/anthropic.rs @@ -38,6 +38,8 @@ pub enum Model { Custom { name: String, max_tokens: usize, + /// The name displayed in the UI, such as in the assistant panel model dropdown menu. + display_name: Option, /// Override this model with a different Anthropic model for tool calls. tool_override: Option, /// Indicates whether this custom model supports caching. @@ -77,7 +79,9 @@ impl Model { Self::Claude3Opus => "Claude 3 Opus", Self::Claude3Sonnet => "Claude 3 Sonnet", Self::Claude3Haiku => "Claude 3 Haiku", - Self::Custom { name, .. } => name, + Self::Custom { + name, display_name, .. + } => display_name.as_ref().unwrap_or(name), } } diff --git a/crates/language_model/src/provider/anthropic.rs b/crates/language_model/src/provider/anthropic.rs index 3b44856697..e2ed27fe67 100644 --- a/crates/language_model/src/provider/anthropic.rs +++ b/crates/language_model/src/provider/anthropic.rs @@ -29,15 +29,22 @@ const PROVIDER_NAME: &str = "Anthropic"; pub struct AnthropicSettings { pub api_url: String, pub low_speed_timeout: Option, + /// Extend Zed's list of Anthropic models. pub available_models: Vec, pub needs_setting_migration: bool, } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)] pub struct AvailableModel { + /// The model's name in the Anthropic API. e.g. claude-3-5-sonnet-20240620 pub name: String, + /// The model's name in Zed's UI, such as in the model selector dropdown menu in the assistant panel. + pub display_name: Option, + /// The model's context window size. pub max_tokens: usize, + /// A model `name` to substitute when calling tools, in case the primary model doesn't support tool calling. pub tool_override: Option, + /// Configuration of Anthropic's caching API. pub cache_configuration: Option, pub max_output_tokens: Option, } @@ -171,6 +178,7 @@ impl LanguageModelProvider for AnthropicLanguageModelProvider { model.name.clone(), anthropic::Model::Custom { name: model.name.clone(), + display_name: model.display_name.clone(), max_tokens: model.max_tokens, tool_override: model.tool_override.clone(), cache_configuration: model.cache_configuration.as_ref().map(|config| { diff --git a/crates/language_model/src/provider/cloud.rs b/crates/language_model/src/provider/cloud.rs index 38478e4de3..b4ef8d3d01 100644 --- a/crates/language_model/src/provider/cloud.rs +++ b/crates/language_model/src/provider/cloud.rs @@ -52,12 +52,20 @@ pub enum AvailableProvider { #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)] pub struct AvailableModel { - provider: AvailableProvider, - name: String, - max_tokens: usize, - tool_override: Option, - cache_configuration: Option, - max_output_tokens: Option, + /// The provider of the language model. + pub provider: AvailableProvider, + /// The model's name in the provider's API. e.g. claude-3-5-sonnet-20240620 + pub name: String, + /// The name displayed in the UI, such as in the assistant panel model dropdown menu. + pub display_name: Option, + /// The size of the context window, indicating the maximum number of tokens the model can process. + pub max_tokens: usize, + /// The maximum number of output tokens allowed by the model. + pub max_output_tokens: Option, + /// Override this model with a different Anthropic model for tool calls. + pub tool_override: Option, + /// Indicates whether this custom model supports caching. + pub cache_configuration: Option, } pub struct CloudLanguageModelProvider { @@ -202,6 +210,7 @@ impl LanguageModelProvider for CloudLanguageModelProvider { AvailableProvider::Anthropic => { CloudModel::Anthropic(anthropic::Model::Custom { name: model.name.clone(), + display_name: model.display_name.clone(), max_tokens: model.max_tokens, tool_override: model.tool_override.clone(), cache_configuration: model.cache_configuration.as_ref().map(|config| { diff --git a/crates/language_model/src/settings.rs b/crates/language_model/src/settings.rs index 85dce2e121..afe223f842 100644 --- a/crates/language_model/src/settings.rs +++ b/crates/language_model/src/settings.rs @@ -94,12 +94,14 @@ impl AnthropicSettingsContent { .filter_map(|model| match model { anthropic::Model::Custom { name, + display_name, max_tokens, tool_override, cache_configuration, max_output_tokens, } => Some(provider::anthropic::AvailableModel { name, + display_name, max_tokens, tool_override, cache_configuration: cache_configuration.as_ref().map(