PARTIAL feat: Integrate Anthropic models via Vertex AI

This commit introduces a new language model provider,
`anthropic_vertex_ai`, that integrates Anthropic's models via the Google
Cloud Vertex AI platform. The implementation uses Google Cloud's
Application Default Credentials (ADC) for authentication and fetches
`project_id` and `location_id` from the user's settings.
This commit is contained in:
joe.schwerdtner 2025-07-21 21:25:00 +02:00
parent 132f0dd36a
commit 59073836c7
9 changed files with 2014 additions and 0 deletions

View file

@ -33,6 +33,7 @@ fs.workspace = true
futures.workspace = true
google_ai = { workspace = true, features = ["schemars"] }
google_vertex_ai = { workspace = true, features = ["schemars"] }
anthropic_vertex_ai = { workspace = true, features = ["schemars"] }
gpui.workspace = true
gpui_tokio.workspace = true
http_client.workspace = true

View file

@ -10,6 +10,7 @@ mod settings;
pub mod ui;
use crate::provider::anthropic::AnthropicLanguageModelProvider;
use crate::provider::anthropic_vertex::AnthropicVertexLanguageModelProvider;
use crate::provider::bedrock::BedrockLanguageModelProvider;
use crate::provider::cloud::CloudLanguageModelProvider;
use crate::provider::copilot_chat::CopilotChatLanguageModelProvider;
@ -72,6 +73,11 @@ fn register_language_model_providers(
GoogleVertexLanguageModelProvider::new(client.http_client(), cx),
cx,
);
registry.register_provider(
// NEW REGISTRATION BY DIAB
AnthropicVertexLanguageModelProvider::new(client.http_client(), cx),
cx,
);
registry.register_provider(
MistralLanguageModelProvider::new(client.http_client(), cx),
cx,

View file

@ -1,4 +1,5 @@
pub mod anthropic;
pub mod anthropic_vertex;
pub mod bedrock;
pub mod cloud;
pub mod copilot_chat;

File diff suppressed because it is too large Load diff

View file

@ -7,6 +7,7 @@ use settings::{Settings, SettingsSources};
use crate::provider::{
self,
anthropic::AnthropicSettings,
anthropic_vertex::AnthropicVertexSettings,
bedrock::AmazonBedrockSettings,
cloud::{self, ZedDotDevSettings},
deepseek::DeepSeekSettings,
@ -33,6 +34,7 @@ pub struct AllLanguageModelSettings {
pub deepseek: DeepSeekSettings,
pub google: GoogleSettings,
pub google_vertex: GoogleVertexSettings,
pub anthropic_vertex: AnthropicVertexSettings,
pub lmstudio: LmStudioSettings,
pub mistral: MistralSettings,
pub ollama: OllamaSettings,
@ -50,6 +52,7 @@ pub struct AllLanguageModelSettingsContent {
pub deepseek: Option<DeepseekSettingsContent>,
pub google: Option<GoogleSettingsContent>,
pub google_vertex: Option<GoogleVertexSettingsContent>,
pub anthropic_vertex: Option<AnthropicVertexSettingsContent>,
pub lmstudio: Option<LmStudioSettingsContent>,
pub mistral: Option<MistralSettingsContent>,
pub ollama: Option<OllamaSettingsContent>,
@ -126,6 +129,14 @@ pub struct GoogleVertexSettingsContent {
pub available_models: Option<Vec<provider::google_vertex::AvailableModel>>,
}
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema)]
pub struct AnthropicVertexSettingsContent {
pub api_url: Option<String>,
pub project_id: Option<String>, // ADDED
pub location_id: Option<String>, // ADDED
pub available_models: Option<Vec<provider::anthropic_vertex::AvailableModel>>,
}
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema)]
pub struct XAiSettingsContent {
pub api_url: Option<String>,
@ -322,6 +333,29 @@ impl settings::Settings for AllLanguageModelSettings {
.as_ref()
.and_then(|s| s.location_id.clone()),
);
// Anthropic Vertex AI
merge(
&mut settings.anthropic_vertex.api_url,
value
.anthropic_vertex
.as_ref()
.and_then(|s| s.api_url.clone()),
);
merge(
&mut settings.anthropic_vertex.project_id,
value
.anthropic_vertex
.as_ref()
.and_then(|s| s.project_id.clone()),
);
merge(
&mut settings.anthropic_vertex.location_id,
value
.anthropic_vertex
.as_ref()
.and_then(|s| s.location_id.clone()),
);
}
Ok(settings)