Files
magpie/internal/provider/fireworks_nexus_test.go
T
yetone 065ca02c28 provider: Fireworks Nexus preset, Nexus Auto on all three APIs (CNSA0422 on X)
Fireworks Nexus is an account and plan of its own (nexus.fireworks.ai,
Pro $8, Team, Enterprise) on the platform's /inference endpoints, which
speak chat completions, Responses and Anthropic messages
(docs.fireworks.ai/nexus/apis-and-sdks). Its keys are made at
nexus.fireworks.ai/settings/api-keys; a platform key carries no Nexus
plan.

The new preset fireworks-nexus (Add sheet tile "Nexus", the Fireworks
logo) sets all three endpoints and lists only `auto`: Pro and Team
refuse an open model named directly with a 403 (nexus/open-models), so
the platform's /models would offer models the plan refuses, and no list
is asked for. Enterprise users type their open models in, or set a
models URL. The editor offers x-anthropic-api-key and x-openai-api-key,
the headers Nexus Auto takes the user's own Claude and OpenAI keys in.
No usage API is documented (only the nexus.fireworks.ai/usage
dashboard), so there is no usage card. READMEs (en, zh) and
docs/reference.md list it.

Run (mote): go test -run 'TestFireworksNexus|Preset' ./internal/provider
ok at the pushed head; go test -count=1 -timeout 45m ./internal/provider
./internal/gui ./internal/catalog at the pre-rebase base: provider and
catalog ok, gui red only in the real-window AppKit tests killed at their
deadline under mote's load (TestCoveredWindowStaysUp,
TestClosingWindowMarksPageOutOfSight,
TestPanelHiddenByWailsMarksPageOutOfSight; #2645, #4924, #4125).
gofmt clean; go vet darwin, linux (nogui) and windows of internal/provider.
Broken by hand: without NoList TestFireworksNexusPreset goes red, the
fake platform list's accounts/fireworks/models/glm-5p3 listed and its
/models asked.
Not tried: a real Nexus key (none here), so neither `auto` on each API,
the header passthrough, nor what /models answers for a Nexus key; the
`auto` context window is left to the catalog (Nexus CLI writes 1M/131K).
GUI suite not run: presets reach the Add sheet as data and no GUI file
names a preset list.
2026-11-10 22:26:38 +08:00

56 lines
1.9 KiB
Go

package provider
import (
"net/http"
"net/http/httptest"
"slices"
"testing"
)
// Fireworks Nexus (CNSA0422 on X) is the platform's /inference API with a
// key from nexus.fireworks.ai, on all three APIs. Pro and Team refuse every
// model but `auto` (docs.fireworks.ai/nexus/open-models: 403), so `auto` is
// its list, and no list is asked for: the platform's would offer models the
// plan refuses.
func TestFireworksNexusPreset(t *testing.T) {
detectHome(t)
p, err := FromPreset("fireworks-nexus")
if err != nil {
t.Fatal(err)
}
if p.Chat != "https://api.fireworks.ai/inference/v1" || p.Responses != "https://api.fireworks.ai/inference/v1" ||
p.Anthropic != "https://api.fireworks.ai/inference" {
t.Fatalf("endpoints %q %q %q", p.Chat, p.Responses, p.Anthropic)
}
if p.KeysURL != "https://nexus.fireworks.ai/settings/api-keys" {
t.Fatalf("keys at %q", p.KeysURL)
}
if pr := Preset("fireworks-nexus"); !slices.Equal(pr.HeaderHints, []string{"x-anthropic-api-key", "x-openai-api-key"}) {
t.Fatalf("header hints %v", pr.HeaderHints)
}
asked := false
up := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
asked = true
w.Header().Set("Content-Type", "application/json")
w.Write([]byte(`{"object":"list","data":[{"id":"accounts/fireworks/models/glm-5p3","object":"model"}]}`))
}))
defer up.Close()
p.Key = "fw_test"
p.Chat, p.Responses, p.Anthropic = up.URL+"/inference/v1", up.URL+"/inference/v1", up.URL+"/inference"
for name, list := range map[string]func() ([]string, error){
"fetch": func() ([]string, error) { ms, err := p.fetch(t.Context()); return modelIDs(ms), err },
"all": func() ([]string, error) { ms, err := p.ListAll(t.Context()); return modelIDs(ms), err },
} {
got, err := list()
if err != nil {
t.Fatalf("%s: %v", name, err)
}
if !slices.Equal(got, []string{"auto"}) {
t.Fatalf("%s: models %v", name, got)
}
}
if asked {
t.Fatal("the platform's /models was asked")
}
}