feat: bump majordomo + support llama-swap(s) provider spellings
- Bump majordomo to the latest build (...225659). - Accept every llama-swap spelling in gadfly's endpoint switches — "llama-swap"/"llama-swaps" (mirroring majordomo's DSN schemes: http vs https TLS) plus the un-hyphenated "llamaswap"/"llamaswaps" — in both the GADFLY_PROVIDER+GADFLY_BASE_URL override and the GADFLY_ENDPOINT_<NAME>="llama-swap|url[|key]" form. Previously only the un-hyphenated "llamaswap" matched, so a majordomo-canonical "llama-swap" hit "unknown provider". - The LLM_* DSN path (llama-swap:// / llama-swaps://) already works via majordomo.Parse — no gadfly change needed there. - README providers table + error messages updated; new endpointProvider alias tests. gofmt clean, go vet quiet, go test -race green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+9
-5
@@ -80,7 +80,11 @@ func resolveModel() (llm.Model, error) {
|
||||
opts = append(opts, ollama.WithToken(apiKey))
|
||||
}
|
||||
return ollama.New(opts...).Model(model)
|
||||
case "llamaswap":
|
||||
case "llamaswap", "llamaswaps", "llama-swap", "llama-swaps":
|
||||
// llama-swap (model-swapping proxy). Accept every spelling: hyphenated
|
||||
// ("llama-swap"/"llama-swaps") mirrors majordomo's DSN schemes (http vs
|
||||
// https), and the un-hyphenated forms are accepted too. With an explicit
|
||||
// GADFLY_BASE_URL the scheme is whatever the URL says, so all behave the same.
|
||||
opts := []llamaswap.Option{llamaswap.WithBaseURL(baseURL)}
|
||||
if apiKey != "" {
|
||||
opts = append(opts, llamaswap.WithToken(apiKey))
|
||||
@@ -104,7 +108,7 @@ func resolveModel() (llm.Model, error) {
|
||||
}
|
||||
return google.New(opts...).Model(model)
|
||||
default:
|
||||
return nil, fmt.Errorf("GADFLY_BASE_URL is set but GADFLY_PROVIDER %q has no endpoint-override support (use openai/openai-compatible/ollama/llamaswap/foreman/anthropic/google, or unset GADFLY_BASE_URL to resolve via majordomo)", provider)
|
||||
return nil, fmt.Errorf("GADFLY_BASE_URL is set but GADFLY_PROVIDER %q has no endpoint-override support (use openai/openai-compatible/ollama/llama-swap/foreman/anthropic/google, or unset GADFLY_BASE_URL to resolve via majordomo)", provider)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +167,7 @@ func modelProvider() string {
|
||||
// plaintext local Ollama (or foreman queue) works:
|
||||
// GADFLY_ENDPOINT_BIGBOX="ollama|http://192.168.1.50:11434"
|
||||
// GADFLY_MODEL=bigbox/qwen2.5-coder:7b
|
||||
// provider is one of ollama/llamaswap/foreman/openai/anthropic/google; "foreman"
|
||||
// provider is one of ollama/llama-swap(s)/foreman/openai/anthropic/google; "foreman"
|
||||
// targets a foreman daemon (native Ollama on the wire):
|
||||
// GADFLY_ENDPOINT_M1="foreman|http://foreman-m1:8080|tok"
|
||||
//
|
||||
@@ -222,7 +226,7 @@ func endpointProvider(name, raw string) (llm.Provider, error) {
|
||||
opts = append(opts, ollama.WithToken(key))
|
||||
}
|
||||
return ollama.New(opts...), nil
|
||||
case "llamaswap":
|
||||
case "llamaswap", "llamaswaps", "llama-swap", "llama-swaps":
|
||||
opts := []llamaswap.Option{llamaswap.WithName(name), llamaswap.WithBaseURL(baseURL)}
|
||||
if key != "" {
|
||||
opts = append(opts, llamaswap.WithToken(key))
|
||||
@@ -252,6 +256,6 @@ func endpointProvider(name, raw string) (llm.Provider, error) {
|
||||
}
|
||||
return google.New(opts...), nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown provider %q (use ollama/llamaswap/foreman/openai/openai-compatible/anthropic/google)", provider)
|
||||
return nil, fmt.Errorf("unknown provider %q (use ollama/llama-swap(s)/foreman/openai/openai-compatible/anthropic/google)", provider)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,19 @@ func TestEndpointProvider(t *testing.T) {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
})
|
||||
// All llama-swap spellings (hyphenated/TLS variants mirror majordomo's DSN
|
||||
// schemes) must resolve to the llamaswap provider.
|
||||
for _, name := range []string{"llama-swap", "llama-swaps", "llamaswaps"} {
|
||||
t.Run(name+" alias", func(t *testing.T) {
|
||||
p, err := endpointProvider("ls", name+"|https://swap.lan:8080|tok")
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if p.Name() != "ls" {
|
||||
t.Errorf("Name() = %q, want %q", p.Name(), "ls")
|
||||
}
|
||||
})
|
||||
}
|
||||
for _, bad := range []string{"", "ollama", "noprovider-no-pipe", "mystery|http://x"} {
|
||||
t.Run("rejects "+bad, func(t *testing.T) {
|
||||
if _, err := endpointProvider("n", bad); err == nil {
|
||||
|
||||
Reference in New Issue
Block a user