diff --git a/crates/goose-server/src/configuration.rs b/crates/goose-server/src/configuration.rs index bbece127666e..870b0fba0dad 100644 --- a/crates/goose-server/src/configuration.rs +++ b/crates/goose-server/src/configuration.rs @@ -1,8 +1,11 @@ use crate::error::{to_env_var, ConfigError}; use config::{Config, Environment}; -use goose::providers::configs::{GoogleProviderConfig, GroqProviderConfig}; +use goose::providers::configs::{ + AnthropicProviderConfig, GoogleProviderConfig, GroqProviderConfig, +}; use goose::providers::openai::OPEN_AI_DEFAULT_MODEL; use goose::providers::{ + anthropic, configs::{ DatabricksAuth, DatabricksProviderConfig, ModelConfig, OllamaProviderConfig, OpenAiProviderConfig, ProviderConfig, @@ -108,6 +111,21 @@ pub enum ProviderSettings { #[serde(default)] estimate_factor: Option, }, + Anthropic { + #[serde(default = "default_anthropic_host")] + host: String, + api_key: String, + #[serde(default = "default_anthropic_model")] + model: String, + #[serde(default)] + temperature: Option, + #[serde(default)] + max_tokens: Option, + #[serde(default)] + context_limit: Option, + #[serde(default)] + estimate_factor: Option, + }, } impl ProviderSettings { @@ -120,6 +138,7 @@ impl ProviderSettings { ProviderSettings::Ollama { .. } => ProviderType::Ollama, ProviderSettings::Google { .. } => ProviderType::Google, ProviderSettings::Groq { .. } => ProviderType::Groq, + ProviderSettings::Anthropic { .. } => ProviderType::Anthropic, } } @@ -210,6 +229,23 @@ impl ProviderSettings { .with_context_limit(context_limit) .with_estimate_factor(estimate_factor), }), + ProviderSettings::Anthropic { + host, + api_key, + model, + temperature, + max_tokens, + context_limit, + estimate_factor, + } => ProviderConfig::Anthropic(AnthropicProviderConfig { + host, + api_key, + model: ModelConfig::new(model) + .with_temperature(temperature) + .with_max_tokens(max_tokens) + .with_context_limit(context_limit) + .with_estimate_factor(estimate_factor), + }), } } } @@ -317,6 +353,14 @@ fn default_groq_model() -> String { groq::GROQ_DEFAULT_MODEL.to_string() } +fn default_anthropic_host() -> String { + "https://api.anthropic.com".to_string() +} + +fn default_anthropic_model() -> String { + anthropic::ANTHROPIC_DEFAULT_MODEL.to_string() +} + fn default_image_format() -> ImageFormat { ImageFormat::Anthropic } diff --git a/crates/goose-server/src/state.rs b/crates/goose-server/src/state.rs index cec731d4a0a1..08a2dd8f5041 100644 --- a/crates/goose-server/src/state.rs +++ b/crates/goose-server/src/state.rs @@ -1,5 +1,4 @@ use anyhow::Result; -use goose::providers::configs::GroqProviderConfig; use goose::{ agent::Agent, developer::DeveloperSystem, @@ -11,6 +10,8 @@ use std::{env, sync::Arc}; use tokio::sync::Mutex; /// Shared application state +#[allow(dead_code)] +#[derive(Clone)] pub struct AppState { pub provider_config: ProviderConfig, pub agent: Arc>, @@ -60,55 +61,3 @@ impl AppState { }) } } - -// Manual Clone implementation since we know ProviderConfig variants can be cloned -impl Clone for AppState { - fn clone(&self) -> Self { - Self { - provider_config: match &self.provider_config { - ProviderConfig::OpenAi(config) => { - ProviderConfig::OpenAi(goose::providers::configs::OpenAiProviderConfig { - host: config.host.clone(), - api_key: config.api_key.clone(), - model: config.model.clone(), - }) - } - ProviderConfig::Databricks(config) => ProviderConfig::Databricks( - goose::providers::configs::DatabricksProviderConfig { - host: config.host.clone(), - auth: config.auth.clone(), - model: config.model.clone(), - image_format: config.image_format, - }, - ), - ProviderConfig::Ollama(config) => { - ProviderConfig::Ollama(goose::providers::configs::OllamaProviderConfig { - host: config.host.clone(), - model: config.model.clone(), - }) - } - ProviderConfig::Anthropic(config) => { - ProviderConfig::Anthropic(goose::providers::configs::AnthropicProviderConfig { - host: config.host.clone(), - api_key: config.api_key.clone(), - model: config.model.clone(), - }) - } - ProviderConfig::Google(config) => { - ProviderConfig::Google(goose::providers::configs::GoogleProviderConfig { - host: config.host.clone(), - api_key: config.api_key.clone(), - model: config.model.clone(), - }) - } - ProviderConfig::Groq(config) => ProviderConfig::Groq(GroqProviderConfig { - host: config.host.clone(), - api_key: config.api_key.clone(), - model: config.model.clone(), - }), - }, - agent: self.agent.clone(), - secret_key: self.secret_key.clone(), - } - } -} diff --git a/profiles.yaml b/profiles.yaml deleted file mode 100644 index 9b1783af50a3..000000000000 --- a/profiles.yaml +++ /dev/null @@ -1,13 +0,0 @@ -default: - processor: - provider: databricks - model: claude-3-5-sonnet-2 - accelerator: - provider: openai / ollama - model: gpt-4o-mini / qwen2.5 - systems: - - name: synopsis - type: embedded - - name: qai - type: http - host: localhost:8001 diff --git a/providers.yaml b/providers.yaml deleted file mode 100644 index b96e58ed8d4e..000000000000 --- a/providers.yaml +++ /dev/null @@ -1,16 +0,0 @@ -providers: - - name: databricks - config: - host: databricks_host - token: databricks_token - - name: openai - config: - api_key: openai_api_key - - name: ollama - config: - host: "http://localhost:11434/" - - name: bedrock - config: - profile: aws_profile - access_key: key - accesss_secret: secret diff --git a/ui/desktop/src/main.ts b/ui/desktop/src/main.ts index 70536589f881..058132746fdd 100644 --- a/ui/desktop/src/main.ts +++ b/ui/desktop/src/main.ts @@ -37,19 +37,19 @@ const checkApiCredentials = () => { loadZshEnv(app.isPackaged); - //{env-macro-start}// - const isDatabricksConfigValid = - process.env.GOOSE_PROVIDER__TYPE === 'databricks' && + //{env-macro-start}// + const apiKeyProvidersValid = + ['openai', 'anthropic', 'google', 'groq'].includes(process.env.GOOSE_PROVIDER__TYPE) && process.env.GOOSE_PROVIDER__HOST && - process.env.GOOSE_PROVIDER__MODEL; - - const isOpenAIDirectConfigValid = - process.env.GOOSE_PROVIDER__TYPE === 'openai' && - process.env.GOOSE_PROVIDER__HOST === 'https://api.openai.com' && process.env.GOOSE_PROVIDER__MODEL && process.env.GOOSE_PROVIDER__API_KEY; + + const optionalApiKeyProvidersValid = + ['ollama', 'databricks'].includes(process.env.GOOSE_PROVIDER__TYPE) && + process.env.GOOSE_PROVIDER__HOST && + process.env.GOOSE_PROVIDER__MODEL; - return isDatabricksConfigValid || isOpenAIDirectConfigValid + return apiKeyProvidersValid|| optionalApiKeyProvidersValid; //{env-macro-end}// };