feat: add bedrock provider (#1069)
Co-authored-by: Burak Varlı <unexge@gmail.com>
This commit is contained in:
@@ -3,7 +3,9 @@ use dotenv::dotenv;
|
||||
use goose::message::{Message, MessageContent};
|
||||
use goose::providers::base::Provider;
|
||||
use goose::providers::errors::ProviderError;
|
||||
use goose::providers::{anthropic, azure, databricks, google, groq, ollama, openai, openrouter};
|
||||
use goose::providers::{
|
||||
anthropic, azure, bedrock, databricks, google, groq, ollama, openai, openrouter,
|
||||
};
|
||||
use mcp_core::content::Content;
|
||||
use mcp_core::tool::Tool;
|
||||
use std::collections::HashMap;
|
||||
@@ -374,6 +376,34 @@ async fn test_azure_provider() -> Result<()> {
|
||||
.await
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_bedrock_provider_long_term_credentials() -> Result<()> {
|
||||
test_provider(
|
||||
"Bedrock",
|
||||
&["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY"],
|
||||
None,
|
||||
bedrock::BedrockProvider::default,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_bedrock_provider_aws_profile_credentials() -> Result<()> {
|
||||
let env_mods = HashMap::from_iter([
|
||||
// Ensure to unset long-term credentials to use AWS Profile provider
|
||||
("AWS_ACCESS_KEY_ID", None),
|
||||
("AWS_SECRET_ACCESS_KEY", None),
|
||||
]);
|
||||
|
||||
test_provider(
|
||||
"Bedrock AWS Profile Credentials",
|
||||
&["AWS_PROFILE"],
|
||||
Some(env_mods),
|
||||
bedrock::BedrockProvider::default,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_databricks_provider() -> Result<()> {
|
||||
test_provider(
|
||||
|
||||
@@ -8,7 +8,7 @@ use goose::model::ModelConfig;
|
||||
use goose::providers::base::Provider;
|
||||
use goose::providers::{anthropic::AnthropicProvider, databricks::DatabricksProvider};
|
||||
use goose::providers::{
|
||||
azure::AzureProvider, ollama::OllamaProvider, openai::OpenAiProvider,
|
||||
azure::AzureProvider, bedrock::BedrockProvider, ollama::OllamaProvider, openai::OpenAiProvider,
|
||||
openrouter::OpenRouterProvider,
|
||||
};
|
||||
use goose::providers::{google::GoogleProvider, groq::GroqProvider};
|
||||
@@ -18,6 +18,7 @@ enum ProviderType {
|
||||
Azure,
|
||||
OpenAi,
|
||||
Anthropic,
|
||||
Bedrock,
|
||||
Databricks,
|
||||
Google,
|
||||
Groq,
|
||||
@@ -35,6 +36,7 @@ impl ProviderType {
|
||||
],
|
||||
ProviderType::OpenAi => &["OPENAI_API_KEY"],
|
||||
ProviderType::Anthropic => &["ANTHROPIC_API_KEY"],
|
||||
ProviderType::Bedrock => &["AWS_PROFILE", "AWS_REGION"],
|
||||
ProviderType::Databricks => &["DATABRICKS_HOST"],
|
||||
ProviderType::Google => &["GOOGLE_API_KEY"],
|
||||
ProviderType::Groq => &["GROQ_API_KEY"],
|
||||
@@ -66,6 +68,7 @@ impl ProviderType {
|
||||
ProviderType::Azure => Box::new(AzureProvider::from_env(model_config)?),
|
||||
ProviderType::OpenAi => Box::new(OpenAiProvider::from_env(model_config)?),
|
||||
ProviderType::Anthropic => Box::new(AnthropicProvider::from_env(model_config)?),
|
||||
ProviderType::Bedrock => Box::new(BedrockProvider::from_env(model_config)?),
|
||||
ProviderType::Databricks => Box::new(DatabricksProvider::from_env(model_config)?),
|
||||
ProviderType::Google => Box::new(GoogleProvider::from_env(model_config)?),
|
||||
ProviderType::Groq => Box::new(GroqProvider::from_env(model_config)?),
|
||||
@@ -200,6 +203,16 @@ mod tests {
|
||||
.await
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_truncate_agent_with_bedrock() -> Result<()> {
|
||||
run_test_with_config(TestConfig {
|
||||
provider_type: ProviderType::Bedrock,
|
||||
model: "anthropic.claude-3-5-sonnet-20241022-v2:0",
|
||||
context_window: 200_000,
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_truncate_agent_with_databricks() -> Result<()> {
|
||||
run_test_with_config(TestConfig {
|
||||
|
||||
Reference in New Issue
Block a user