fix: keep LiteLLM default local (#10996)
This commit is contained in:
@@ -22,6 +22,7 @@ use goose_providers::request_log::{start_log, LoggerHandleExt};
|
||||
use rmcp::model::Tool;
|
||||
|
||||
const LITELLM_PROVIDER_NAME: &str = "litellm";
|
||||
const LITELLM_DEFAULT_HOST: &str = "http://localhost:4000";
|
||||
pub const LITELLM_DEFAULT_MODEL: &str = "gpt-4o-mini";
|
||||
pub const LITELLM_DOC_URL: &str = "https://docs.litellm.ai/docs/";
|
||||
|
||||
@@ -47,7 +48,7 @@ impl LiteLLMProvider {
|
||||
let api_key = secrets.get("LITELLM_API_KEY").cloned().unwrap_or_default();
|
||||
let host: String = config
|
||||
.get_param("LITELLM_HOST")
|
||||
.unwrap_or_else(|_| "https://api.litellm.ai".to_string());
|
||||
.unwrap_or_else(|_| LITELLM_DEFAULT_HOST.to_string());
|
||||
let base_path: String = config
|
||||
.get_param("LITELLM_BASE_PATH")
|
||||
.unwrap_or_else(|_| "v1/chat/completions".to_string());
|
||||
@@ -177,7 +178,7 @@ impl goose_providers::base::ProviderDescriptor for LiteLLMProvider {
|
||||
"LITELLM_HOST",
|
||||
true,
|
||||
false,
|
||||
Some("http://localhost:4000"),
|
||||
Some(LITELLM_DEFAULT_HOST),
|
||||
true,
|
||||
),
|
||||
ConfigKey::new(
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
use goose::providers::litellm::LiteLLMProvider;
|
||||
|
||||
#[tokio::test]
|
||||
async fn litellm_host_follows_the_configuration_contract() {
|
||||
let temp_dir = tempfile::tempdir().expect("tempdir");
|
||||
let root = temp_dir.path().to_string_lossy().to_string();
|
||||
let _guard = env_lock::lock_env([
|
||||
("GOOSE_PATH_ROOT", Some(root.as_str())),
|
||||
("GOOSE_DISABLE_KEYRING", Some("1")),
|
||||
("GOOSE_ADDITIONAL_CONFIG_FILES", None::<&str>),
|
||||
("LITELLM_API_KEY", Some("test-key")),
|
||||
("LITELLM_HOST", None::<&str>),
|
||||
("LITELLM_CUSTOM_HEADERS", None::<&str>),
|
||||
]);
|
||||
|
||||
let provider = LiteLLMProvider::from_env(None)
|
||||
.await
|
||||
.expect("provider should use its default host");
|
||||
let debug = format!("{provider:?}");
|
||||
assert!(
|
||||
debug.contains("http://localhost:4000"),
|
||||
"missing host should stay on the advertised local proxy: {debug}"
|
||||
);
|
||||
assert!(
|
||||
!debug.contains("api.litellm.ai"),
|
||||
"missing host should not select a remote service: {debug}"
|
||||
);
|
||||
|
||||
std::env::set_var("LITELLM_HOST", "https://proxy.example.test");
|
||||
let provider = LiteLLMProvider::from_env(None)
|
||||
.await
|
||||
.expect("provider should accept an explicit host");
|
||||
let debug = format!("{provider:?}");
|
||||
assert!(
|
||||
debug.contains("https://proxy.example.test"),
|
||||
"explicit host should remain unchanged: {debug}"
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user