Ollama 0.35.0+ (0.40.5+ for cloud models) serves System One at
POST /v1/systemone, locally and at ollama.com with a key. Its body and
answers are System One's, so magpie's request is sent unchanged (a real
answer adds prompt_eval_cached_count, which is ignored). Its /v1/models
lists the decision models (Tev, Nimble, Clef) among the chat models with
nothing to tell them apart, so clef:27b showed up as a chat model on
Ollama Cloud. /api/tags, asked with the same key, gives each model
capabilities: "decision" (and "vision" for Clef).
- Both presets get Decide = their chat base, and a saved Ollama or
Ollama Cloud provider is backfilled with its chat base, as oMLX and
MLX-Serve are.
- ollama_decide.go: the decision list is /api/tags filtered by the
"decision" capability (ollamaDecides, listedOllamaDecide), kept under
<id>.decisions. Images come from "vision". The window is the list's
context_length, else the cloud's 65,536 from Ollama's docs. An Ollama
older than System One lists no capabilities, so none, and no Jev is
made up.
- decide.go: oMLX's, MLX-Serve's and Ollama's mixed-provider checks now
share serverMarksDecisions.
- internal/gui/local_address_test.go: an Ollama added at another address
moves its decision URL with it, as oMLX's does.
- docs/subsystems/providers-accounts.md says so.
Run, at origin/main ef655acb4 plus this change:
- gofmt -l clean. go vet ./... (darwin), GOOS=linux go vet -tags nogui
./..., GOOS=windows go vet ./... all ok.
- set -o pipefail; go test -timeout 45m ./... in a sandbox HOME: every
package ok except internal/gui, where TestProviderSaveLocalPresetAtItsURLs
still expected Ollama to have no decision API. I updated it.
internal/gui alone then failed once, with the failing test's name lost
to a tail, and passed on the next run (680s), the updated test included.
That one red isn't identified and isn't filed.
- Broken by hand. Each break turned the new tests red, and each restore
turned them green:
- Ollama left out of serverMarksDecisions: tev1 kept as a chat model,
and a Jev made up.
- The backfill removed: no Decide on a saved provider.
- The capability filter removed: smollm counted as a decider.
- Fixtures are real bytes from Ollama 0.40.6 (/api/tags, /v1/models,
/v1/systemone, the 400 "does not support chat") and from
ollama.com/api/tags.
- Real use: Ollama 0.40.6 in a sandbox (own HOME, port 11545) with
tev1:0.8b and smollm:135m. magpie built with -tags nogui under a sandbox
HOME:
- provider set ... decide= was backfilled.
- refresh listed 2 models.
- provider test ollama: chat ok on smollm, decide 101 ms on tev1:0.8b.
- group add ... classifier=ollama/tev1:0.8b: the group shows the
classifier.
- Not tried: Ollama Cloud with a real key (none here, and
ollama.com/v1/systemone is 401 without one). The GUI suite was not run
because no GUI asset changed.
74 lines
2.7 KiB
Go
74 lines
2.7 KiB
Go
package gui
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"os"
|
|
"reflect"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// A local server's preset added at another address sends its URLs moved
|
|
// there (the editor's Address): it is stored as the preset's provider, as
|
|
// one added at the default is, apart from its URLs.
|
|
func TestProviderSaveLocalPresetAtItsURLs(t *testing.T) {
|
|
t.Setenv("HOME", t.TempDir())
|
|
t.Setenv("USERPROFILE", os.Getenv("HOME"))
|
|
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
|
t.Setenv("XDG_CACHE_HOME", t.TempDir())
|
|
mux := http.NewServeMux()
|
|
providerRoutes(mux, nil)
|
|
post := func(body string) {
|
|
t.Helper()
|
|
w := httptest.NewRecorder()
|
|
mux.ServeHTTP(w, httptest.NewRequest("POST", "/api/provider/save", strings.NewReader(body)))
|
|
if w.Code != 200 {
|
|
t.Fatalf("%d", w.Code)
|
|
}
|
|
}
|
|
for _, c := range []struct{ id, name, chat, responses, anthropic, decide string }{
|
|
{"ollama", "Ollama", "http://127.0.0.1:1/v1", "", "http://127.0.0.1:1", "http://127.0.0.1:1/v1"},
|
|
{"omlx", "oMLX", "http://127.0.0.1:2/v1", "http://127.0.0.1:2/v1", "http://127.0.0.1:2", "http://127.0.0.1:2/v1"},
|
|
{"lmstudio", "LM Studio", "http://127.0.0.1:3/v1", "", "", ""},
|
|
} {
|
|
// at the default, as the editor sends it with no address: no URLs
|
|
post(`{"id":"` + c.id + `","name":"` + c.name + `","preset":"` + c.id + `","key":"","new":true}`)
|
|
def, err := provider.Find(c.id)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
post(`{"id":"` + c.id + `","name":"` + c.name + `","preset":"` + c.id + `","key":"","chat":"` + c.chat + `","responses":"` + c.responses + `","anthropic":"` + c.anthropic + `","new":true}`)
|
|
moved, err := provider.Find(c.id + "-2")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if moved.Chat != c.chat || moved.Responses != c.responses || moved.Anthropic != c.anthropic {
|
|
t.Fatalf("%s at %q %q %q", c.id, moved.Chat, moved.Responses, moved.Anthropic)
|
|
}
|
|
// oMLX's and Ollama's decision API is the same server's, so it moves
|
|
// too (#1641; Nanka on Discord)
|
|
if moved.Decide != c.decide {
|
|
t.Fatalf("%s decides at %q, want %q", c.id, moved.Decide, c.decide)
|
|
}
|
|
if !moved.Ready() || moved.Key != "" {
|
|
t.Fatalf("%s not usable with no key: ready %v", c.id, moved.Ready())
|
|
}
|
|
// the same provider as the default's, but for its URLs, and its id
|
|
// and name as the second of the preset
|
|
d, m := *def, *moved
|
|
if m.Name != d.Name+" 2" {
|
|
t.Fatalf("%s named %q", c.id, m.Name)
|
|
}
|
|
d.ID, d.Chat, d.Responses, d.Anthropic, d.Decide = "", "", "", "", ""
|
|
m.ID, m.Chat, m.Responses, m.Anthropic, m.Decide = "", "", "", "", ""
|
|
d.Name, m.Name = "", ""
|
|
d.Models, m.Models = nil, nil
|
|
if d.Preset != c.id || d.Icon != c.id || !reflect.DeepEqual(d, m) {
|
|
t.Fatalf("%s moved lost its preset's: default %+v\nmoved %+v", c.id, d, m)
|
|
}
|
|
}
|
|
}
|