feat: bump majordomo + support llama-swap(s) provider spellings (#7)
Build & push image / build-and-push (push) Successful in 7s
Build & push image / build-and-push (push) Successful in 7s
Bump majordomo to the latest build and accept every llama-swap spelling (llama-swap/llama-swaps + un-hyphenated llamaswap/llamaswaps) in gadfly's endpoint switches; the LLM_* llama-swap(s):// DSN path already worked via majordomo.Parse. README + error messages + endpointProvider alias tests. Swarm review: 8/9 clean; qwen3-coder's "Blocking" was a false positive (claimed llamaswap was untested — it has dedicated test cases). Folded in its one fair nit (README now lists the un-hyphenated aliases). gofmt clean, go vet quiet, go test -race green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: Steve Dudenhoeffer <steve@stevedudenhoeffer.com> Co-committed-by: Steve Dudenhoeffer <steve@stevedudenhoeffer.com>
This commit was merged in pull request #7.
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