oMLX 0.7.1.dev1 (jundot/omlx#4315) serves decision models at POST /v1/systemone. Its /v1/models lists them among the chat models with nothing to mark them, by the alias the user gave one. Its /v1/models/status (same key) gives each model's model_type, which is "decision" for these. oMLX finds that from the checkpoint's files, so the folder's name needn't say "clef" or "openjev". A name rule would miss an aliased OpenJev, so magpie reads the status list instead. - The omlx preset has a decision base, http://localhost:8000/v1. An oMLX provider saved before this gets its chat base as one, at whatever port it was given (the same backfill Zen and OpenRouter got). - omlxDecides joins listsDecisions. fetchDecide reads /v1/models/status and keeps the decision models under <id>.decisions, each by its alias where it has one. It leaves out the ones the user hid in oMLX and keeps the window oMLX serves. Clef and OpenJev both read images, so ImageInput is set. - DecidesModel then takes them out of the agents' lists and offers them as deciders. Jev() is the first of them. A server with none (or an older oMLX) lists none, and no Jev alias is made up for it. Run: - TestOMLXDecisionModels: the fake answers with get_status's real fields. Clef-Flash by name and OpenJev under the alias "router" are deciders, the hidden Clef isn't, the chat model alone reaches agents, and RouteDecider plus AskSystemOne post "router" to /v1/systemone. Red with omlxDecides taken out of listsDecisions. - TestOMLXWithoutDecisionModels: no decision model means none, not Jev. - go test ./internal/provider, gofmt, linux and windows vet. Not tried: a real oMLX 0.7.1.dev1 with a Clef checkpoint (no Apple-silicon oMLX install here). The fixture follows the server's source at the v0.7.1.dev1 tag, not captured bytes.
69 lines
2.3 KiB
Go
69 lines
2.3 KiB
Go
package provider
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/yetone/magpie/internal/catalog"
|
|
)
|
|
|
|
// OMLXPreset is the oMLX preset's id.
|
|
const OMLXPreset = "omlx"
|
|
|
|
// oMLX (0.7.1.dev1, jundot/omlx#4315; #1641) serves decision models —
|
|
// Clef, Clef-Flash and OpenJev — at POST /v1/systemone, System One's
|
|
// questions and answers. Its /v1/models lists them among its chat models
|
|
// with nothing to tell them apart, under the alias the user gave one; its
|
|
// /v1/models/status, asked with the same key, says each model's
|
|
// model_type, "decision" for these (found by the checkpoint's files, so
|
|
// the folder's name needn't say it), beside the id and its alias. That list
|
|
// is the provider's decision models, as OpenRouter's is (listsDecisions),
|
|
// and a model it doesn't name stays a chat model.
|
|
func (p Provider) omlxDecides() bool {
|
|
return p.Preset == OMLXPreset && p.Decide != "" && !p.DecideOnly()
|
|
}
|
|
|
|
// omlxDecisions is where an oMLX server says each model's type.
|
|
func omlxDecisions(base string) string {
|
|
return strings.TrimRight(base, "/") + "/models/status"
|
|
}
|
|
|
|
// listedOMLXDecide are the decision models in oMLX's /v1/models/status,
|
|
// each by the name /v1/models gives it (its alias, if it has one) and with
|
|
// the window oMLX serves it with. One the user hid in oMLX is left out, as
|
|
// /v1/models leaves it out. Clef and OpenJev both read images.
|
|
func listedOMLXDecide(b []byte) ([]catalog.Model, error) {
|
|
var out struct {
|
|
Models *[]struct {
|
|
ID string `json:"id"`
|
|
Alias string `json:"model_alias"`
|
|
ModelType string `json:"model_type"`
|
|
EngineType string `json:"engine_type"`
|
|
Hidden bool `json:"is_hidden"`
|
|
MaxContextWindow int `json:"max_context_window"`
|
|
ContextLength int `json:"model_context_length"`
|
|
} `json:"models"`
|
|
}
|
|
if err := json.Unmarshal(b, &out); err != nil || out.Models == nil {
|
|
return nil, fmt.Errorf("not oMLX's model status")
|
|
}
|
|
ms := []catalog.Model{}
|
|
for _, m := range *out.Models {
|
|
if m.ID == "" || m.Hidden || m.ModelType != "decision" && m.EngineType != "decision" {
|
|
continue
|
|
}
|
|
id := m.ID
|
|
if m.Alias != "" {
|
|
id = m.Alias
|
|
}
|
|
images := true
|
|
ctx := m.MaxContextWindow
|
|
if ctx <= 0 {
|
|
ctx = m.ContextLength
|
|
}
|
|
ms = append(ms, catalog.Model{ID: id, Name: id, Context: ctx, ImageInput: &images, Images: true})
|
|
}
|
|
return ms, nil
|
|
}
|