Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
test(rerank): pin every vendor's request, and correct three facts the table surfaced (#3513)
lyingbug4640a1ea0cf7
diff --git a/internal/models/parity/rerank_test.go b/internal/models/parity/rerank_test.goindex b717437e7..113061e6b 100644--- a/internal/models/parity/rerank_test.go+++ b/internal/models/parity/rerank_test.go@@ -67,7 +67,6 @@ func TestRerankProtocolAssignment(t *testing.T) {"qianfan": api.RerankCohere,"gpustack": api.RerankCohere,"generic": api.RerankCohere,- "openai": api.RerankCohere,"weknoracloud": api.RerankCohere,"novita": api.RerankCohere,"openrouter": api.RerankCohere,@@ -263,8 +262,8 @@ func TestRerankCeilingsAreTheDocumentedOnes(t *testing.T) {// cloud.tencent.com/document/product/1772: RunRerank 60 docs,// Query + Docs together 2000 characters, one request at a time."lkeap": {MaxDocuments: 60, MaxRequestChars: 2000, MaxConcurrency: 1},- // Ark Knowledge Service rerank: 50 per request.- "volcengine": {MaxDocuments: 50, MaxConcurrency: 4},+ // VikingDB Knowledge Service rerank: datas "数组长度不超过 200".+ "volcengine": {MaxDocuments: 200, MaxConcurrency: 4},// NIM reranking: passages is capped at 512 items."nvidia": {MaxDocuments: 512},// cloud.baidu.com/doc/qianfan-api: 文本数量不超过64, query 不超过diff --git a/internal/models/rerank/lkeap_reranker.go b/internal/models/rerank/lkeap_reranker.goindex f5c58cd32..e17adfb70 100644--- a/internal/models/rerank/lkeap_reranker.go+++ b/internal/models/rerank/lkeap_reranker.go@@ -21,6 +21,14 @@ const (LKEAPDefaultRerankModel = "lke-reranker-base")+// lkeapEndpoint and lkeapScheme are where the SDK sends RunRerank: the public+// API host, as it has always been, whatever the row's base URL says. They are+// variables only so a test can point the SDK at a local server.+var (+ lkeapEndpoint = LKEAPRerankEndpoint+ lkeapScheme = "HTTPS"+)+// lkeapClient calls Tencent Cloud's RunRerank action through the official// SDK, which owns the TC3 signing this API requires. It implements// api.Reranker and nothing else: the per-request ceilings (60 documents,@@ -50,7 +58,8 @@ func newLKEAPClient(config *RerankerConfig, resolved *catalog.Resolved) (api.Rercredential := common.NewCredential(secretID, secretKey)cpf := profile.NewClientProfile()- cpf.HttpProfile.Endpoint = LKEAPRerankEndpoint+ cpf.HttpProfile.Endpoint = lkeapEndpoint+ cpf.HttpProfile.Scheme = lkeapSchemeclient, err := lkeap.NewClient(credential, region, cpf)if err != nil {diff --git a/internal/models/rerank/sdk_clients_test.go b/internal/models/rerank/sdk_clients_test.goindex 499041578..b8d8c1b3b 100644--- a/internal/models/rerank/sdk_clients_test.go+++ b/internal/models/rerank/sdk_clients_test.go@@ -65,7 +65,10 @@ func TestVolcengineClientOutboundShape(t *testing.T) {require.NotNil(t, request.Datas[0].Content)assert.Equal(t, "会保留", *request.Datas[0].Content)require.NotNil(t, request.RerankInstruction)- assert.Contains(t, *request.RerankInstruction, "Document")+ // The console's default, verbatim, so results match what the console shows.+ assert.Equal(t, volcengineRerankDefaultInstruction, *request.RerankInstruction)+ assert.Equal(t, "Whether the document answers the query or matches the content retrieval intent",+ *request.RerankInstruction)}func TestVolcengineClientSurfacesAnInBodyErrorCode(t *testing.T) {diff --git a/internal/models/rerank/volcengine_reranker.go b/internal/models/rerank/volcengine_reranker.goindex d5cdb762e..2401b716d 100644--- a/internal/models/rerank/volcengine_reranker.go+++ b/internal/models/rerank/volcengine_reranker.go@@ -13,14 +13,17 @@ import ()const (- volcengineRerankDefaultModel = "doubao-seed-rerank"- volcengineRerankDefaultRegion = "cn-beijing"- volcengineRerankDefaultInstruction = "Whether the Document answers the Query or matches the content retrieval intent"+ volcengineRerankDefaultModel = "doubao-seed-rerank"+ volcengineRerankDefaultRegion = "cn-beijing"+ // The console's default instruction, verbatim: "如需对齐控制台效果,请使用+ // 相同指令" (https://docs.volcengine.com/docs/vector_database_vikingdb/Rerank).+ volcengineRerankDefaultInstruction = "Whether the document answers the query " ++ "or matches the content retrieval intent")// volcengineClient calls the managed Knowledge Service rerank through the// vikingdb SDK, which owns the AK/SK signing. It implements api.Reranker and-// nothing else: the 50-document ceiling and the batch concurrency are+// nothing else: the 200-document ceiling and the batch concurrency are// declared on the vendor and enforced by protocolReranker.type volcengineClient struct {modelName stringdiff --git a/internal/models/rerank/wire_test.go b/internal/models/rerank/wire_test.gonew file mode 100644index 000000000..600c96765--- /dev/null+++ b/internal/models/rerank/wire_test.go@@ -0,0 +1,357 @@+package rerank++import (+ "context"+ "encoding/json"+ "fmt"+ "math"+ "net/http"+ "net/http/httptest"+ "sort"+ "strings"+ "sync"+ "testing"+ "unicode/utf8"++ "github.com/Tencent/WeKnora/internal/models/catalog"+ "github.com/Tencent/WeKnora/internal/types"+ "github.com/stretchr/testify/assert"+ "github.com/stretchr/testify/require"+)++// recorded is one request as the upstream saw it.+type recorded struct {+ path string+ header http.Header+ body map[string]any+}++// upstream is a stand-in for every rerank vendor at once. It answers in+// whichever shape the request belongs to, scoring each document by its+// length so that the expected ranking is known: longer is more relevant.+// Probability vendors get length/100, logit vendors length-3, which puts the+// shortest documents below zero the way a real NIM reply does.+type upstream struct {+ mu sync.Mutex+ requests []recorded+ url string+}++func newUpstream(t *testing.T) *upstream {+ t.Helper()+ withRerankSSRFWhitelist(t, "127.0.0.1")+ u := &upstream{}+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ var body map[string]any+ if err := json.NewDecoder(r.Body).Decode(&body); err != nil {+ http.Error(w, err.Error(), http.StatusBadRequest)+ return+ }+ u.mu.Lock()+ u.requests = append(u.requests, recorded{r.URL.Path, r.Header.Clone(), body})+ u.mu.Unlock()+ w.Header().Set("Content-Type", "application/json")+ _, _ = w.Write([]byte(answer(r, body)))+ }))+ t.Cleanup(server.Close)+ u.url = server.URL++ // LKEAP's SDK always calls the public API host; point it here.+ savedEndpoint, savedScheme := lkeapEndpoint, lkeapScheme+ lkeapEndpoint, lkeapScheme = strings.TrimPrefix(server.URL, "http://"), "HTTP"+ t.Cleanup(func() { lkeapEndpoint, lkeapScheme = savedEndpoint, savedScheme })+ return u+}++// texts pulls the documents out of whichever shape carried them.+func texts(v any) []string {+ var out []string+ for _, item := range v.([]any) {+ switch d := item.(type) {+ case string:+ out = append(out, d)+ case map[string]any: // NIM passages, Volcengine datas+ if text, ok := d["text"].(string); ok {+ out = append(out, text)+ } else {+ out = append(out, d["content"].(string))+ }+ }+ }+ return out+}++func probability(doc string) float64 { return float64(utf8.RuneCountInString(doc)) / 100 }+func logit(doc string) float64 { return float64(utf8.RuneCountInString(doc)) - 3 }++// answer replies in the protocol the request belongs to. The indexed shapes+// come back in reverse order so that placement by index is exercised.+func answer(r *http.Request, body map[string]any) string {+ var parts []string+ switch {+ case r.Header.Get("X-TC-Action") == "RunRerank": // LKEAP: scores in input order+ for _, doc := range texts(body["Docs"]) {+ parts = append(parts, fmt.Sprint(probability(doc)))+ }+ return `{"Response":{"ScoreList":[` + strings.Join(parts, ",") + `],"RequestId":"r"}}`+ case strings.HasSuffix(r.URL.Path, "/api/knowledge/service/rerank"): // Volcengine+ for _, doc := range texts(body["datas"]) {+ parts = append(parts, fmt.Sprint(probability(doc)))+ }+ return `{"code":0,"message":"success","data":{"scores":[` + strings.Join(parts, ",") + `]}}`+ case strings.HasSuffix(r.URL.Path, "/reranking"): // NIM+ docs := texts(body["passages"])+ for i := len(docs) - 1; i >= 0; i-- {+ parts = append(parts, fmt.Sprintf(`{"index":%d,"logit":%v}`, i, logit(docs[i])))+ }+ return `{"rankings":[` + strings.Join(parts, ",") + `]}`+ case strings.Contains(r.URL.Path, "/text-rerank"): // DashScope+ docs := texts(body["input"].(map[string]any)["documents"])+ for i := len(docs) - 1; i >= 0; i-- {+ parts = append(parts, fmt.Sprintf(`{"index":%d,"relevance_score":%v}`, i, probability(docs[i])))+ }+ return `{"output":{"results":[` + strings.Join(parts, ",") + `]}}`+ default: // Cohere+ docs := texts(body["documents"])+ score := probability+ if r.Header.Get("X-Test-Scale") == "logit" {+ score = logit+ }+ for i := len(docs) - 1; i >= 0; i-- {+ parts = append(parts, fmt.Sprintf(`{"index":%d,"relevance_score":%v}`, i, score(docs[i])))+ }+ return `{"results":[` + strings.Join(parts, ",") + `]}`+ }+}++func documents(n int) []string {+ out := make([]string, n)+ for i := range out {+ out[i] = strings.Repeat("d", i%7+1) + fmt.Sprint(i)+ }+ return out+}++func anyStrings(in []string) []any {+ out := make([]any, len(in))+ for i, s := range in {+ out[i] = s+ }+ return out+}++// TestRerankWireFormatPerVendor pins, for every rerank vendor in the catalog,+// the request the factory actually sends — URL, credential and the complete+// body — and that the answer comes back ranked on the 0..1 scale the+// retrieval threshold assumes. Each expectation traces to the vendor's+// reference as cited in its vendor.go.+func TestRerankWireFormatPerVendor(t *testing.T) {+ const query = "q"+ three := []string{"a", "bbb", "cc"}+ cohere := func(model string, docs []string, extra map[string]any) map[string]any {+ body := map[string]any{"model": model, "query": query, "documents": anyStrings(docs)}+ for k, v := range extra {+ body[k] = v+ }+ return body+ }+ const volcInstruction = "Whether the document answers the query or matches the content retrieval intent"++ cases := []struct {+ name string+ provider string+ model string+ base string // appended to the upstream URL+ extra map[string]string+ appID string+ appSecret string+ docs []string+ logitScale bool // the protocol answers raw logits (NIM)+ // cohereLogs marks a Cohere-shape vendor that declares a logit scale+ // (GPUStack). The shape cannot tell the stub which scale to answer+ // in, so the case asks for logits through a test-only header.+ cohereLogs bool++ wantPath string+ wantAuth [2]string // header, a substring its value must contain+ wantRequests int+ // wantBody is one request's body, exactly. Batches go out+ // concurrently, so it is matched against every request rather than+ // the first to arrive.+ wantBody map[string]any+ }{+ {+ name: "jina echoes documents", provider: "jina", model: "jina-reranker-v3", base: "/v1",+ wantPath: "/v1/rerank", wantAuth: [2]string{"Authorization", "Bearer k"},+ wantBody: cohere("jina-reranker-v3", three, map[string]any{"return_documents": true}),+ },+ {+ name: "zhipu on its full rerank URL", provider: "zhipu", model: "rerank", base: "/api/paas/v4/rerank",+ wantPath: "/api/paas/v4/rerank", wantAuth: [2]string{"Authorization", "Bearer k"},+ wantBody: cohere("rerank", three, map[string]any{"return_documents": true}),+ },+ {+ name: "zhipu splits at 128 documents", provider: "zhipu", model: "rerank", base: "/api/paas/v4/rerank",+ docs: documents(129), wantRequests: 2,+ wantPath: "/api/paas/v4/rerank", wantAuth: [2]string{"Authorization", "Bearer k"},+ wantBody: cohere("rerank", documents(128), map[string]any{"return_documents": true}),+ },+ {+ name: "siliconflow", provider: "siliconflow", model: "BAAI/bge-reranker-v2-m3", base: "/v1",+ wantPath: "/v1/rerank", wantAuth: [2]string{"Authorization", "Bearer k"},+ wantBody: cohere("BAAI/bge-reranker-v2-m3", three, nil),+ },+ {+ name: "qianfan splits at 64 documents", provider: "qianfan", model: "bce-reranker-base", base: "/v2",+ docs: documents(65), wantRequests: 2,+ wantPath: "/v2/rerank", wantAuth: [2]string{"Authorization", "Bearer k"},+ wantBody: cohere("bce-reranker-base", documents(64), nil),+ },+ {+ name: "gpustack sends the row's truncation budget and answers logits", provider: "gpustack",+ model: "bge-reranker-v2-m3", base: "/v1",+ extra: map[string]string{catalog.ExtraTruncatePromptTokens: "256"},+ cohereLogs: true,+ wantPath: "/v1/rerank", wantAuth: [2]string{"Authorization", "Bearer k"},+ wantBody: cohere("bge-reranker-v2-m3", three, map[string]any{"truncate_prompt_tokens": float64(256)}),+ },+ {+ name: "generic", provider: "generic", model: "bge-reranker-v2-m3", base: "/v1",+ wantPath: "/v1/rerank", wantAuth: [2]string{"Authorization", "Bearer k"},+ wantBody: cohere("bge-reranker-v2-m3", three, nil),+ },+ {+ name: "novita", provider: "novita", model: "baai/bge-reranker-v2-m3", base: "/openai/v1",+ wantPath: "/openai/v1/rerank", wantAuth: [2]string{"Authorization", "Bearer k"},+ wantBody: cohere("baai/bge-reranker-v2-m3", three, nil),+ },+ {+ name: "openrouter", provider: "openrouter", model: "cohere/rerank-v3.5", base: "/api/v1",+ wantPath: "/api/v1/rerank", wantAuth: [2]string{"Authorization", "Bearer k"},+ wantBody: cohere("cohere/rerank-v3.5", three, nil),+ },+ {+ name: "litellm on the proxy root", provider: "litellm", model: "cohere/rerank-v3.5",+ wantPath: "/rerank", wantAuth: [2]string{"Authorization", "Bearer k"},+ wantBody: cohere("cohere/rerank-v3.5", three, nil),+ },+ {+ name: "weknoracloud signs its own path", provider: "weknoracloud", model: "rerank",+ appID: "app", appSecret: "s",+ wantPath: "/api/v1/rerank", wantAuth: [2]string{"X-APPID", "app"},+ wantBody: cohere("rerank", three, nil),+ },+ {+ name: "aliyun wraps input and parameters", provider: "aliyun", model: "gte-rerank-v2",+ base: "/api/v1/services/rerank/text-rerank/text-rerank",+ wantPath: "/api/v1/services/rerank/text-rerank/text-rerank",+ wantAuth: [2]string{"Authorization", "Bearer k"},+ wantBody: map[string]any{+ "model": "gte-rerank-v2",+ "input": map[string]any{"query": query, "documents": anyStrings(three)},+ "parameters": map[string]any{"return_documents": true, "top_n": float64(3)},+ },+ },+ {+ name: "nvidia sends passages and answers logits", provider: "nvidia",+ model: "nvidia/nv-rerankqa-mistral-4b-v3", base: "/v1/retrieval/nvidia/reranking", logitScale: true,+ wantPath: "/v1/retrieval/nvidia/reranking", wantAuth: [2]string{"Authorization", "Bearer k"},+ wantBody: map[string]any{+ "model": "nvidia/nv-rerankqa-mistral-4b-v3",+ "query": map[string]any{"text": query},+ "passages": []any{+ map[string]any{"text": "a"}, map[string]any{"text": "bbb"}, map[string]any{"text": "cc"},+ },+ "truncate": "END",+ },+ },+ {+ name: "volcengine through the Knowledge Service SDK", provider: "volcengine", model: "doubao-seed-rerank",+ appSecret: "secret-test",+ wantPath: "/api/knowledge/service/rerank", wantAuth: [2]string{"Authorization", "Credential=k/"},+ wantBody: map[string]any{+ "rerank_model": "doubao-seed-rerank",+ "rerank_instruction": volcInstruction,+ "datas": []any{+ map[string]any{"query": query, "content": "a"},+ map[string]any{"query": query, "content": "bbb"},+ map[string]any{"query": query, "content": "cc"},+ },+ },+ },+ {+ name: "lkeap through the Tencent Cloud SDK", provider: "lkeap", model: "lke-reranker-base",+ appSecret: "secret-test",+ wantPath: "/", wantAuth: [2]string{"Authorization", "Credential=k/"},+ wantBody: map[string]any{"Query": query, "Docs": anyStrings(three), "Model": "lke-reranker-base"},+ },+ }++ for _, tc := range cases {+ t.Run(tc.name, func(t *testing.T) {+ up := newUpstream(t)+ docs := tc.docs+ if docs == nil {+ docs = three+ }+ headers := map[string]string{}+ if tc.cohereLogs {+ headers["X-Test-Scale"] = "logit"+ }+ reranker, err := NewReranker(&RerankerConfig{+ Source: types.ModelSourceRemote, Provider: tc.provider, ModelName: tc.model,+ BaseURL: up.url + tc.base, APIKey: "k", ExtraConfig: tc.extra,+ AppID: tc.appID, AppSecret: tc.appSecret, CustomHeaders: headers,+ })+ require.NoError(t, err)++ got, err := reranker.Rerank(context.Background(), query, docs)+ require.NoError(t, err)++ wantRequests := tc.wantRequests+ if wantRequests == 0 {+ wantRequests = 1+ }+ require.Len(t, up.requests, wantRequests)+ bodies := make([]map[string]any, 0, len(up.requests))+ for _, req := range up.requests {+ assert.Equal(t, tc.wantPath, req.path)+ assert.Contains(t, req.header.Get(tc.wantAuth[0]), tc.wantAuth[1])+ if tc.appSecret != "" {+ assert.NotContains(t, req.header.Get("Authorization"), tc.appSecret,+ "a secret key signs the request and must never travel")+ }+ bodies = append(bodies, req.body)+ }+ assert.Contains(t, bodies, tc.wantBody)++ // Every document comes back once, ranked by the upstream's score,+ // and on the probability scale.+ require.Len(t, got, len(docs))+ want := append([]string(nil), docs...)+ sort.SliceStable(want, func(i, j int) bool {+ return utf8.RuneCountInString(want[i]) > utf8.RuneCountInString(want[j])+ })+ for i, r := range got {+ assert.Equal(t, docs[r.Index], r.Document.Text, "result %d carries the wrong text", i)+ assert.Equal(t, utf8.RuneCountInString(want[i]), utf8.RuneCountInString(r.Document.Text),+ "result %d is out of rank", i)+ assert.GreaterOrEqual(t, r.RelevanceScore, 0.0)+ assert.LessOrEqual(t, r.RelevanceScore, 1.0)+ }+ if tc.logitScale || tc.cohereLogs {+ // length 1 is a logit of -2: well below one half once converted.+ last := got[len(got)-1]+ assert.InDelta(t, 1/(1+math.Exp(2)), last.RelevanceScore, 1e-9,+ "a logit must be converted, not passed through")+ }+ })+ }+}++// OpenAI has no rerank API, so the vendor does not offer the type.+func TestOpenAIDoesNotOfferRerank(t *testing.T) {+ v, ok := catalog.Get("openai")+ require.True(t, ok)+ assert.False(t, v.SupportsType(types.ModelTypeRerank))+}diff --git a/internal/models/vendors/openai/vendor.go b/internal/models/vendors/openai/vendor.goindex d1d02d539..f9191b9b1 100644--- a/internal/models/vendors/openai/vendor.go+++ b/internal/models/vendors/openai/vendor.go@@ -21,8 +21,8 @@// gpt-5* / o1* / o3* / o4* families set supports_temperature false;// - `store: false` is sent so completions are not retained, and// `prompt_cache_key` steers cache routing; usage reports cached tokens;-// - every model type (chat, embedding, rerank via generic clients, VLM,-// ASR) is served from https://api.openai.com/v1;+// - chat, embedding, VLM and ASR are served from https://api.openai.com/v1;+// there is no rerank API;// - requests that go to api.openai.com itself use the Responses protocol// (https://developers.openai.com/api/docs/api-reference/responses),// OpenAI's primary API where reasoning items and encrypted reasoning are@@ -85,14 +85,16 @@ func init() {DefaultBaseURLs: map[types.ModelType]string{types.ModelTypeKnowledgeQA: BaseURL,types.ModelTypeEmbedding: BaseURL,- types.ModelTypeRerank: BaseURL,types.ModelTypeVLLM: BaseURL,types.ModelTypeASR: BaseURL,},+ // No rerank: OpenAI's API has no rerank endpoint — the reference+ // index (https://developers.openai.com/api/llms.txt) does not mention+ // one — so a row created here would only ever 404. A relay that+ // serves rerank behind an OpenAI-style URL is a generic row.ModelTypes: []types.ModelType{types.ModelTypeKnowledgeQA,types.ModelTypeEmbedding,- types.ModelTypeRerank,types.ModelTypeVLLM,types.ModelTypeASR,},diff --git a/internal/models/vendors/siliconflow/models.json b/internal/models/vendors/siliconflow/models.jsonindex 44cb98d2d..585be3a42 100644--- a/internal/models/vendors/siliconflow/models.json+++ b/internal/models/vendors/siliconflow/models.json@@ -22,8 +22,8 @@{"id": "Qwen/Qwen3-Embedding-8B", "name": "Qwen3 Embedding 8B", "type": "Embedding", "dimension": 4096, "source": "https://api-docs.siliconflow.cn/docs/api/embeddings-post"},{"id": "Qwen/Qwen3-Embedding-4B", "name": "Qwen3 Embedding 4B", "type": "Embedding", "dimension": 2560, "source": "https://api-docs.siliconflow.cn/docs/api/embeddings-post"},{"id": "Qwen/Qwen3-Embedding-0.6B", "name": "Qwen3 Embedding 0.6B", "type": "Embedding", "dimension": 1024, "source": "https://api-docs.siliconflow.cn/docs/api/embeddings-post"},- {"id": "BAAI/bge-reranker-v2-m3", "name": "BGE Reranker v2 M3", "type": "Rerank", "source": "https://docs.siliconflow.cn/cn/api-reference/rerank/create-rerank"},- {"id": "Qwen/Qwen3-Reranker-8B", "name": "Qwen3 Reranker 8B", "type": "Rerank", "source": "https://docs.siliconflow.cn/cn/api-reference/rerank/create-rerank"},+ {"id": "BAAI/bge-reranker-v2-m3", "name": "BGE Reranker v2 M3", "type": "Rerank", "source": "https://api-docs.siliconflow.cn/docs/api/rerank-post"},+ {"id": "Qwen/Qwen3-Reranker-8B", "name": "Qwen3 Reranker 8B", "type": "Rerank", "source": "https://api-docs.siliconflow.cn/docs/api/rerank-post"},{"id": "FunAudioLLM/SenseVoiceSmall", "name": "SenseVoice Small", "type": "ASR", "source": "https://api-docs.siliconflow.cn/docs/api/audio-transcriptions-post"},{"id": "TeleAI/TeleSpeechASR", "name": "TeleSpeechASR", "type": "ASR", "source": "https://api-docs.siliconflow.cn/docs/api/audio-transcriptions-post"}]diff --git a/internal/models/vendors/volcengine/vendor.go b/internal/models/vendors/volcengine/vendor.goindex c48a88347..783f928b8 100644--- a/internal/models/vendors/volcengine/vendor.go+++ b/internal/models/vendors/volcengine/vendor.go@@ -54,7 +54,9 @@// (the API key field carries the access key; the secret key, region and// instruction come from the rerank-only extra fields). Documented models// are doubao-seed-rerank and base-multilingual-rerank-// (https://www.volcengine.com/docs/84313/1254474);+// (https://www.volcengine.com/docs/84313/1254474). datas takes at most+// 200 items, and the default instruction is the console's, verbatim, as+// the page asks for results that match the console;// - Ark additionally serves an Anthropic Messages surface at// https://ark.cn-beijing.volces.com/api/compatible/v1 with x-api-key// auth. This package configures OpenAI Chat Completions, which is the@@ -68,10 +70,6 @@// saying whether k is 1000 or 1024, so the context windows in models.json are// left at their present values.//-// unverified: the rerank instruction default here capitalises Document /-// Query while the console default in the docs is lower case; it is kept in-// sync with internal/models/rerank instead.-//// unverified: prices in models.json come from the Ark pricing console, which// the public docs do not render.package volcengine@@ -179,7 +177,7 @@ func init() {Label: "Rerank Instruction",Labels: map[string]string{"zh-CN": "重排指令"},Type: "string",- Default: "Whether the Document answers the Query or matches the content retrieval intent",+ Default: "Whether the document answers the query or matches the content retrieval intent",Placeholder: "Instruction passed to the rerank model",Placeholders: map[string]string{"zh-CN": "传给重排模型的 instruction",@@ -223,7 +221,11 @@ func init() {MaxBatchSize: catalog.Ptr(1),},Rerank: catalog.RerankCompat{- MaxDocuments: catalog.Ptr(50),+ // datas "数组长度不超过 200"+ // (https://docs.volcengine.com/docs/vector_database_vikingdb/Rerank).+ // The pre-catalog client split at 50, a constant of its own+ // rather than a documented ceiling.+ MaxDocuments: catalog.Ptr(200),MaxConcurrency: catalog.Ptr(4),},OpenAICompletions: catalog.OpenAICompletionsCompat{diff --git a/website-docs/03-features/06-models.md b/website-docs/03-features/06-models.mdindex 3d8ccf7e6..53679812f 100644--- a/website-docs/03-features/06-models.md+++ b/website-docs/03-features/06-models.md@@ -269,6 +269,12 @@ make model-catalog-diff VENDOR=deepseek # 只看一家3. **`api.openai.com` 的一方流量改走 Responses 协议**(`PreferAPI` 只对官方域生效)。各类中转 / 网关仍走 Chat Completions,`parity` 包里有断言钉住这一点。4. **7 家厂商的输出上限字段按文档纠正**:hunyuan、modelscope、qiniu、requesty、longcat、novita 由 `max_completion_tokens` 改回 `max_tokens`,moonshot 反向改为 `max_completion_tokens`。每一处在 `internal/models/parity/parity_test.go` 里都记了变更理由与厂商文档。aliyun 保持 `max_completion_tokens` 不变:兼容模式两个字段都收,但 DashScope 的参数表已经把 `max_tokens` 标为即将废弃并指名了继任者。+Rerank 行(逐厂商的出站请求由 `internal/models/rerank/wire_test.go` 钉住,含火山与 LKEAP 两个签名 SDK 客户端):++1. **OpenAI 不再出现在 rerank 的厂商列表里**。OpenAI 的 API 没有 rerank 接口,在这里建的行只会 404;架在 OpenAI 风格地址后面、自带 rerank 的中转请建成 generic 行。已有的行照常解析。+2. **火山 rerank 每次最多 200 条**(文档:datas「数组长度不超过 200」),旧实现按自己定的 50 条切分。+3. **火山 rerank 的默认指令改为控制台原文** `Whether the document answers the query or matches the content retrieval intent`,文档要求「如需对齐控制台效果,请使用相同指令」;旧默认值把 Document / Query 写成了大写。已在额外字段里保存了指令的行不受影响。+Embedding 行也有几处按厂商文档纠正的行为变化(逐厂商的出站请求由 `internal/models/embedding/wire_test.go` 钉住):1. **托管厂商不再收到 `truncate_prompt_tokens`**。此前所有 OpenAI 兼容厂商都被塞了一个 511,它只是 vLLM 的扩展参数;`generic`、`gpustack` 照旧发送。