omp: a Protocol row picks the API magpie's models are asked on (imty42 on X)

omp's models.yml had magpie's provider on openai-completions with no way
to change it: ompKept treated the provider's api as magpie's, so an api
typed there was written back on the next sync, and omp's row had no
protocol as Pi's has. An auto/* group whose members don't all take
Responses (provider.GroupAPI) could only be asked on Chat.

- omp's row gets the Protocol row Pi has (protocolField, now shared with
  Pi's piProtocolField): each model's own (unpicked, as before),
  openai-completions, openai-responses or anthropic-messages. omp takes
  each for the provider and a model (KnownApi in pi-catalog types.ts and
  the api enum of models-config-schema-bundle.ts, omp 18.9.1). The pick
  is kept per place and agent folder, so each profile has its own.
  `magpie omp protocol openai-responses` sets it from the CLI.
- ompOn puts the provider and every chat model on the pick: Chat and
  Responses with no api of their own and thinking mode effort; Messages
  at the gateway's root with budget, or anthropic-adaptive for a Claude
  that thinks only adaptively. Image models stay on openai-images.
- The provider's api typed into models.yml by hand now stays and shows
  as picked (ompAPIKept, the same api:<path>:wanted record as Pi's); a
  pick made after it replaces it.

Unchanged: unpicked, Responses-native models and groups whose members
all take Responses already went on openai-responses per model.

Run at this head (3d0cadfce, the same tree; only this message differs),
on mote:
- gofmt -l internal/agent: nothing. go vet ./..., GOOS=linux go vet
  -tags nogui ./..., GOOS=windows go vet ./...: rc 0. go build, linux
  nogui and windows builds: rc 0.
- go test -tags nogui -count=1 -timeout 45m ./... in a sandbox HOME
  under suite.lock: rc 0, 103 packages ok, no FAIL.
- Broken by hand: without ompAPIKept, TestOmpProtocolPicked is red
  ("an api typed by hand: file openai-completions, field \"\"").
- Real omp 18.9.1 in a sandbox HOME against a stand-in server: with the
  provider on openai-responses a group model posted to /v1/responses;
  a model on anthropic-messages at the root posted to /v1/messages.

Not tried: the GUI suite (no GUI file changed; the Protocol row is the
generic one Pi's uses, shown for any agent with a protocol field), and
omp against the real gateway with a real auto group.
Not changed: a model's api typed by hand in omp's models.yml is still
magpie's (the model list is magpie's whole); site docs for omp.
This commit is contained in:
yetone
2026-11-17 12:46:56 +08:00
parent ad585ccd6c
commit 255ccdd7ca
5 changed files with 300 additions and 10 deletions
+2 -1
View File
@@ -63,7 +63,8 @@ something else shows up as drift.
- A sync brings magpie's models up to date, not where the agent reaches magpie. Every `Sync` that `SyncCatalog` runs (each start and update of magpie, a provider added, and a plugin signed in to, out of or renewed, or listing other models than the last time: `plugin.OnChange` and `plugin.OnListed` call `catalog.Touched`, #2373) goes through `synced`, which passes each file written through `kept.away` (`edit.Filtered`, [`keptaway.go`](../../internal/agent/keptaway.go)). The filter sees every file written through `edit` while it is on, from any goroutine and under whatever lock the writer holds, so it takes none a writer may hold: the gateway's address and the LAN key are read before it is on (`keeping`), and magpie's own files (`magpieFile`: its folder as named or where its links lead, such as a `~/.config` linked into a dotfiles repo) are left as they are (ylorn on Discord: `settings.Save` under the settings' lock reached a filter that read the settings, and the app hung ~10s after every start; `TestOwnWritesDuringASyncWithALinkedConfig`). In a file without the gateway's own address, whose magpie the user pointed at an address on another machine (a NAS's, or this machine's LAN address), and with no address a WSL distro was seen at, that address stays in place of `gateway.URL()`, with the path before magpie's every URL at it had (`awayPath`: a reverse proxy's `/magpie`; on loopback, a local proxy's route where magpie answered or hasn't been asked), and so does the key that went with it in place of magpie's own (coeo91 on Discord: the base URL went back to 127.0.0.1 after an update or restart). An address on this machine's loopback follows the gateway; with more than one address or key gone, the write is left as it is. Picking a model in magpie still points the agent at this magpie, but for Claude Code at a proxy to it (above). ZCode and WorkBuddy keep such an address in their own writers too (`zcodeAddress`, `buddyWriteAt`).
- An agent whose `Sync` does nothing but bring a block of magpie's name up to the catalog is `ListOnly` (OpenCode, MiMo Code and the other OpenCode forms, Pi and its forks, Goose, Crush, Air, AtomCode, Command Code, Droid, Fx, jcode, Mistral Vibe, Kimi, MiniMax, Mothx, omp, OpenChamber, OpenClaw, OpenMausBot, Avibe, Kun, OpenPencil, Penguin, Qwen Code, T3 Code). `SyncCatalog` runs it only while the agent is connected (`Wired`), as its switch on the Agents page says: a custom provider the user named magpie in the agent, with a few models picked by hand, was written over with the whole catalog at every start (yyddbds on Discord, Xiaomi MiMo; `TestCatalogSyncLeavesAHandWrittenMagpieBlock`). A list magpie wrote while connected waits, while the agent runs a model of its own, until a model of magpie's is picked again; a model of magpie's picked by hand on a provider the user wrote doesn't connect it (`handWired`, above). Every `ListOnly` agent magpie connects reads as `Wired` (`TestListOnlyAgentsReadConnected`). Agents whose `Sync` also repairs while not connected (Codex, Claude, Grok, Hermes' bots) are not `ListOnly`. magpie keeps no copy of a list it wrote over before this, so such a list stays full until the user trims it.
- Pi's models.json (Pi, its forks and Aside) keeps an `api` the user set by hand on magpie's provider or on one of its models (`piAPIsKept` in [`pi_api_kept.go`](../../internal/agent/pi_api_kept.go)): T3 Code's Pi puts all 71 tools in the context on `openai-completions` and 3 on `openai-responses`, and a sync wrote the user's `openai-responses` back (xiaomanweiman on X). The stash records the APIs magpie wanted per file (`api:<path>:wanted`), and one in the file that is none of them is the user's; a model's keeps its `baseUrl` and `compat`, and a model left on a provider the user put on Responses gets `compat.supportsStrictMode` (#3055). With no record the provider's is taken as `openai-completions`, the only value magpie wrote there; an `api` the file lacks is magpie's. magpie's own default stays Chat for models whose provider speaks Chat, relayed as sent. `TestPiKeepsAnAPISetByHand`.
- Pi's opened row on the Agents page has a Protocol row (`piProtocolField` in [`pi_protocol.go`](../../internal/agent/pi_protocol.go), `protocolButton` in app.js; `magpie pi protocol <api>` in the CLI), in place of typing that `api` by hand (xiaomanweiman on X). It lists each model's own (unpicked, as before) and pi-ai's APIs the gateway serves (`dshAPIs`): `openai-completions`, `openai-responses` and `anthropic-messages`. A pick, kept in the stash per place (`pi.protocol`), puts the provider and every one of magpie's models on it (`piProviderOn`, `piModelOn`): on Responses each gets `compat.supportsStrictMode`, on Messages its own `api` and `baseUrl` at the gateway's root (Anthropic's SDK adds `/v1`) while the provider's stays `/v1`. An `api` the user typed on the provider still wins and shows as picked; a pick made after it records that value as magpie's (`piAPIWanted`), so the pick replaces it. Pi alone: its forks and Aside keep each model's own. With the pi-magpie extension serving the provider the row has no options and is hidden. `TestPiProtocolPicked`, `pi-protocol.test.cjs`.
- Pi's opened row on the Agents page has a Protocol row (`piProtocolField` in [`pi_protocol.go`](../../internal/agent/pi_protocol.go), `protocolButton` in app.js; `magpie pi protocol <api>` in the CLI), in place of typing that `api` by hand (xiaomanweiman on X). It lists each model's own (unpicked, as before) and pi-ai's APIs the gateway serves (`dshAPIs`): `openai-completions`, `openai-responses` and `anthropic-messages`. A pick, kept in the stash per place (`pi.protocol`), puts the provider and every one of magpie's models on it (`piProviderOn`, `piModelOn`): on Responses each gets `compat.supportsStrictMode`, on Messages its own `api` and `baseUrl` at the gateway's root (Anthropic's SDK adds `/v1`) while the provider's stays `/v1`. An `api` the user typed on the provider still wins and shows as picked; a pick made after it records that value as magpie's (`piAPIWanted`), so the pick replaces it. Pi's forks (OmO, Prime Agent) and Aside keep each model's own; omp has its own row, below. With the pi-magpie extension serving the provider the row has no options and is hidden. `TestPiProtocolPicked`, `pi-protocol.test.cjs`.
- omp's opened row has the same Protocol row (`protocolField`, shared with Pi's, in [`pi_protocol.go`](../../internal/agent/pi_protocol.go); [`omp_protocol.go`](../../internal/agent/omp_protocol.go)): its `models.yml` had the provider on `openai-completions` with no way to change it, so an `auto/*` group whose members don't all take Responses (`provider.GroupAPI`) was asked on Chat only (imty42 on X). omp takes each of the three for the provider and a model (`KnownApi`, the `api` enum of `models-config-schema-bundle.ts`, omp 18.9.1). The pick is kept per place and agent folder (`omp.protocol:<dir>`, so each profile has its own), and `ompOn` puts the provider and every chat model on it: on Chat and Responses with no `api` of its own and thinking `mode: effort`; on Messages each at the gateway's root with `budget`, or `anthropic-adaptive` for a Claude that thinks only adaptively. An image model stays on `openai-images`. The provider's `api` typed into `models.yml` by hand stays through a sync and shows as picked (`ompAPIKept`, the same `api:<path>:wanted` record as Pi's); a model's `api` stays magpie's, the model list being magpie's whole. Tried with omp 18.9.1 in a sandbox HOME: on `openai-responses` a group posted to `/v1/responses`, a model on `anthropic-messages` to `/v1/messages`. `TestOmpProtocolPicked`.
- `SyncCatalog` holds the catalog it builds (`provider.Hold`), the plugins' providers and sign-ins among it, for up to a second. Those `catalog.Touched` drops are told in the background, so a plugin change also drops what is held at once (`plugin.OnChangeNow`, [`hold.go`](../../internal/provider/hold.go)): the host's "auth" event is read before its reply to the sign-in that saved it, and a look at the accounts once the sign-in returns sees it (#2449: `magpie plugin login` found no account while a sync ran; `TestHeldGoesWithAPluginChange`).
- JetBrains Air's `magpie-opencode.json` keeps user-added fields in `provider.magpie`, including nested options, on sync and model picks (`air` in [`air.go`](../../internal/agent/air.go), using `theirsKept` in [`sync.go`](../../internal/agent/sync.go)). The gateway fields and complete model list are still replaced, so removed models leave the list.
- Air comes in two forms that read different files, both wired by `airAt` in [`air.go`](../../internal/agent/air.go). The Air app (`air`) reads `acp.json` in its own config folder. The Air plugin in JetBrains IDEs (`air-ide`; bundled from 2026.3, from Marketplace in 2026.2) reads `~/.jetbrains/acp.json` on every system, the file AI Assistant's custom agents are in too (`AcpConfigurationLoader` in the plugin's `intellij.air.backend.acp.runtime`, checked in air-plugin 262.8665.521). Each gets its own Magpie entry and `magpie-opencode.json` beside its `acp.json`. `air-ide` shows for an IDE config folder of 2026.2 or later, or with its entry already there (`TestAirIDEDetectedByIDEVersion`). Neither has a base URL for its own agents (JetBrains AI, the agent's login, or an Anthropic, OpenAI, Gemini or OpenRouter key); The plugin's Codex on its own login runs this computer's `codex` (the terminal's `PATH`, else the `@openai/codex` it installs) as `codex app-server` with the user's `CODEX_HOME` or `~/.codex`, and sets no `model_provider` (`CodexAppServerProcessKt`); its menu is Codex's `model/list` and its default `config/read`'s model. Its Claude Agent runs `claude` with only Air's hooks in `--settings`. So both go through magpie while Codex and Claude Code are connected here. The Air app's Codex runs with a `CODEX_HOME` of its own and JetBrains' gateway (`codexRuntimeEnvironment`, `[model_providers.air-gateway]`), and never does. The model on either Air row is the Magpie agent's alone, and the opened row says which of Air's own agents go through magpie (`airSaid` in `app.js`, `agent-air-own.test.cjs`; jumy_18634 on Discord).
+13 -3
View File
@@ -199,8 +199,6 @@ func ompIn(at place) *Agent {
// ompAt is omp with its agent folder at dir, magpie's entry in its
// models.yml being entry's.
func ompAt(at place, dir string, entry func() ompProviderEntry) *Agent {
// magpie's entry laid over the one in the models file at path (ompKept)
ompProvider := func(path string) any { return ompKept(path, entry()) }
// omp reads the .yml and falls back to the .yaml
pick := func(name string) string {
yml := filepath.Join(dir, name+".yml")
@@ -209,6 +207,13 @@ func ompAt(at place, dir string, entry func() ompProviderEntry) *Agent {
}
return yml
}
// the protocol picked in its row (omp_protocol.go)
protocol := ompProtocolKey(at, dir)
// magpie's entry, on the protocol picked, laid over the one in the
// models file at path (ompKept), an api the user typed there kept
ompProvider := func(path string) any {
return ompKept(path, ompAPIKept(path, ompOn(entry(), ompProtocol(protocol))))
}
path := pick("config")
// the entries of enabledModels a sync took out (scope_gone.go)
gone := at.key("omp.scope.gone")
@@ -574,7 +579,12 @@ func ompAt(at place, dir string, entry func() ompProviderEntry) *Agent {
return edit.SetYAML(path, edit.KV{Path: "defaultThinkingLevel", Value: v})
},
Options: func(map[string]string) []Option { return static(append([]string{"auto"}, ompEfforts...)...) },
}), ompAdvisorFields(path)...),
}), append(ompAdvisorFields(path), protocolField(at, protocol, pick("models"), func() (string, bool) {
models := pick("models")
v, _ := edit.GetYAML(models, "providers."+magpieID+".api")
_, has := edit.GetYAMLText(models, "providers."+magpieID)
return v, has
}, writeMagpie, func() bool { return false }))...),
}
}
+109
View File
@@ -0,0 +1,109 @@
package agent
import (
"encoding/json"
"slices"
"strings"
"github.com/yetone/magpie/internal/edit"
"github.com/yetone/magpie/internal/gateway"
)
// The protocol omp asks magpie's models on, picked in omp's row as Pi's is
// (pi_protocol.go; imty42 on X). Unpicked, magpie's provider in models.yml
// is on openai-completions and each model on the API its provider serves
// natively (ompProviderAt): a group whose members don't all take Responses
// stays on Chat (provider.GroupAPI), and an api typed into models.yml was
// written over on the next sync, so an omp that wanted every model on
// Responses had no way to get there. omp takes each of piProtocols for its
// provider and its models (KnownApi in pi-catalog types.ts, the api enum of
// models-config-schema-bundle.ts, omp 18.9.1), and the gateway serves every
// model on each. A pick puts every chat model on it; the provider's api
// typed into models.yml by hand stays (ompKept) and shows, until a pick is
// made after it.
// ompProtocolKey is where the stash keeps the protocol picked for the omp
// whose agent folder is dir at a place, "" for each model's own: each
// profile is an omp of its own.
func ompProtocolKey(at place, dir string) string { return at.key("omp.protocol") + ":" + dir }
// ompProtocol is the protocol picked for the omp at key.
func ompProtocol(key string) string {
if v := stashShared()[key]; slices.Contains(piProtocols, v) {
return v
}
return ""
}
// ompOn is magpie's entry e with every chat model asked on the api on, as
// it is for "". On anthropic-messages a model names the gateway's root, as
// omp adds the /v1 the provider's baseUrl has, and thinks as ompProviderAt
// has a Messages model think; on Chat and Responses it is asked an effort.
// An image model stays on openai-images.
func ompOn(e ompProviderEntry, on string) ompProviderEntry {
if on == "" {
return e
}
gw := strings.TrimSuffix(e.BaseURL, "/v1")
e.API = on
e.Models = slices.Clone(e.Models)
for i := range e.Models {
m := &e.Models[i]
if m.Kind != "" {
continue
}
m.API, m.BaseURL = "", ""
mode := "effort"
if on == "anthropic-messages" {
m.API, m.BaseURL = on, gw
mode = "budget"
if gateway.AdaptiveThinking(m.ID) {
mode = "anthropic-adaptive"
}
}
if m.Thinking != nil {
th := *m.Thinking
th.Mode = mode
m.Thinking = &th
}
}
return e
}
// ompAPIKept is e with the provider's api the user typed into the
// models.yml at path in place of magpie's, as Pi's (pi_api_kept.go): one
// that is none of the APIs magpie has written there (piAPIsWanted, only
// ever openai-completions before there was a record) is theirs. What e
// wants is recorded as magpie's. A model's api is magpie's, the list being
// magpie's whole.
func ompAPIKept(path string, e ompProviderEntry) ompProviderEntry {
want := e.API
if file, _ := edit.GetYAML(path, "providers."+magpieID+".api"); file != "" && file != want && !slices.Contains(piAPIsWanted(path), file) {
e.API = file
}
stashMu.Lock()
defer stashMu.Unlock()
m := stashLoad()
rec := map[string][]string{}
if s := m[apisWantedKey(path)]; s != "" && json.Unmarshal([]byte(s), &rec) != nil {
rec = map[string][]string{}
}
was, known := rec[piProviderAPI]
if !known {
was = []string{"openai-completions"}
}
if slices.Contains(was, want) && known {
return e
}
if !slices.Contains(was, want) {
was = append(slices.Clone(was), want)
if len(was) > outputsRemembered {
was = was[len(was)-outputsRemembered:]
}
}
rec[piProviderAPI] = was
b, _ := json.Marshal(rec)
m[apisWantedKey(path)] = string(b)
stashWrite(m)
return e
}
+147
View File
@@ -0,0 +1,147 @@
package agent
import (
"os"
"path/filepath"
"testing"
"github.com/yetone/magpie/internal/edit"
"github.com/yetone/magpie/internal/gateway"
"github.com/yetone/magpie/internal/provider"
"gopkg.in/yaml.v3"
)
// imty42 on X: omp's models.yml had magpie's provider on
// openai-completions with no way to change it — an api typed there was
// written back on the next sync, and omp's row had no protocol as Pi's
// has — so an auto group whose members don't all take Responses could
// only be asked on Chat. omp's row now picks the protocol: unpicked it is
// as before, a pick puts every chat model on it (an image model stays on
// openai-images), and an api typed into models.yml by hand stays and
// shows until a pick is made after it.
func TestOmpProtocolPicked(t *testing.T) {
home := syncHome(t)
was := ompVersion
ompVersion = func() string { return "18.9.1" }
t.Cleanup(func() { ompVersion = was })
for _, p := range []provider.Provider{
{ID: "oa", Name: "OA", Key: "k", Responses: "http://127.0.0.1:1/v1", Models: []string{"gpt-6.1-sol"}},
{ID: "an", Name: "An", Key: "k", Anthropic: "http://127.0.0.1:1", Models: []string{"claude-sonnet-5"}},
} {
if err := provider.Save(p); err != nil {
t.Fatal(err)
}
}
// a Chat-only member keeps the group on Chat unpicked
if err := provider.SaveGroup(provider.Group{ID: "mixed", Name: "Mixed", Members: []string{"oa/gpt-6.1-sol", "relay/glm-4.6"}}); err != nil {
t.Fatal(err)
}
a := omp(home)
if err := a.Field("model").Set("magpie/group/mixed"); err != nil {
t.Fatal(err)
}
models := filepath.Join(home, ".omp", "agent", "models.yml")
f := a.Field("protocol")
if f == nil {
t.Fatal("omp has no protocol field")
}
read := func() (map[string]any, map[string]map[string]any) {
t.Helper()
b, err := os.ReadFile(models)
if err != nil {
t.Fatal(err)
}
var file map[string]any
if err := yaml.Unmarshal(b, &file); err != nil {
t.Fatal(err)
}
pm := file["providers"].(map[string]any)["magpie"].(map[string]any)
ms := map[string]map[string]any{}
for _, raw := range pm["models"].([]any) {
m := raw.(map[string]any)
ms[m["id"].(string)] = m
}
return pm, ms
}
gw := gateway.URL()
sync := func() {
t.Helper()
if err := a.Sync(); err != nil {
t.Fatal(err)
}
}
// unpicked: as before
pm, ms := read()
if v := f.Get(); v != "" || pm["api"] != "openai-completions" {
t.Fatalf("unpicked: field %q, provider api %v", v, pm["api"])
}
if ms["group/mixed"]["api"] != nil || ms["oa/gpt-6.1-sol"]["api"] != "openai-responses" || ms["an/claude-sonnet-5"]["api"] != "anthropic-messages" {
t.Fatalf("unpicked models: %v", ms)
}
// Responses: the provider's, every chat model on it with no api of its own
if err := f.Set("openai-responses"); err != nil {
t.Fatal(err)
}
sync()
pm, ms = read()
if pm["api"] != "openai-responses" || f.Get() != "openai-responses" {
t.Fatalf("Responses picked: provider api %v, field %q", pm["api"], f.Get())
}
for id, m := range ms {
if m["kind"] != nil {
continue
}
if m["api"] != nil || m["baseUrl"] != nil {
t.Errorf("%s on Responses has api %v at %v of its own", id, m["api"], m["baseUrl"])
}
if th, _ := m["thinking"].(map[string]any); th != nil && th["mode"] != "effort" {
t.Errorf("%s on Responses thinks %v", id, th["mode"])
}
}
// Messages: each at the gateway's root
if err := f.Set("anthropic-messages"); err != nil {
t.Fatal(err)
}
pm, ms = read()
for _, id := range []string{"group/mixed", "oa/gpt-6.1-sol", "an/claude-sonnet-5"} {
if ms[id]["api"] != "anthropic-messages" || ms[id]["baseUrl"] != gw {
t.Errorf("%s on Messages: %v at %v", id, ms[id]["api"], ms[id]["baseUrl"])
}
}
if pm["baseUrl"] != gw+"/v1" {
t.Fatalf("provider baseUrl %v", pm["baseUrl"])
}
// back to each model's own
if err := f.Set(""); err != nil {
t.Fatal(err)
}
pm, ms = read()
if pm["api"] != "openai-completions" || ms["oa/gpt-6.1-sol"]["api"] != "openai-responses" || ms["group/mixed"]["api"] != nil {
t.Fatalf("each model's own: provider %v, models %v", pm["api"], ms)
}
// typed by hand: it stays through a sync, and shows
if err := edit.SetYAML(models, edit.KV{Path: "providers.magpie.api", Value: "openai-responses"}); err != nil {
t.Fatal(err)
}
sync()
if pm, _ = read(); pm["api"] != "openai-responses" || f.Get() != "openai-responses" {
t.Fatalf("an api typed by hand: file %v, field %q", pm["api"], f.Get())
}
// a pick after it is the newer word
if err := f.Set(""); err != nil {
t.Fatal(err)
}
sync()
if pm, _ = read(); pm["api"] != "openai-completions" || f.Get() != "" {
t.Fatalf("picked after a hand value: file %v, field %q", pm["api"], f.Get())
}
if err := f.Set("google-generative-ai"); err == nil {
t.Fatal("a protocol the gateway doesn't serve to omp was taken")
}
}
+29 -6
View File
@@ -73,15 +73,37 @@ func piProviderOn(agentID string, models []catalog.Model, gw, on string) map[str
// and off says magpie doesn't write the block (the pi-magpie extension
// serves the provider), so there is nothing to pick.
func piProtocolField(at place, modelsPath string, write func() error, off func() bool) Field {
return protocolField(at, piProtocolKey(at), modelsPath, func() (string, bool) {
v, has := edit.GetJSON(modelsPath, "providers."+magpieID+".api")
if _, block := edit.GetJSON(modelsPath, "providers."+magpieID); !block {
has = false
}
return v, has
}, write, off)
}
// protocolField is an agent's protocol, picked in its row and kept in the
// stash at key: the api magpie's provider has in the models file at
// modelsPath, which fileAPI reads (has: magpie's provider is in the file).
// write rewrites the provider when it is there, and off says magpie
// doesn't write it, so there is nothing to pick. Pi's (piProtocolField)
// and omp's (omp_protocol.go).
func protocolField(at place, key, modelsPath string, fileAPI func() (string, bool), write func() error, off func() bool) Field {
picked := func() string {
if v := stashShared()[key]; slices.Contains(piProtocols, v) {
return v
}
return ""
}
return Field{
Key: "protocol", Label: "protocol", Quiet: true,
Get: func() string {
picked := piProtocol(at)
picked := picked()
if at.cold {
// a stopped distro's files start it (#3896)
return picked
}
file, _ := edit.GetJSON(modelsPath, "providers."+magpieID+".api")
file, _ := fileAPI()
if file == "" {
return picked
}
@@ -89,7 +111,7 @@ func piProtocolField(at place, modelsPath string, write func() error, off func()
if want == "" {
want = "openai-completions"
}
// one the user typed there is what Pi asks on
// one the user typed there is what the agent asks on
if file != want && !slices.Contains(piAPIsWanted(modelsPath), file) {
return file
}
@@ -101,11 +123,12 @@ func piProtocolField(at place, modelsPath string, write func() error, off func()
}
// the api in the file now, the user's own included, gives way
// to the pick
if file, _ := edit.GetJSON(modelsPath, "providers."+magpieID+".api"); file != "" {
file, has := fileAPI()
if file != "" {
piAPIWanted(modelsPath, file)
}
stash(map[string]string{piProtocolKey(at): v})
if _, has := edit.GetJSON(modelsPath, "providers."+magpieID); !has || off() {
stash(map[string]string{key: v})
if !has || off() {
return nil
}
return write()