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
4 changes: 4 additions & 0 deletions crates/goose/src/agents/reply_parts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ mod tests {
crate::providers::base::ProviderMetadata::empty()
}

fn get_name(&self) -> &str {
"mock"
}

fn get_model_config(&self) -> ModelConfig {
self.model_config.clone()
}
Expand Down
7 changes: 7 additions & 0 deletions crates/goose/src/providers/anthropic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub struct AnthropicProvider {
api_client: ApiClient,
model: ModelConfig,
supports_streaming: bool,
name: String,
}

impl AnthropicProvider {
Expand All @@ -67,6 +68,7 @@ impl AnthropicProvider {
api_client,
model,
supports_streaming: true,
name: Self::metadata().name,
})
}

Expand All @@ -91,6 +93,7 @@ impl AnthropicProvider {
api_client,
model,
supports_streaming: config.supports_streaming.unwrap_or(true),
name: config.name.clone(),
})
}

Expand Down Expand Up @@ -176,6 +179,10 @@ impl Provider for AnthropicProvider {
)
}

fn get_name(&self) -> &str {
&self.name
}

fn get_model_config(&self) -> ModelConfig {
self.model.clone()
}
Expand Down
6 changes: 6 additions & 0 deletions crates/goose/src/providers/azure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub struct AzureProvider {
deployment_name: String,
api_version: String,
model: ModelConfig,
name: String,
}

impl Serialize for AzureProvider {
Expand Down Expand Up @@ -94,6 +95,7 @@ impl AzureProvider {
deployment_name,
api_version,
model,
name: Self::metadata().name,
})
}

Expand Down Expand Up @@ -128,6 +130,10 @@ impl Provider for AzureProvider {
)
}

fn get_name(&self) -> &str {
&self.name
}

fn get_model_config(&self) -> ModelConfig {
self.model.clone()
}
Expand Down
3 changes: 3 additions & 0 deletions crates/goose/src/providers/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ pub trait Provider: Send + Sync {
where
Self: Sized;

/// Get the name of this provider instance
fn get_name(&self) -> &str;

// Internal implementation of complete, used by complete_fast and complete
// Providers should override this to implement their actual completion logic
async fn complete_with_model(
Expand Down
7 changes: 7 additions & 0 deletions crates/goose/src/providers/bedrock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ pub struct BedrockProvider {
model: ModelConfig,
#[serde(skip)]
retry_config: RetryConfig,
#[serde(skip)]
name: String,
}

impl BedrockProvider {
Expand Down Expand Up @@ -78,6 +80,7 @@ impl BedrockProvider {
client,
model,
retry_config,
name: Self::metadata().name,
})
}

Expand Down Expand Up @@ -184,6 +187,10 @@ impl Provider for BedrockProvider {
)
}

fn get_name(&self) -> &str {
&self.name
}

fn retry_config(&self) -> RetryConfig {
self.retry_config.clone()
}
Expand Down
7 changes: 7 additions & 0 deletions crates/goose/src/providers/claude_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ pub const CLAUDE_CODE_DOC_URL: &str = "https://claude.ai/cli";
pub struct ClaudeCodeProvider {
command: String,
model: ModelConfig,
#[serde(skip)]
name: String,
}

impl ClaudeCodeProvider {
Expand All @@ -42,6 +44,7 @@ impl ClaudeCodeProvider {
Ok(Self {
command: resolved_command,
model,
name: Self::metadata().name,
})
}

Expand Down Expand Up @@ -463,6 +466,10 @@ impl Provider for ClaudeCodeProvider {
)
}

fn get_name(&self) -> &str {
&self.name
}

fn get_model_config(&self) -> ModelConfig {
// Return the model config with appropriate context limit for Claude models
self.model.clone()
Expand Down
7 changes: 7 additions & 0 deletions crates/goose/src/providers/cursor_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ pub const CURSOR_AGENT_DOC_URL: &str = "https://docs.cursor.com/en/cli/overview"
pub struct CursorAgentProvider {
command: String,
model: ModelConfig,
#[serde(skip)]
name: String,
}

impl CursorAgentProvider {
Expand All @@ -41,6 +43,7 @@ impl CursorAgentProvider {
Ok(Self {
command: resolved_command,
model,
name: Self::metadata().name,
})
}

Expand Down Expand Up @@ -395,6 +398,10 @@ impl Provider for CursorAgentProvider {
)
}

fn get_name(&self) -> &str {
&self.name
}

fn get_model_config(&self) -> ModelConfig {
// Return the model config with appropriate context limit for Cursor models
self.model.clone()
Expand Down
8 changes: 8 additions & 0 deletions crates/goose/src/providers/databricks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ pub struct DatabricksProvider {
image_format: ImageFormat,
#[serde(skip)]
retry_config: RetryConfig,
#[serde(skip)]
name: String,
}

impl DatabricksProvider {
Expand Down Expand Up @@ -146,6 +148,7 @@ impl DatabricksProvider {
model: model.clone(),
image_format: ImageFormat::OpenAi,
retry_config,
name: Self::metadata().name,
};

// Check if the default fast model exists in the workspace
Expand Down Expand Up @@ -222,6 +225,7 @@ impl DatabricksProvider {
model,
image_format: ImageFormat::OpenAi,
retry_config: RetryConfig::default(),
name: Self::metadata().name,
})
}

Expand Down Expand Up @@ -260,6 +264,10 @@ impl Provider for DatabricksProvider {
)
}

