Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 45 additions & 1 deletion crates/goose-server/src/configuration.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -108,6 +111,21 @@ pub enum ProviderSettings {
#[serde(default)]
estimate_factor: Option<f32>,
},
Anthropic {
#[serde(default = "default_anthropic_host")]
host: String,
api_key: String,
#[serde(default = "default_anthropic_model")]
model: String,
#[serde(default)]
temperature: Option<f32>,
#[serde(default)]
max_tokens: Option<i32>,
#[serde(default)]
context_limit: Option<usize>,
#[serde(default)]
estimate_factor: Option<f32>,
},
}

impl ProviderSettings {
Expand All @@ -120,6 +138,7 @@ impl ProviderSettings {
ProviderSettings::Ollama { .. } => ProviderType::Ollama,
ProviderSettings::Google { .. } => ProviderType::Google,
ProviderSettings::Groq { .. } => ProviderType::Groq,
ProviderSettings::Anthropic { .. } => ProviderType::Anthropic,
}
}

Expand Down Expand Up @@ -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),
}),
}
}
}
Expand Down Expand Up @@ -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
}
Expand Down
55 changes: 2 additions & 53 deletions crates/goose-server/src/state.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use anyhow::Result;
use goose::providers::configs::GroqProviderConfig;
use goose::{
agent::Agent,
developer::DeveloperSystem,
Expand All @@ -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<Mutex<Agent>>,
Expand Down Expand Up @@ -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(),
}
}
}
13 changes: 0 additions & 13 deletions profiles.yaml

This file was deleted.

16 changes: 0 additions & 16 deletions providers.yaml

This file was deleted.

18 changes: 9 additions & 9 deletions ui/desktop/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}//
};

Expand Down
Loading