Add xAI Test Coverage (#3020)

Co-authored-by: Sam Bradbury <Sam Bradbury>
Co-authored-by: Sam Bradbury <sam@consultbradbury.com>
This commit is contained in:
Sam Bradbury
2025-06-22 20:58:57 -05:00
committed by GitHub
parent 0c81198ac4
commit bf7e47a096
3 changed files with 28 additions and 4 deletions
@@ -29,7 +29,7 @@
"models": ["gemini-1.5-flash"], "models": ["gemini-1.5-flash"],
"required_keys": ["GOOGLE_API_KEY"] "required_keys": ["GOOGLE_API_KEY"]
}, },
"grok": { "groq": {
"name": "Groq", "name": "Groq",
"description": "Lorem ipsum", "description": "Lorem ipsum",
"models": ["llama-3.3-70b-versatile"], "models": ["llama-3.3-70b-versatile"],
@@ -58,5 +58,11 @@
"description": "Connect to LLMs via AWS Bedrock", "description": "Connect to LLMs via AWS Bedrock",
"models": ["us.anthropic.claude-3-7-sonnet-20250219-v1:0"], "models": ["us.anthropic.claude-3-7-sonnet-20250219-v1:0"],
"required_keys": ["AWS_PROFILE"] "required_keys": ["AWS_PROFILE"]
} },
"xai": {
"name": "Xai",
"description": "Lorem ipsum",
"models": ["grok-3"],
"required_keys": ["XAI_API_KEY"]
},
} }
+14 -1
View File
@@ -12,7 +12,7 @@ use goose::providers::{
anthropic::AnthropicProvider, azure::AzureProvider, bedrock::BedrockProvider, anthropic::AnthropicProvider, azure::AzureProvider, bedrock::BedrockProvider,
databricks::DatabricksProvider, gcpvertexai::GcpVertexAIProvider, google::GoogleProvider, databricks::DatabricksProvider, gcpvertexai::GcpVertexAIProvider, google::GoogleProvider,
groq::GroqProvider, ollama::OllamaProvider, openai::OpenAiProvider, groq::GroqProvider, ollama::OllamaProvider, openai::OpenAiProvider,
openrouter::OpenRouterProvider, openrouter::OpenRouterProvider, xai::XaiProvider,
}; };
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
@@ -27,6 +27,7 @@ enum ProviderType {
Groq, Groq,
Ollama, Ollama,
OpenRouter, OpenRouter,
Xai,
} }
impl ProviderType { impl ProviderType {
@@ -46,6 +47,7 @@ impl ProviderType {
ProviderType::Ollama => &[], ProviderType::Ollama => &[],
ProviderType::OpenRouter => &["OPENROUTER_API_KEY"], ProviderType::OpenRouter => &["OPENROUTER_API_KEY"],
ProviderType::GcpVertexAI => &["GCP_PROJECT_ID", "GCP_LOCATION"], ProviderType::GcpVertexAI => &["GCP_PROJECT_ID", "GCP_LOCATION"],
ProviderType::Xai => &["XAI_API_KEY"],
} }
} }
@@ -79,6 +81,7 @@ impl ProviderType {
ProviderType::Groq => Arc::new(GroqProvider::from_env(model_config)?), ProviderType::Groq => Arc::new(GroqProvider::from_env(model_config)?),
ProviderType::Ollama => Arc::new(OllamaProvider::from_env(model_config)?), ProviderType::Ollama => Arc::new(OllamaProvider::from_env(model_config)?),
ProviderType::OpenRouter => Arc::new(OpenRouterProvider::from_env(model_config)?), ProviderType::OpenRouter => Arc::new(OpenRouterProvider::from_env(model_config)?),
ProviderType::Xai => Arc::new(XaiProvider::from_env(model_config)?),
}) })
} }
} }
@@ -329,6 +332,16 @@ mod tests {
}) })
.await .await
} }
#[tokio::test]
async fn test_agent_with_xai() -> Result<()> {
run_test_with_config(TestConfig {
provider_type: ProviderType::Xai,
model: "grok-3",
context_window: 9_000,
})
.await
}
} }
#[cfg(test)] #[cfg(test)]
+6 -1
View File
@@ -4,7 +4,7 @@ use goose::message::{Message, MessageContent};
use goose::providers::base::Provider; use goose::providers::base::Provider;
use goose::providers::errors::ProviderError; use goose::providers::errors::ProviderError;
use goose::providers::{ use goose::providers::{
anthropic, azure, bedrock, databricks, google, groq, ollama, openai, openrouter, snowflake, anthropic, azure, bedrock, databricks, google, groq, ollama, openai, openrouter, snowflake, xai,
}; };
use mcp_core::content::Content; use mcp_core::content::Content;
use mcp_core::tool::Tool; use mcp_core::tool::Tool;
@@ -501,6 +501,11 @@ async fn test_sagemaker_tgi_provider() -> Result<()> {
.await .await
} }
#[tokio::test]
async fn test_xai_provider() -> Result<()> {
test_provider("Xai", &["XAI_API_KEY"], None, xai::XaiProvider::default).await
}
// Print the final test report // Print the final test report
#[ctor::dtor] #[ctor::dtor]
fn print_test_report() { fn print_test_report() {