From d2b473f8ee2a13a7dd1ddeac14d5139dbb80c1a1 Mon Sep 17 00:00:00 2001 From: "Can H. Tartanoglu" Date: Mon, 13 Apr 2026 18:45:25 +0200 Subject: [PATCH] feat(providers): add llama-swap declarative provider (#8462) --- .../goose/src/config/declarative_providers.rs | 28 +++++++++++++++++++ .../src/providers/declarative/llama_swap.json | 23 +++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 crates/goose/src/providers/declarative/llama_swap.json diff --git a/crates/goose/src/config/declarative_providers.rs b/crates/goose/src/config/declarative_providers.rs index e0da2d56..e470c0a4 100644 --- a/crates/goose/src/config/declarative_providers.rs +++ b/crates/goose/src/config/declarative_providers.rs @@ -530,6 +530,34 @@ mod tests { assert_eq!(config.models[0].name, "openai/gpt-oss-120b"); } + #[test] + fn test_llama_swap_json_deserializes() { + let json = include_str!("../providers/declarative/llama_swap.json"); + let config: DeclarativeProviderConfig = + serde_json::from_str(json).expect("llama_swap.json should parse"); + assert_eq!(config.name, "llama_swap"); + assert_eq!(config.display_name, "Llama Swap"); + assert!(matches!(config.engine, ProviderEngine::OpenAI)); + assert_eq!(config.api_key_env, ""); + assert!(!config.requires_auth); + assert!(config.skip_canonical_filtering); + assert_eq!(config.dynamic_models, Some(true)); + assert_eq!(config.supports_streaming, Some(true)); + assert_eq!(config.base_url, "${LLAMA_SWAP_HOST}/v1/chat/completions"); + assert!(config.models.is_empty()); + + let env_vars = config.env_vars.as_ref().expect("env_vars should be set"); + assert_eq!(env_vars.len(), 1); + assert_eq!(env_vars[0].name, "LLAMA_SWAP_HOST"); + assert!(!env_vars[0].required); + assert!(!env_vars[0].secret); + assert_eq!(env_vars[0].primary, Some(true)); + assert_eq!( + env_vars[0].default, + Some("http://localhost:8080".to_string()) + ); + } + #[test] fn test_existing_json_files_still_deserialize_without_new_fields() { let json = include_str!("../providers/declarative/groq.json"); diff --git a/crates/goose/src/providers/declarative/llama_swap.json b/crates/goose/src/providers/declarative/llama_swap.json new file mode 100644 index 00000000..3e66a016 --- /dev/null +++ b/crates/goose/src/providers/declarative/llama_swap.json @@ -0,0 +1,23 @@ +{ + "name": "llama_swap", + "engine": "openai", + "display_name": "Llama Swap", + "description": "Local proxy that hot-swaps llama.cpp (and other) inference backends on demand via an OpenAI-compatible API.", + "api_key_env": "", + "base_url": "${LLAMA_SWAP_HOST}/v1/chat/completions", + "env_vars": [ + { + "name": "LLAMA_SWAP_HOST", + "required": false, + "secret": false, + "primary": true, + "default": "http://localhost:8080", + "description": "Base URL of the llama-swap proxy (default: http://localhost:8080)" + } + ], + "dynamic_models": true, + "models": [], + "supports_streaming": true, + "requires_auth": false, + "skip_canonical_filtering": true +}