Trained adapters published, private to their owners like the knowledge bases they come from

An adapter now has an owner (org, team, project, user or key): only callers
there see it, and to anyone else it is a model that does not exist, absent
from /v1/models too. A training job's owner defaults to the one collection
its pairs come from, must be able to read every collection they come from,
and pairs from a knowledge base are never made public. ctl train publish
keeps the GGUF or PEFT files on the mirror, which accepts uploads now, and
sets the owned adapter after the usual architecture check.

The knowledge bases' cache_salt follows the collections searched rather
than the organization, so two teams of one organization no longer share
cached passages.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-10-08 21:30:50 +02:00
1 parent 964b35ae65
commit 85025dfb03
29 files changed
+1049 -84

No files matched your search

+10 -7
View File
@@ -26,11 +26,14 @@ type KBDatasetRequest struct {
// KBDatasetLine is one line of the answer: a pair, or why a chunk gave none.
type KBDatasetLine struct {
Q string `json:"q,omitempty"`
A string `json:"a,omitempty"`
Doc string `json:"doc"`
Ord int `json:"ord"`
Error string `json:"error,omitempty"`
Q string `json:"q,omitempty"`
A string `json:"a,omitempty"`
Doc string `json:"doc"`
Ord int `json:"ord"`
// Collection is where the pair came from: an adapter trained on it
// belongs to a part of the tree that may read it.
Collection string `json:"collection,omitempty"`
Error string `json:"error,omitempty"`
}
const kbDatasetPrompt = `From the passage of an organisation's document below, write %d different questions an employee might ask, each with a short, correct answer.
@@ -93,7 +96,7 @@ func (a *API) kbDataset(w http.ResponseWriter, r *http.Request) {
body, _ := json.Marshal(map[string]any{"model": m.Name, "temperature": 0.7, "max_tokens": 200 * per,
"messages": []map[string]string{{"role": "user", "content": fmt.Sprintf(kbDatasetPrompt, per, ch.Document, ch.Body)}}})
status, out, _, err := a.replay(r.Context(), "/v1/chat/completions", m.Name, body)
line := KBDatasetLine{Doc: ch.Document, Ord: ch.Ord}
line := KBDatasetLine{Doc: ch.Document, Ord: ch.Ord, Collection: c.ID}
if err == nil && status != http.StatusOK {
err = fmt.Errorf("%d: %s", status, strings.TrimSpace(string(out)))
}
@@ -109,7 +112,7 @@ func (a *API) kbDataset(w http.ResponseWriter, r *http.Request) {
_ = enc.Encode(line)
}
for _, p := range pairs {
p.Doc, p.Ord = ch.Document, ch.Ord
p.Doc, p.Ord, p.Collection = ch.Document, ch.Ord, c.ID
_ = enc.Encode(p)
}
flush()