feat(providers): add llama-swap declarative provider (#8462)
This commit is contained in:
committed by
GitHub
parent
4ad71920bc
commit
d2b473f8ee
@@ -530,6 +530,34 @@ mod tests {
|
|||||||
assert_eq!(config.models[0].name, "openai/gpt-oss-120b");
|
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]
|
#[test]
|
||||||
fn test_existing_json_files_still_deserialize_without_new_fields() {
|
fn test_existing_json_files_still_deserialize_without_new_fields() {
|
||||||
let json = include_str!("../providers/declarative/groq.json");
|
let json = include_str!("../providers/declarative/groq.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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user