fn get_name(&self) -> &str {
&self.name
}

fn retry_config(&self) -> RetryConfig {
self.retry_config.clone()
}
Expand Down
7 changes: 7 additions & 0 deletions crates/goose/src/providers/gcpvertexai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ pub struct GcpVertexAIProvider {
/// Retry configuration for handling rate limit errors
#[serde(skip)]
retry_config: RetryConfig,
#[serde(skip)]
name: String,
}

impl GcpVertexAIProvider {
Expand Down Expand Up @@ -109,6 +111,7 @@ impl GcpVertexAIProvider {
location,
model,
retry_config,
name: Self::metadata().name,
})
}

Expand Down Expand Up @@ -494,6 +497,10 @@ impl Provider for GcpVertexAIProvider {
)
}

fn get_name(&self) -> &str {
&self.name
}

/// Completes a model interaction by sending a request and processing the response.
///
/// # Arguments
Expand Down
7 changes: 7 additions & 0 deletions crates/goose/src/providers/gemini_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ pub const GEMINI_CLI_DOC_URL: &str = "https://ai.google.dev/gemini-api/docs";
pub struct GeminiCliProvider {
command: String,
model: ModelConfig,
#[serde(skip)]
name: String,
}

impl GeminiCliProvider {
Expand All @@ -42,6 +44,7 @@ impl GeminiCliProvider {
Ok(Self {
command: resolved_command,
model,
name: Self::metadata().name,
})
}

Expand Down Expand Up @@ -311,6 +314,10 @@ impl Provider for GeminiCliProvider {
)
}

fn get_name(&self) -> &str {
&self.name
}

fn get_model_config(&self) -> ModelConfig {
// Return the model config with appropriate context limit for Gemini models
self.model.clone()
Expand Down
7 changes: 7 additions & 0 deletions crates/goose/src/providers/githubcopilot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ pub struct GithubCopilotProvider {
#[serde(skip)]
mu: tokio::sync::Mutex<RefCell<Option<CopilotState>>>,
model: ModelConfig,
#[serde(skip)]
name: String,
}

impl GithubCopilotProvider {
Expand All @@ -127,6 +129,7 @@ impl GithubCopilotProvider {
cache,
mu,
model,
name: Self::metadata().name,
})
}

Expand Down Expand Up @@ -392,6 +395,10 @@ impl Provider for GithubCopilotProvider {
)
}

fn get_name(&self) -> &str {
&self.name
}

fn get_model_config(&self) -> ModelConfig {
self.model.clone()
}
Expand Down
12 changes: 11 additions & 1 deletion crates/goose/src/providers/google.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ pub struct GoogleProvider {
#[serde(skip)]
api_client: ApiClient,
model: ModelConfig,
#[serde(skip)]
name: String,
}

impl GoogleProvider {
Expand All @@ -59,7 +61,11 @@ impl GoogleProvider {
let api_client =
ApiClient::new(host, auth)?.with_header("Content-Type", "application/json")?;

Ok(Self { api_client, model })
Ok(Self {
api_client,
model,
name: Self::metadata().name,
})
}

async fn post(&self, model_name: &str, payload: &Value) -> Result<Value, ProviderError> {
Expand All @@ -86,6 +92,10 @@ impl Provider for GoogleProvider {
)
}

fn get_name(&self) -> &str {
&self.name
}

fn get_model_config(&self) -> ModelConfig {
self.model.clone()
}
Expand Down
13 changes: 13 additions & 0 deletions crates/goose/src/providers/lead_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,11 @@ impl Provider for LeadWorkerProvider {
)
}

fn get_name(&self) -> &str {
// Return the lead provider's name as the default
self.lead_provider.get_name()
}

fn get_model_config(&self) -> ModelConfig {
// Return the lead provider's model config as the default
// In practice, this might need to be more sophisticated
Expand Down Expand Up @@ -472,6 +477,10 @@ mod tests {
ProviderMetadata::empty()
}

fn get_name(&self) -> &str {
"mock-lead"
}

fn get_model_config(&self) -> ModelConfig {
self.model_config.clone()
}
Expand Down Expand Up @@ -634,6 +643,10 @@ mod tests {
ProviderMetadata::empty()
}

fn get_name(&self) -> &str {
"mock-lead"
}

fn get_model_config(&self) -> ModelConfig {
self.model_config.clone()
}
Expand Down
7 changes: 7 additions & 0 deletions crates/goose/src/providers/litellm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ pub struct LiteLLMProvider {
api_client: ApiClient,
base_path: String,
model: ModelConfig,
#[serde(skip)]
name: String,
}

impl LiteLLMProvider {
Expand Down Expand Up @@ -67,6 +69,7 @@ impl LiteLLMProvider {
api_client,
base_path,
model,
name: Self::metadata().name,
})
}

Expand Down Expand Up @@ -154,6 +157,10 @@ impl Provider for LiteLLMProvider {
)
}

fn get_name(&self) -> &str {
&self.name
}

fn get_model_config(&self) -> ModelConfig {
self.model.clone()
}
Expand Down
Loading
Loading