gateway, gui: an added provider's embedding and rerank models are listed (@rfiacne on X)
@rfiacne asked why an added provider's embedding models aren't recognised. Routing them already worked: /v1/embeddings and /v1/rerank took a bare id, provider/id or a slashed id from the provider's fetched list. But they were nowhere a user looks. GET /v1/models answered ?kind=embedding with 400 and never listed them, and the provider editor showed only a count, and only when the provider had no chat model. - /v1/models?kind= takes embedding and rerank (all includes them). Each row is provider/model with "kind", owned_by, magpie_label and supported_endpoint_types embeddings or jina-rerank, the names Cherry Studio's new-api provider reads (listModels.ts ENDPOINT_TYPE_ALIASES). Disabled models and those a held key can't reach are left out. The default list stays chat models (TestKindGroupsServeEachAPIByRoute). Cherry Studio, listed every kind already, gets them too for its knowledge bases; ?format=text stays chat. A remote magpie asks by headers, not ?kind=, so its list is unchanged. - gateway.RetrievalModels: the fetched list's Serves models and the preset's, each id once, shared by the list and the GUI. - The provider editor lists Embedding models and Rerank models as read only chips (embedIds/rerankIds, retrievalRows), in every language. The script budgets rise by 354 for it: the editor draws it, so there is no page to move it to. - docs: integrating.md, the site's integrate page (en, zh), and providers-accounts.md; site/node docs-index.mjs rebuilt llms-full.txt and search/*.json for them. Run on mote (load ~20-28 of 18 cores; mica was at 40 of 12), at 6ce8f232c, rebased on origin/main6635dec7c: - go test -tags nogui -run 'TestAddedProvidersRetrievalModelsListed| TestRetrievalModelsOnce|TestKindGroupsServeEachAPIByRoute|Kind|Cherry| Models' ./internal/gateway: ok. TestAddedProvidersRetrievalModelsListed is red on the old gateway.go (?kind=embedding,rerank: 400). - go test -tags nogui -run 'Budget|Provider' ./internal/gui: ok (before the rebase; the budget was re-measured after it, at exactly the new numbers). - node --test provider-retrieval-rows and provider-retrieval-only, both engines, 5 languages, 900 and 420 px: 46 pass. provider-retrieval-rows is red on the old app.js (no rows). - gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui ./...: ok. - After the rebase on origin/main3c9d79d28and again on70a881071: the tests above plus TestCoreScriptBudget, TestTogetherLiveList and TestModelsListMediaOnlyWhenAsked in gateway, gui and provider: ok (testenv's docs-index check passes after the rebuild). - The full go test -tags nogui -timeout 45m ./... was stopped before it ended, not run to the end (owner: never hold a verified fix behind a full suite). Not tried: a real provider's live list in the app; the whole GUI suite (1636 files); OpenRouter, whose embedding models are on a separate /api/v1/embeddings/models list that magpie doesn't fetch.
This commit is contained in:
+7
-6
@@ -61,12 +61,13 @@ it takes images. List them from there rather than shipping a list: the
|
||||
user adds and removes providers in magpie. Reasoning is asked in your
|
||||
API's own field (`reasoning_effort`, `reasoning.effort`, Anthropic's
|
||||
`thinking` or `output_config.effort`). `?format=text` gives the ids one a
|
||||
line. The list holds chat models only. Ask for image and video models
|
||||
with `?kind=image,video` (or `?kind=chat,image,video`, or `?kind=all`).
|
||||
Each of them is marked `"kind": "image"` or `"kind": "video"` and goes to
|
||||
`/v1/images/generations` or `/v1/videos`, never to a chat route. Cherry
|
||||
Studio, which can't ask and tells an image model from a chat one by its
|
||||
id, is listed every kind.
|
||||
line. The list holds chat models only. Ask for image, video, embedding
|
||||
and rerank models with `?kind=image,video,embedding,rerank` (or
|
||||
`?kind=chat,image`, any of them, or `?kind=all`). Each of them is marked
|
||||
`"kind": "image"`, `"video"`, `"embedding"` or `"rerank"` and goes to
|
||||
`/v1/images/generations`, `/v1/videos`, `/v1/embeddings` or `/v1/rerank`,
|
||||
never to a chat route. Cherry Studio, which can't ask and tells an image
|
||||
or embedding model from a chat one by its id, is listed every kind.
|
||||
|
||||
**A vendor's own fields.** `/v1/images/generations` and `/v1/videos`
|
||||
take OpenAI's fields and pass the others on to a vendor that takes them:
|
||||
|
||||
@@ -108,12 +108,22 @@ bases from one address (`remoteMagpieEndpoints` in
|
||||
list requests images, videos and decisions with `X-Magpie-Drawers`,
|
||||
`X-Magpie-Videomakers` and `X-Magpie-Deciders`. The gateway includes these
|
||||
only when asked, with `kind` of `image`, `video` or `decision`. Any other
|
||||
client asks for image and video models with `?kind=` (`chat`, `image`,
|
||||
`video`, comma separated, or `all`; `listKinds` in
|
||||
client asks for image, video, embedding and rerank models with `?kind=`
|
||||
(`chat`, `image`, `video`, `embedding`, `rerank`, comma separated, or
|
||||
`all`; `listKinds` in
|
||||
[`gateway.go`](../../internal/gateway/gateway.go)); without it the list is
|
||||
chat models alone, so no agent's chat picker offers an image or video
|
||||
model, and an unknown kind is a 400 (axelburks on Discord;
|
||||
`TestModelsListMediaOnlyWhenAsked`). Decision
|
||||
`TestModelsListMediaOnlyWhenAsked`). Embedding and rerank entries are
|
||||
`retrievalObjects`: every on provider's `RetrievalModels` (its fetched
|
||||
list's `Serves` models and its preset's), as `provider/model`, with
|
||||
`supported_endpoint_types` `embeddings` or `jina-rerank`, less disabled
|
||||
models and those a held key can't reach. Cherry Studio, which can't ask,
|
||||
gets every kind; a remote magpie asks by its headers, not `?kind=`, so
|
||||
its list is unchanged (@rfiacne on X;
|
||||
`TestAddedProvidersRetrievalModelsListed`). A provider's editor lists the
|
||||
same models read only, as Embedding models and Rerank models
|
||||
(`embedIds`/`rerankIds`, `retrievalRows` in app.js). Decision
|
||||
entries pass through `keyAllowed`, including model and account restrictions.
|
||||
[`catalog/live.go`](../../internal/catalog/live.go) keeps each kind and all
|
||||
models the remote already exposed, including retrieval models. The shared
|
||||
|
||||
+88
-27
@@ -1727,6 +1727,48 @@ func videomakerObjects(r *http.Request) []map[string]any {
|
||||
return out
|
||||
}
|
||||
|
||||
// retrievalObjects are the embedding or rerank models, kind's, that
|
||||
// magpie serves on /v1/embeddings or /v1/rerank (RetrievalModels), as a
|
||||
// client asks for them (?kind=embedding,rerank, listKinds): "kind":
|
||||
// "embedding" or "rerank", each provider's by "provider/model", the id
|
||||
// either route takes. supported_endpoint_types is new-api's word for the
|
||||
// route, which Cherry Studio's new-api provider reads the model's kind
|
||||
// from (listModels.ts ENDPOINT_TYPE_ALIASES: "embeddings",
|
||||
// "jina-rerank"). Models disabled in magpie are left out, and a gateway
|
||||
// key held to some models or accounts is told of those alone, as its
|
||||
// chat list is (#2579).
|
||||
func retrievalObjects(r *http.Request, kind string) []map[string]any {
|
||||
who, held := keyListHolds(r)
|
||||
path, ends := "/v1/embeddings", []string{"embeddings"}
|
||||
if kind == catalog.ServesRerank {
|
||||
path, ends = "/v1/rerank", []string{"jina-rerank"}
|
||||
}
|
||||
var out []map[string]any
|
||||
for _, p := range provider.All() {
|
||||
if !p.On() || p.DecideOnly() {
|
||||
continue
|
||||
}
|
||||
for _, m := range RetrievalModels(p, kind) {
|
||||
if _, off := modelOff(p, m.ID, p.ID+"/"+m.ID); off {
|
||||
continue
|
||||
}
|
||||
if held && (!modelAllowed(who, p, m.ID) || !accountServes(who, p, m.ID)) {
|
||||
continue
|
||||
}
|
||||
name := cmp.Or(m.Name, m.ID)
|
||||
o := map[string]any{"id": p.ID + "/" + m.ID, "object": "model", "type": "model", "kind": kind, "created": 0,
|
||||
"owned_by": p.ID, "display_name": name, "magpie_label": name + " · " + p.Name,
|
||||
"native_endpoints": []string{path}, "supported_endpoint_types": ends,
|
||||
"magpie_via": catalog.ViaHere(m.Via)}
|
||||
if m.Context > 0 {
|
||||
o["context_window"] = m.Context
|
||||
}
|
||||
out = append(out, o)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// viaOf is the magpies e's model passes through after this one, as the
|
||||
// remote magpie serving it listed them; nil for a provider's own model.
|
||||
// A routing group's are its members' together: a group with a remote
|
||||
@@ -1758,49 +1800,61 @@ func catalogFor(r *http.Request) []provider.Entry {
|
||||
|
||||
// listKinds is which of magpie's models a /v1/models call lists: its chat
|
||||
// models alone, unless it names the kinds it wants in ?kind= (chat, image,
|
||||
// video, comma separated; all for the three). Image and video models are
|
||||
// listed only when asked for, each marked "kind" (drawerObjects,
|
||||
// videomakerObjects): OpenAI's own list puts gpt-image and sora among its
|
||||
// chat models with nothing to tell them apart, and the clients and agents
|
||||
// that offer every id this list gives as a model to chat with (OpenCode's,
|
||||
// Cherry Studio's, ZCode's pasted ?format=text) would offer an image model
|
||||
// in their chat pickers (axelburks on Discord asked for them here). A kind
|
||||
// it doesn't know is refused, not read as none.
|
||||
// video, embedding, rerank, comma separated; all for every one). The
|
||||
// others are listed only when asked for, each marked "kind"
|
||||
// (drawerObjects, videomakerObjects, retrievalObjects): OpenAI's own list
|
||||
// puts gpt-image and sora among its chat models with nothing to tell them
|
||||
// apart, and the clients and agents that offer every id this list gives
|
||||
// as a model to chat with (OpenCode's, Cherry Studio's, ZCode's pasted
|
||||
// ?format=text) would offer an image or embedding model in their chat
|
||||
// pickers (axelburks on Discord asked for image and video models here,
|
||||
// @rfiacne on X for embedding ones). A kind it doesn't know is refused,
|
||||
// not read as none.
|
||||
//
|
||||
// Cherry Studio is the exception: it can't ask, and it tells an image model
|
||||
// from a chat one itself. Its provider of magpie (an OpenAI-compatible one)
|
||||
// reads only each id, then looks the id's last segment up in its own model
|
||||
// registry (provider-registry's models.json, by normalizeModelId), which
|
||||
// marks gpt-image-2, dall-e-3, the gemini-*-image, imagen, seedream and
|
||||
// grok-imagine models as image generation: those go to its Paintings page,
|
||||
// not its chat picker (isNonChatModel). Without them listed, Paintings had
|
||||
// no model of magpie's (pingqipai3 on X). So it is listed every kind.
|
||||
func listKinds(r *http.Request) (chat, image, video bool, err error) {
|
||||
// Cherry Studio is the exception: it can't ask, and it tells an image
|
||||
// model from a chat one itself. Its provider of magpie (an
|
||||
// OpenAI-compatible one) reads only each id, then looks the id's last
|
||||
// segment up in its own model registry (provider-registry's models.json,
|
||||
// by normalizeModelId), which marks gpt-image-2, dall-e-3, the
|
||||
// gemini-*-image, imagen, seedream and grok-imagine models as image
|
||||
// generation: those go to its Paintings page, not its chat picker
|
||||
// (isNonChatModel), and its embedding and rerank models (text-embedding-3,
|
||||
// bge-m3, Qwen3-Embedding, bge-reranker) to its knowledge bases. Without
|
||||
// them listed, Paintings had no model of magpie's (pingqipai3 on X). So it
|
||||
// is listed every kind.
|
||||
func listKinds(r *http.Request) (k listKind, err error) {
|
||||
q, ok := r.URL.Query()["kind"]
|
||||
if !ok {
|
||||
// a list of ids pasted somewhere (?format=text) stays chat models
|
||||
media := cherryStudio(r) && r.URL.Query().Get("format") != "text"
|
||||
return true, media, media, nil
|
||||
return listKind{chat: true, image: media, video: media, embedding: media, rerank: media}, nil
|
||||
}
|
||||
for _, v := range q {
|
||||
for k := range strings.SplitSeq(v, ",") {
|
||||
switch strings.ToLower(strings.TrimSpace(k)) {
|
||||
for kind := range strings.SplitSeq(v, ",") {
|
||||
switch strings.ToLower(strings.TrimSpace(kind)) {
|
||||
case "chat":
|
||||
chat = true
|
||||
k.chat = true
|
||||
case "image":
|
||||
image = true
|
||||
k.image = true
|
||||
case "video":
|
||||
video = true
|
||||
k.video = true
|
||||
case "embedding":
|
||||
k.embedding = true
|
||||
case "rerank":
|
||||
k.rerank = true
|
||||
case "all":
|
||||
chat, image, video = true, true, true
|
||||
k = listKind{true, true, true, true, true}
|
||||
default:
|
||||
return false, false, false, fmt.Errorf("kind %q: /v1/models lists the kinds chat, image and video (or all), comma separated", k)
|
||||
return listKind{}, fmt.Errorf("kind %q: /v1/models lists the kinds chat, image, video, embedding and rerank (or all), comma separated", kind)
|
||||
}
|
||||
}
|
||||
}
|
||||
return chat, image, video, nil
|
||||
return k, nil
|
||||
}
|
||||
|
||||
// listKind is which kinds of model a /v1/models call lists (listKinds).
|
||||
type listKind struct{ chat, image, video, embedding, rerank bool }
|
||||
|
||||
// cherryStudio is a request of Cherry Studio's: with the key magpie's link
|
||||
// gives it (agentOf), or a key the user typed in by hand, by its User-Agent,
|
||||
// Electron's own with the app's name in it ("Mozilla/5.0 (…)
|
||||
@@ -1830,7 +1884,8 @@ func (s *Server) models(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
func (s *Server) listModels(w http.ResponseWriter, r *http.Request) {
|
||||
data := []map[string]any{}
|
||||
chat, images, videos, err := listKinds(r)
|
||||
kinds, err := listKinds(r)
|
||||
chat, images, videos := kinds.chat, kinds.image, kinds.video
|
||||
if err != nil {
|
||||
writeError(w, provider.Chat, 400, err.Error())
|
||||
return
|
||||
@@ -1997,6 +2052,12 @@ func (s *Server) listModels(w http.ResponseWriter, r *http.Request) {
|
||||
if videos || r.Header.Get(provider.VideomakersHeader) != "" {
|
||||
data = append(data, videomakerObjects(r)...)
|
||||
}
|
||||
if kinds.embedding {
|
||||
data = append(data, retrievalObjects(r, catalog.ServesEmbedding)...)
|
||||
}
|
||||
if kinds.rerank {
|
||||
data = append(data, retrievalObjects(r, catalog.ServesRerank)...)
|
||||
}
|
||||
if r.Header.Get(provider.DecidersHeader) != "" {
|
||||
// the decision models its own pickers offer: of a provider with
|
||||
// picks (OpenRouter's twenty-odd), the picked ones, so another
|
||||
|
||||
@@ -80,6 +80,21 @@ func servesKind(kind string) func(p provider.Provider, model string) bool {
|
||||
}
|
||||
}
|
||||
|
||||
// RetrievalModels are the embedding or rerank models, kind's, p serves
|
||||
// on /v1/embeddings or /v1/rerank by their own ids: those its fetched
|
||||
// list says are of that API (catalog.LiveServing), then those its preset
|
||||
// names (PlanRetrieval), each id once. They need no pick: the routes take
|
||||
// them as listed.
|
||||
func RetrievalModels(p provider.Provider, kind string) []catalog.Model {
|
||||
ms := slices.Clone(catalog.LiveServing(p.ID, kind))
|
||||
for _, m := range p.PlanRetrieval(kind) {
|
||||
if !slices.ContainsFunc(ms, func(x catalog.Model) bool { return x.ID == m.ID }) {
|
||||
ms = append(ms, m)
|
||||
}
|
||||
}
|
||||
return ms
|
||||
}
|
||||
|
||||
// retrievalKind is the kind of model an operation of serveRetrieval's is
|
||||
// asked of.
|
||||
func retrievalKind(operation string) string {
|
||||
|
||||
@@ -98,7 +98,7 @@ func TestModelsListMediaOnlyWhenAsked(t *testing.T) {
|
||||
if _, body := get("/v1/models?kind=image&format=text", nil); !strings.Contains(body, image) || strings.Contains(body, video) {
|
||||
t.Fatalf("kind=image&format=text:\n%s", body)
|
||||
}
|
||||
for _, bad := range []string{"images", "embedding", "", "chat,"} {
|
||||
for _, bad := range []string{"images", "embeddings", "moderation", "", "chat,"} {
|
||||
if code, body := get("/v1/models?kind="+bad, nil); code != 400 {
|
||||
t.Errorf("kind=%q: %d %s", bad, code, body)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
package gateway
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/yetone/magpie/internal/catalog"
|
||||
"github.com/yetone/magpie/internal/provider"
|
||||
)
|
||||
|
||||
// A provider the user added lists its embedding and rerank models where a
|
||||
// client looks for them: /v1/models?kind=embedding,rerank, each as
|
||||
// provider/model with its kind and route, and Cherry Studio, which can't
|
||||
// ask, sees them by default. The default list stays chat models
|
||||
// (TestKindGroupsServeEachAPIByRoute). Before, /v1/models refused
|
||||
// ?kind=embedding and no list had them (@rfiacne on X: an added
|
||||
// provider's embedding models weren't recognised).
|
||||
func TestAddedProvidersRetrievalModelsListed(t *testing.T) {
|
||||
fresh(t)
|
||||
// SiliconFlow's /v1/models, the shape of its docs' example
|
||||
up := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
if r.URL.Path == "/v1/embeddings" {
|
||||
io.WriteString(w, `{"object":"list","data":[{"object":"embedding","index":0,"embedding":[0.5,0.25]}],"model":"BAAI/bge-m3","usage":{"prompt_tokens":1,"total_tokens":1}}`)
|
||||
return
|
||||
}
|
||||
io.WriteString(w, `{"object":"list","data":[`+
|
||||
`{"id":"deepseek-ai/DeepSeek-V3","object":"model","created":0,"owned_by":""},`+
|
||||
`{"id":"BAAI/bge-m3","object":"model","created":0,"owned_by":""},`+
|
||||
`{"id":"Qwen/Qwen3-Embedding-8B","object":"model","created":0,"owned_by":""},`+
|
||||
`{"id":"BAAI/bge-reranker-v2-m3","object":"model","created":0,"owned_by":""}]}`)
|
||||
}))
|
||||
defer up.Close()
|
||||
saveFetched(t, provider.Provider{ID: "sf", Name: "SiliconFlow", Chat: up.URL + "/v1", Key: "k", Models: []string{"deepseek-ai/DeepSeek-V3"}})
|
||||
s := New()
|
||||
|
||||
list := func(q, ua string) (int, map[string]string) {
|
||||
t.Helper()
|
||||
r := httptest.NewRequest("GET", "/v1/models"+q, nil)
|
||||
if ua != "" {
|
||||
r.Header.Set("User-Agent", ua)
|
||||
}
|
||||
w := httptest.NewRecorder()
|
||||
s.Handler().ServeHTTP(w, r)
|
||||
var got struct {
|
||||
Data []map[string]any `json:"data"`
|
||||
}
|
||||
json.Unmarshal(w.Body.Bytes(), &got)
|
||||
kinds := map[string]string{}
|
||||
for _, m := range got.Data {
|
||||
id, _ := m["id"].(string)
|
||||
k, _ := m["kind"].(string)
|
||||
kinds[id] = k
|
||||
if k == "embedding" || k == "rerank" {
|
||||
ends, _ := m["supported_endpoint_types"].([]any)
|
||||
want := map[string]string{"embedding": "embeddings", "rerank": "jina-rerank"}[k]
|
||||
if len(ends) != 1 || ends[0] != want {
|
||||
t.Fatalf("%s: supported_endpoint_types %v, want [%s]", id, ends, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
return w.Code, kinds
|
||||
}
|
||||
|
||||
want := map[string]string{"sf/BAAI/bge-m3": "embedding", "sf/Qwen/Qwen3-Embedding-8B": "embedding", "sf/BAAI/bge-reranker-v2-m3": "rerank"}
|
||||
code, got := list("?kind=embedding,rerank", "")
|
||||
if code != 200 {
|
||||
t.Fatalf("?kind=embedding,rerank: %d", code)
|
||||
}
|
||||
for id, k := range want {
|
||||
if got[id] != k {
|
||||
t.Fatalf("?kind=embedding,rerank: %s is %q, want %q: %v", id, got[id], k, got)
|
||||
}
|
||||
}
|
||||
if len(got) != len(want) {
|
||||
t.Fatalf("?kind=embedding,rerank lists more than its kinds: %v", got)
|
||||
}
|
||||
if _, got := list("?kind=rerank", ""); len(got) != 1 || got["sf/BAAI/bge-reranker-v2-m3"] != "rerank" {
|
||||
t.Fatalf("?kind=rerank: %v", got)
|
||||
}
|
||||
_, got = list("?kind=all", "")
|
||||
for id, k := range want {
|
||||
if got[id] != k {
|
||||
t.Fatalf("?kind=all: %s is %q: %v", id, got[id], got)
|
||||
}
|
||||
}
|
||||
// Cherry Studio is listed every kind; its knowledge bases take these
|
||||
_, got = list("", "CherryStudio/1.6.0")
|
||||
for id, k := range want {
|
||||
if got[id] != k {
|
||||
t.Fatalf("Cherry Studio: %s is %q: %v", id, got[id], got)
|
||||
}
|
||||
}
|
||||
// the default stays the models agents chat with
|
||||
_, got = list("", "")
|
||||
for id := range got {
|
||||
if strings.Contains(strings.ToLower(id), "bge") || strings.Contains(id, "Embedding") {
|
||||
t.Fatalf("the default /v1/models lists %s", id)
|
||||
}
|
||||
}
|
||||
// the id it lists is one the route takes
|
||||
if code, raw := postRetrieval(t, s, "/v1/embeddings", `{"model":"sf/BAAI/bge-m3","input":"hi"}`); code != 200 || !strings.Contains(raw, `[0.5,0.25]`) {
|
||||
t.Fatalf("embeddings by the listed id: %d %s", code, raw)
|
||||
}
|
||||
|
||||
// a model disabled in magpie is left out
|
||||
if err := provider.DisableModels("sf/BAAI/bge-m3"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, got := list("?kind=embedding", ""); got["sf/BAAI/bge-m3"] != "" || got["sf/Qwen/Qwen3-Embedding-8B"] != "embedding" {
|
||||
t.Fatalf("with bge-m3 disabled: %v", got)
|
||||
}
|
||||
if code, _ := list("?kind=moderation", ""); code != 400 {
|
||||
t.Fatalf("an unknown kind: %d, want 400", code)
|
||||
}
|
||||
}
|
||||
|
||||
// RetrievalModels names each model once, its fetched list's and its
|
||||
// preset's together.
|
||||
func TestRetrievalModelsOnce(t *testing.T) {
|
||||
fresh(t)
|
||||
up := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
io.WriteString(w, `{"data":[{"id":"gpt-5.5"},{"id":"text-embedding-3-small"},{"id":"text-embedding-3-small"}]}`)
|
||||
}))
|
||||
defer up.Close()
|
||||
p := saveFetched(t, provider.Provider{ID: "oa", Name: "Relay", Chat: up.URL + "/v1", Key: "k", Models: []string{"gpt-5.5"}})
|
||||
var ids []string
|
||||
for _, m := range RetrievalModels(p, catalog.ServesEmbedding) {
|
||||
ids = append(ids, m.ID)
|
||||
}
|
||||
if !slices.Equal(ids, []string{"text-embedding-3-small"}) {
|
||||
t.Fatalf("embedding models %v", ids)
|
||||
}
|
||||
}
|
||||
@@ -4098,6 +4098,7 @@ body:not(.side-nav) #addSheet > .row-head.stuck::before { opacity: 1; box-shadow
|
||||
transition: background .12s, color .12s, border-color .12s;
|
||||
}
|
||||
.mchip:hover { color: var(--fg); border-color: var(--muted); }
|
||||
.mchips.still .mchip:hover { color: var(--muted); border-color: var(--line); }
|
||||
.mchip.on { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); font-weight: 500; }
|
||||
.mchip.on::before { content: "✓"; font-size: 10px; }
|
||||
/* a chip a click picks and unpicks keeps its size either way (frankdeng on
|
||||
|
||||
@@ -9778,6 +9778,7 @@ function drawEditor(p, presetID) {
|
||||
ed.append(...field(t("Models"), renderModels(p), pluginFilterNote(subOf(a.agent))));
|
||||
if (p.drawIds?.length) ed.append(...renderDrawers(p));
|
||||
if (p.filmIds?.length) ed.append(...renderVideomakers(p));
|
||||
ed.append(...retrievalRows(p));
|
||||
// the subscription's own warm-up, check-in and resets first
|
||||
// and Advanced opened when one is on, as for Routing: the user who set
|
||||
// a warm-up finds it where it went (ChrisYagao on X: "我的预热去哪里了")
|
||||
@@ -10307,6 +10308,7 @@ function drawEditor(p, presetID) {
|
||||
else if (pr?.id === "azure") ed.append(...field(t("Models"), el("div", "hint azure-models", t("No need to type them: once added, magpie lists the deployments this key can call. Type a deployment's name as a model id only if that list can't be fetched.")), ""));
|
||||
if (p?.drawIds?.length) ed.append(...renderDrawers(p));
|
||||
if (p?.filmIds?.length) ed.append(...renderVideomakers(p));
|
||||
ed.append(...retrievalRows(p));
|
||||
{
|
||||
// the window agents are told a model has, over what the vendor or
|
||||
// models.dev says: one for all of them, and model=size for one
|
||||
@@ -12380,6 +12382,18 @@ function renderVideomakers(p) {
|
||||
return field(t("Video models"), mediaChips("mchips videomakers", p.filmIds, "hiddenVideomakers", p), t("Only the ticked ones are offered when making a video. Agents don't chat with these, so they aren't among its models."));
|
||||
}
|
||||
|
||||
// retrievalRows: its embedding and rerank models, which need no pick and
|
||||
// aren't among its models since agents don't chat with them: they were
|
||||
// nowhere to be seen (@rfiacne on X)
|
||||
function retrievalRows(p) {
|
||||
return [["Embedding models", p?.embedIds], ["Rerank models", p?.rerankIds]].flatMap(([l, v]) => {
|
||||
if (!v) return [];
|
||||
const d = el("div", "mchips still");
|
||||
d.append(...v.map((id) => el("span", "mchip", id)));
|
||||
return field(t(l), d);
|
||||
});
|
||||
}
|
||||
|
||||
function mediaChips(cls, ids, key, p, names) {
|
||||
const chips = el("div", cls);
|
||||
draft[key] ||= [...(p[key] || [])];
|
||||
|
||||
@@ -2019,6 +2019,8 @@ const I18N = {
|
||||
"Image models": "图像模型",
|
||||
"Settings › Models › Images lists the ticked ones. Agents don't chat with these, so they aren't among its models.": "设置 › 模型 › 图像 只列出已勾选的。Agent 不与它们对话,故不在模型列表中。",
|
||||
"Video models": "视频模型",
|
||||
"Embedding models": "嵌入模型",
|
||||
"Rerank models": "重排序模型",
|
||||
"Only the ticked ones are offered when making a video. Agents don't chat with these, so they aren't among its models.": "生成视频时只提供已勾选的。Agent 不与它们对话,故不在模型列表中。",
|
||||
"{model}, picked here, is unticked in its provider's Image models: it still draws, but leaves this list once another is picked. Tick it there to keep it listed.": "{model} 是此处选中的,但在其供应商的“图像模型”中未勾选:它仍用于生图,改选其他模型后便不再列在这里。在那里勾选它即可留在列表中。",
|
||||
"no models exposed": "未暴露模型",
|
||||
@@ -7539,6 +7541,8 @@ const I18N = {
|
||||
"Image models": "影像模型",
|
||||
"Settings › Models › Images lists the ticked ones. Agents don't chat with these, so they aren't among its models.": "設定 › 模型 › 影像 只列出已勾選的。Agent 不與它們對話,故不在模型列表中。",
|
||||
"Video models": "影片模型",
|
||||
"Embedding models": "嵌入模型",
|
||||
"Rerank models": "重排序模型",
|
||||
"Only the ticked ones are offered when making a video. Agents don't chat with these, so they aren't among its models.": "生成影片時只提供已勾選的。Agent 不與它們對話,故不在模型列表中。",
|
||||
"{model}, picked here, is unticked in its provider's Image models: it still draws, but leaves this list once another is picked. Tick it there to keep it listed.": "{model} 是此處選取的,但在其供應商的「影像模型」中未勾選:它仍用於生圖,改選其他模型後便不再列在這裡。在那裡勾選它即可留在列表中。",
|
||||
"no models exposed": "未暴露模型",
|
||||
@@ -13026,6 +13030,8 @@ const I18N = {
|
||||
"Image models": "画像モデル",
|
||||
"Settings › Models › Images lists the ticked ones. Agents don't chat with these, so they aren't among its models.": "設定 › モデル › 画像 にはチェックしたものだけが表示されます。エージェントはこれらと会話しないため、モデル一覧には含まれません。",
|
||||
"Video models": "動画モデル",
|
||||
"Embedding models": "埋め込みモデル",
|
||||
"Rerank models": "リランクモデル",
|
||||
"Only the ticked ones are offered when making a video. Agents don't chat with these, so they aren't among its models.": "動画を作るときは、チェックしたものだけが候補になります。エージェントはこれらと会話しないため、モデル一覧には含まれません。",
|
||||
"{model}, picked here, is unticked in its provider's Image models: it still draws, but leaves this list once another is picked. Tick it there to keep it listed.": "ここで選んだ {model} は、プロバイダの「画像モデル」でチェックが外されています。描画には引き続き使われますが、別のモデルを選ぶとこの一覧から消えます。一覧に残すには、そちらでチェックしてください。",
|
||||
"no models exposed": "公開されているモデルなし",
|
||||
@@ -18556,6 +18562,8 @@ const I18N = {
|
||||
"Image models": "Bildmodelle",
|
||||
"Settings › Models › Images lists the ticked ones. Agents don't chat with these, so they aren't among its models.": "Einstellungen › Modelle › Bilder listet die angehakten. Agenten chatten nicht mit diesen Modellen, daher stehen sie nicht bei seinen Modellen.",
|
||||
"Video models": "Videomodelle",
|
||||
"Embedding models": "Embedding-Modelle",
|
||||
"Rerank models": "Rerank-Modelle",
|
||||
"Only the ticked ones are offered when making a video. Agents don't chat with these, so they aren't among its models.": "Beim Erstellen eines Videos werden nur die angehakten angeboten. Agenten chatten nicht mit diesen Modellen, daher stehen sie nicht bei seinen Modellen.",
|
||||
"{model}, picked here, is unticked in its provider's Image models: it still draws, but leaves this list once another is picked. Tick it there to keep it listed.": "{model}, hier gewählt, ist bei den Bildmodellen seines Anbieters abgehakt: Es zeichnet weiter, verschwindet aber aus dieser Liste, sobald ein anderes gewählt ist. Haken Sie es dort an, damit es gelistet bleibt.",
|
||||
"no models exposed": "keine Modelle freigegeben",
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -495,6 +495,11 @@ type providerJSON struct {
|
||||
// with none listed to chat with, how many embedding and rerank models
|
||||
// it lists: served on /v1/embeddings and /v1/rerank, with no pick
|
||||
Retrieval int `json:"retrieval,omitempty"`
|
||||
// its embedding and rerank models (gateway.RetrievalModels), listed
|
||||
// apart in its editor: they need no pick, and agents don't chat with
|
||||
// them, so they aren't among Models (@rfiacne on X couldn't find them)
|
||||
EmbedIDs []string `json:"embedIds,omitempty"`
|
||||
RerankIDs []string `json:"rerankIds,omitempty"`
|
||||
// its video models (gateway.Videomakers), listed apart in its editor
|
||||
// as its image models are, and those unticked there
|
||||
// (provider.HiddenVideomakers)
|
||||
@@ -1391,13 +1396,15 @@ func providerInfoWith(p provider.Provider, ls provider.Listing, agents []agentUs
|
||||
out.Deciders = &deciders
|
||||
}
|
||||
out.Exposed = len(exposed)
|
||||
for _, m := range gateway.RetrievalModels(p, catalog.ServesEmbedding) {
|
||||
out.EmbedIDs = append(out.EmbedIDs, m.ID)
|
||||
}
|
||||
for _, m := range gateway.RetrievalModels(p, catalog.ServesRerank) {
|
||||
out.RerankIDs = append(out.RerankIDs, m.ID)
|
||||
}
|
||||
if len(out.Models) == 0 {
|
||||
// a vendor of embedding and rerank models alone (heatonz)
|
||||
for _, m := range append(catalog.LiveServing(p.ID, ""), p.PlanRetrieval("")...) {
|
||||
if m.Serves == catalog.ServesEmbedding || m.Serves == catalog.ServesRerank {
|
||||
out.Retrieval++
|
||||
}
|
||||
}
|
||||
out.Retrieval = len(out.EmbedIDs) + len(out.RerankIDs)
|
||||
}
|
||||
// its image models aren't among those agents chat with; the editor
|
||||
// lists them apart, as Settings → Models → Images is where one is picked
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// A provider the user added that lists chat models and embedding and
|
||||
// rerank models too (@rfiacne on X, 11-20): its editor lists the embedding
|
||||
// and rerank ones apart, read only, as they need no pick; before, they
|
||||
// were nowhere to be seen once the provider had a chat model. A provider
|
||||
// without them shows neither row. Every language, both engines, wide and
|
||||
// narrow; no backend, the API is faked here.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
const { test } = require("node:test");
|
||||
const { chromium, webkit } = require("playwright");
|
||||
|
||||
const assets = path.resolve(__dirname, "../assets");
|
||||
const { I18N } = require("./strings.cjs").strings();
|
||||
const EMBED = "Embedding models", RERANK = "Rerank models";
|
||||
const say = (lang, k) => lang === "en" ? k : I18N[lang][k];
|
||||
|
||||
const relay = { id: "sf", name: "Silicon Relay", icon: "openai", models: [{ id: "deepseek-ai/DeepSeek-V3" }], agents: [], key: { set: true, masked: "sk-…ab12" }, chat: "http://sf.test/v1", embedIds: ["BAAI/bge-m3", "Qwen/Qwen3-Embedding-8B"], rerankIds: ["BAAI/bge-reranker-v2-m3"] };
|
||||
const plain = { id: "plain", name: "Plain Relay", icon: "openai", models: [{ id: "gpt-5.5" }], agents: [], key: { set: true, masked: "sk-…cd34" }, chat: "http://plain.test/v1" };
|
||||
|
||||
function server(lang) {
|
||||
const providers = { providers: [relay, plain], presets: [], excluded: [], gateway: { running: true, window: true } };
|
||||
return async (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
const json = (data) => route.fulfill({ json: data });
|
||||
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:${JSON.stringify(lang)},theme:"light",web:false};` });
|
||||
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
||||
if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: { lang, theme: "light" } });
|
||||
if (url.pathname === "/api/providers") return json(providers);
|
||||
if (url.pathname === "/api/groups") return json({ groups: [], pools: [] });
|
||||
if (url.pathname.startsWith("/api/")) return json({});
|
||||
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
|
||||
try { await route.fulfill({ body: await fs.readFile(file), contentType: { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)] }); } catch { await route.fulfill({ status: 404, body: "" }); }
|
||||
};
|
||||
}
|
||||
|
||||
test("each language names both rows", () => {
|
||||
for (const lang of ["zh", "zh-TW", "ja", "de"]) for (const k of [EMBED, RERANK]) assert(I18N[lang][k], lang + " " + k);
|
||||
});
|
||||
|
||||
// the chips under the label named label, in the open editor
|
||||
const chipsUnder = (page, label) => page.evaluate((label) => {
|
||||
const l = [...document.querySelectorAll(".editor label")].find((e) => e.textContent === label);
|
||||
const box = l?.nextElementSibling?.querySelector(".mchips.still") ?? l?.nextElementSibling;
|
||||
return l ? [...(box?.querySelectorAll(".mchip") ?? [])].map((c) => c.textContent) : null;
|
||||
}, label);
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
test(engine + ": an added provider's embedding and rerank models in its editor", async (t) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: process.env.PLAYWRIGHT_CHANNEL || "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) for (const width of [900, 420]) {
|
||||
await t.test(`${lang}, ${width}px`, async () => {
|
||||
const page = await (await browser.newContext({ viewport: { width, height: 760 }, reducedMotion: "reduce" })).newPage();
|
||||
page.setDefaultTimeout(5000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", server(lang));
|
||||
|
||||
await page.goto("http://magpie.test/?view=providers");
|
||||
await page.locator(".row.provider", { hasText: "Silicon Relay" }).first().click();
|
||||
await page.locator(".editor .ehead b", { hasText: "Silicon Relay" }).waitFor();
|
||||
assert.deepEqual(await chipsUnder(page, say(lang, EMBED)), ["BAAI/bge-m3", "Qwen/Qwen3-Embedding-8B"]);
|
||||
assert.deepEqual(await chipsUnder(page, say(lang, RERANK)), ["BAAI/bge-reranker-v2-m3"]);
|
||||
// the chips stay inside the editor at a narrow width
|
||||
const over = await page.evaluate(() => {
|
||||
const ed = document.querySelector(".editor").getBoundingClientRect();
|
||||
return [...document.querySelectorAll(".editor .mchips.still .mchip")].filter((c) => c.getBoundingClientRect().right > ed.right + 1).map((c) => c.textContent);
|
||||
});
|
||||
assert.deepEqual(over, []);
|
||||
|
||||
await page.goto("http://magpie.test/?view=providers");
|
||||
await page.locator(".row.provider", { hasText: "Plain Relay" }).first().click();
|
||||
await page.locator(".editor .ehead b", { hasText: "Plain Relay" }).waitFor();
|
||||
assert.equal(await chipsUnder(page, say(lang, EMBED)), null);
|
||||
assert.equal(await chipsUnder(page, say(lang, RERANK)), null);
|
||||
assert.deepEqual(errors, []);
|
||||
await page.context().close();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -47,7 +47,7 @@ f3475239bc3eacef0f4ee96f19bf35171b647be5fb3913e2ebaf62e56cd2f31a docs/grok-app.
|
||||
91408b1b9744ea84d175b25c58b53b045eb4721236053b145151a3ef184800d1 docs/huaweicloud.html
|
||||
fd149e201a1538f5f565e6aef5d74800bc55edb398e7f2f3aca51522ffbcde68 docs/images.html
|
||||
f0eea48f0a32d63038891aecb5f8f67fd470bcc82d08b853e2072dbe400a42cc docs/import.html
|
||||
cff1128a2e605a505ba1a0eca20917b6699b787412e358750604eb3eb081a2b2 docs/integrate.html
|
||||
73fce7da402ed359eaa0b2b187db3c56bfe7d9d6fe84cd9361e2eee9ac941c07 docs/integrate.html
|
||||
2b621281527fca8b6874bb7f9d4089f299e7250b2fc065c7ad89a71d05b7f915 docs/intent.html
|
||||
146befdd5c94abb899d9c70d7a8adf9ea20228faa04e9888ca6ab108092f3981 docs/ja/agent-drift.html
|
||||
b79c285f3f62290c2292b01d9938095888db65926cebbac6f0e1b35853a3112b docs/ja/aionui.html
|
||||
@@ -297,7 +297,7 @@ a9c87ff95e3d530036ffeb0b8eb7ca0b0014517597c7cb88c561e531c58a7ef4 docs/zh/hermes
|
||||
cb88657af0abdc41c0dd805f5557ff5b8b7a2cad2176c2803eb8c9fa61d7e7b3 docs/zh/huaweicloud.html
|
||||
1f1b59af2d59e6dffedca08fb73cf79016236d4fa58092af44ddbc39d0dade84 docs/zh/images.html
|
||||
884e502462f8c35c7abf9164c1c6603f20f7bd9c8869de76777c75836c05007e docs/zh/import.html
|
||||
5f864bffe7b682d1f72b3beefb214bf756669bb7a4128a47adf8d9f2d7ba0806 docs/zh/integrate.html
|
||||
555af6d835ddaa3335d0cae88df8cd0b331a2fde3a399ebcd73d42f0a66eb656 docs/zh/integrate.html
|
||||
b7853c115226ffe6a92999a7facee9b8d1f67b04534f2ba298672571c169d801 docs/zh/intent.html
|
||||
196f06ada68f61e11da15534bab83f9c45a6103b2d7d05fe9770a043c6c3df49 docs/zh/jcode.html
|
||||
959da5a0a7db89d930d548f360ed555663f3339e78657c3b3c2cc97f9722c7bc docs/zh/jetbrains-air.html
|
||||
|
||||
@@ -176,7 +176,7 @@ curl -s http://127.0.0.1:3425/v1/models -H "Authorization: Bearer magpie-acme"</
|
||||
<p>On this machine the gateway takes any key. Send <code>magpie-<your-app-id></code> (<code>Authorization: Bearer magpie-acme</code>, or <code>x-api-key</code>) and every call is counted as <code>acme</code> in Usage, the Requests log and the routing rules that match on agents. Without it, magpie counts the call by the first word of your <code>User-Agent</code> (<code>Acme/1.4 (darwin)</code> is <code>Acme</code>); an SDK’s own User-Agent (<code>OpenAI/JS …</code>, <code>ai-sdk/…</code>) would count it as that SDK. From another computer (<span class="ui">Settings</span> → <span class="ui">Share on local network</span>) the key must be one of the user’s gateway keys, and the User-Agent names your app.</p>
|
||||
|
||||
<h3>Models</h3>
|
||||
<p><code>GET /v1/models</code> lists what the user has turned on: <code>id</code> (<code>provider/model</code>, or a routing group’s name, sent as it is), <code>display_name</code>, <code>owned_by</code> (the provider), <code>reasoning</code> and <code>supported_reasoning_levels</code> (<code>[{"effort":"low"},…]</code>, and the same as plain names in <code>reasoning_levels</code>), <code>context_window</code> and <code>max_output_tokens</code> when known, and <code>modalities</code> when magpie knows whether it takes images. List them from there rather than shipping a list: the user adds and removes providers in magpie. Reasoning is asked in your API’s own field (<code>reasoning_effort</code>, <code>reasoning.effort</code>, Anthropic’s <code>thinking</code> or <code>output_config.effort</code>). <code>?format=text</code> gives the ids one a line. The list holds chat models alone: ask for image and video models with <code>?kind=image,video</code> (or <code>?kind=all</code>). Each is marked <code>"kind": "image"</code> or <code>"video"</code> and is made on <code>/v1/images/generations</code> or <code>/v1/videos</code>, not a chat route. Cherry Studio, which can’t ask and tells an image model from a chat one by its id, is listed every kind.</p>
|
||||
<p><code>GET /v1/models</code> lists what the user has turned on: <code>id</code> (<code>provider/model</code>, or a routing group’s name, sent as it is), <code>display_name</code>, <code>owned_by</code> (the provider), <code>reasoning</code> and <code>supported_reasoning_levels</code> (<code>[{"effort":"low"},…]</code>, and the same as plain names in <code>reasoning_levels</code>), <code>context_window</code> and <code>max_output_tokens</code> when known, and <code>modalities</code> when magpie knows whether it takes images. List them from there rather than shipping a list: the user adds and removes providers in magpie. Reasoning is asked in your API’s own field (<code>reasoning_effort</code>, <code>reasoning.effort</code>, Anthropic’s <code>thinking</code> or <code>output_config.effort</code>). <code>?format=text</code> gives the ids one a line. The list holds chat models alone: ask for image, video, embedding and rerank models with <code>?kind=image,video,embedding,rerank</code> (or <code>?kind=all</code>). Each is marked <code>"kind": "image"</code>, <code>"video"</code>, <code>"embedding"</code> or <code>"rerank"</code> and goes to <code>/v1/images/generations</code>, <code>/v1/videos</code>, <code>/v1/embeddings</code> or <code>/v1/rerank</code>, not a chat route. Cherry Studio, which can’t ask and tells an image or embedding model from a chat one by its id, is listed every kind.</p>
|
||||
|
||||
<p>A vendor’s own fields: <code>/v1/images/generations</code> and <code>/v1/videos</code> take OpenAI’s fields and pass the others on to a vendor that takes them, such as Volcengine Ark’s <code>content</code> (reference video and audio, <code>draft_task</code>), <code>ratio</code>, <code>resolution</code>, <code>duration: -1</code>, <code>tools</code>, <code>watermark</code> and <code>sequential_image_generation</code>, and a video’s answer carries Ark’s own fields (<code>content.last_frame_url</code>, <code>usage</code>). For the rest of a vendor’s API use <code>/v1/magpie/native/<provider>/<path></code>: <code>GET</code>, <code>POST</code>, <code>PUT</code>, <code>PATCH</code> or <code>DELETE</code>, with <code><path></code> joined to the provider’s host (not its base URL), in the vendor’s own shape on the user’s key for that provider, a stream as it comes; Ark’s task list is <code>GET /v1/magpie/native/ark/api/v3/contents/generations/tasks</code>. It serves a provider added with an API key, not a subscription or sign-in, and Ark’s short paths (<code>images/generations</code>, <code>contents/generations/tasks</code>) still work under the key’s base. It takes the same gateway key as every route, and a key held to models, accounts or a budget is refused it.</p>
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ curl -s http://127.0.0.1:3425/v1/models -H "Authorization: Bearer magpie-acme"</
|
||||
<p>在本机,网关接受任意 key。发送 <code>magpie-<你的应用 id></code>(<code>Authorization: Bearer magpie-acme</code>,或 <code>x-api-key</code>),每次调用都会在用量、请求记录以及按 Agent 匹配的路由规则里记为 <code>acme</code>。不带它时,magpie 按 <code>User-Agent</code> 的第一个词统计(<code>Acme/1.4 (darwin)</code> 记为 <code>Acme</code>);SDK 自带的 User-Agent(<code>OpenAI/JS …</code>、<code>ai-sdk/…</code>)会被记成那个 SDK。从另一台电脑访问时(<span class="ui">设置</span> → <span class="ui">局域网共享</span>),key 必须是用户的网关密钥之一,应用名就靠 User-Agent。</p>
|
||||
|
||||
<h3>模型</h3>
|
||||
<p><code>GET /v1/models</code> 列出用户打开的模型:<code>id</code>(<code>provider/model</code>,或路由组的名字,原样发送即可)、<code>display_name</code>、<code>owned_by</code>(供应商)、<code>reasoning</code> 与 <code>supported_reasoning_levels</code>(<code>[{"effort":"low"},…]</code>;同样的档位以纯名字列在 <code>reasoning_levels</code>),已知时还有 <code>context_window</code>、<code>max_output_tokens</code>,以及 magpie 知道是否支持图片时的 <code>modalities</code>。请从这里读取,而不是内置一份列表:用户会在 magpie 里增删供应商。推理强度用你所用 API 自己的字段传(<code>reasoning_effort</code>、<code>reasoning.effort</code>、Anthropic 的 <code>thinking</code> 或 <code>output_config.effort</code>)。<code>?format=text</code> 每行一个 id。列表只有对话模型:要图像和视频模型,请加 <code>?kind=image,video</code>(或 <code>?kind=all</code>),它们带 <code>"kind": "image"</code> 或 <code>"video"</code>,在 <code>/v1/images/generations</code> 或 <code>/v1/videos</code> 上生成,不走对话接口。Cherry Studio 没法这样要,它按 id 自己分辨图像模型和对话模型,所以给它的列表包含所有种类。</p>
|
||||
<p><code>GET /v1/models</code> 列出用户打开的模型:<code>id</code>(<code>provider/model</code>,或路由组的名字,原样发送即可)、<code>display_name</code>、<code>owned_by</code>(供应商)、<code>reasoning</code> 与 <code>supported_reasoning_levels</code>(<code>[{"effort":"low"},…]</code>;同样的档位以纯名字列在 <code>reasoning_levels</code>),已知时还有 <code>context_window</code>、<code>max_output_tokens</code>,以及 magpie 知道是否支持图片时的 <code>modalities</code>。请从这里读取,而不是内置一份列表:用户会在 magpie 里增删供应商。推理强度用你所用 API 自己的字段传(<code>reasoning_effort</code>、<code>reasoning.effort</code>、Anthropic 的 <code>thinking</code> 或 <code>output_config.effort</code>)。<code>?format=text</code> 每行一个 id。列表只有对话模型:要图像、视频、嵌入和重排序模型,请加 <code>?kind=image,video,embedding,rerank</code>(或 <code>?kind=all</code>),它们带 <code>"kind": "image"</code>、<code>"video"</code>、<code>"embedding"</code> 或 <code>"rerank"</code>,分别走 <code>/v1/images/generations</code>、<code>/v1/videos</code>、<code>/v1/embeddings</code> 或 <code>/v1/rerank</code>,不走对话接口。Cherry Studio 没法这样要,它按 id 自己分辨图像、嵌入模型和对话模型,所以给它的列表包含所有种类。</p>
|
||||
|
||||
<p>厂商自己的字段:<code>/v1/images/generations</code> 和 <code>/v1/videos</code> 读 OpenAI 的字段,其余字段原样转给支持它们的厂商,比如火山方舟的 <code>content</code>(参考视频、参考音频、<code>draft_task</code>)、<code>ratio</code>、<code>resolution</code>、<code>duration: -1</code>、<code>tools</code>、<code>watermark</code>、<code>sequential_image_generation</code>;视频的回答也带上方舟自己的字段(<code>content.last_frame_url</code>、<code>usage</code>)。厂商 API 的其他部分请用 <code>/v1/magpie/native/<provider>/<path></code>:支持 <code>GET</code>、<code>POST</code>、<code>PUT</code>、<code>PATCH</code>、<code>DELETE</code>,<code><path></code> 接在服务商的域名后面(不是 base URL 后面),按厂商自己的格式收发,用的是用户为这个服务商填的密钥,流式回答边到边转;比如方舟的任务列表是 <code>GET /v1/magpie/native/ark/api/v3/contents/generations/tasks</code>。只服务用 API 密钥添加的服务商,不服务订阅或登录的账号;方舟原来的短路径(<code>images/generations</code>、<code>contents/generations/tasks</code>)照旧接在密钥的 base 后面。它和其他接口一样需要网关密钥;限了模型、账号或额度的密钥不能用它。</p>
|
||||
|
||||
|
||||
@@ -11174,7 +11174,7 @@ On this machine the gateway takes any key. Send `magpie-<your-app-id>` (`Authori
|
||||
|
||||
### Models
|
||||
|
||||
`GET /v1/models` lists what the user has turned on: `id` (`provider/model`, or a routing group’s name, sent as it is), `display_name`, `owned_by` (the provider), `reasoning` and `supported_reasoning_levels` (`[{"effort":"low"},…]`, and the same as plain names in `reasoning_levels`), `context_window` and `max_output_tokens` when known, and `modalities` when magpie knows whether it takes images. List them from there rather than shipping a list: the user adds and removes providers in magpie. Reasoning is asked in your API’s own field (`reasoning_effort`, `reasoning.effort`, Anthropic’s `thinking` or `output_config.effort`). `?format=text` gives the ids one a line. The list holds chat models alone: ask for image and video models with `?kind=image,video` (or `?kind=all`). Each is marked `"kind": "image"` or `"video"` and is made on `/v1/images/generations` or `/v1/videos`, not a chat route. Cherry Studio, which can’t ask and tells an image model from a chat one by its id, is listed every kind.
|
||||
`GET /v1/models` lists what the user has turned on: `id` (`provider/model`, or a routing group’s name, sent as it is), `display_name`, `owned_by` (the provider), `reasoning` and `supported_reasoning_levels` (`[{"effort":"low"},…]`, and the same as plain names in `reasoning_levels`), `context_window` and `max_output_tokens` when known, and `modalities` when magpie knows whether it takes images. List them from there rather than shipping a list: the user adds and removes providers in magpie. Reasoning is asked in your API’s own field (`reasoning_effort`, `reasoning.effort`, Anthropic’s `thinking` or `output_config.effort`). `?format=text` gives the ids one a line. The list holds chat models alone: ask for image, video, embedding and rerank models with `?kind=image,video,embedding,rerank` (or `?kind=all`). Each is marked `"kind": "image"`, `"video"`, `"embedding"` or `"rerank"` and goes to `/v1/images/generations`, `/v1/videos`, `/v1/embeddings` or `/v1/rerank`, not a chat route. Cherry Studio, which can’t ask and tells an image or embedding model from a chat one by its id, is listed every kind.
|
||||
|
||||
A vendor’s own fields: `/v1/images/generations` and `/v1/videos` take OpenAI’s fields and pass the others on to a vendor that takes them, such as Volcengine Ark’s `content` (reference video and audio, `draft_task`), `ratio`, `resolution`, `duration: -1`, `tools`, `watermark` and `sequential_image_generation`, and a video’s answer carries Ark’s own fields (`content.last_frame_url`, `usage`). For the rest of a vendor’s API use `/v1/magpie/native/<provider>/<path>`: `GET`, `POST`, `PUT`, `PATCH` or `DELETE`, with `<path>` joined to the provider’s host (not its base URL), in the vendor’s own shape on the user’s key for that provider, a stream as it comes; Ark’s task list is `GET /v1/magpie/native/ark/api/v3/contents/generations/tasks`. It serves a provider added with an API key, not a subscription or sign-in, and Ark’s short paths (`images/generations`, `contents/generations/tasks`) still work under the key’s base. It takes the same gateway key as every route, and a key held to models, accounts or a budget is refused it.
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user