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:
parent
132f0dd36a
commit
59073836c7
9 changed files with 2014 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue