feat: expose model database updates through the public Go SDK
I maintainer di solito rispondono entro 1 giorno
Una pull request collegata è già stata integrata.
- #256 di @ezynda3 — integrata
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
Start by reading pkg/kit/models.go, cmd/update_models.go, and internal/models/cache.go at the pinned commit to understand current update logic. Extract the operation into reusable Kit code and expose it via pkg/kit as UpdateModels. Add hermetic tests with temp dirs and local HTTP servers; done means public SDK updates models atomically with CLI behavior unchanged.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Feature Description
Expose the kit update-models operation through github.com/mark3labs/kit/pkg/kit. Embedders should be able to update the shared model database without installing or executing the Kit CLI.
The SDK should support the existing source choices: default models.dev URL (including all model types), KIT_MODELS_URL, an explicit HTTP(S) URL, a local JSON file, and reset to the embedded database. Keep cache paths, schema versions, catalog decoding, and conditional HTTP requests inside Kit.
Motivation / Use Case
BONNIE wants bonnie update models and ./my-agent update models in compiled agent binaries: https://github.com/mark3labs/bonnie/issues/59.
BONNIE imports only Kit's public SDK. At its pinned Kit v0.136.0 (c50c75cbdd467614092116b049d5fcf43d6dc6b5):
pkg/kit/models.go:5-41exposes registry queries, but no update operation.cmd/update_models.go:50-168owns source selection, download, local-file import, and reset. It writes directly to stderr and starts its timeout fromcontext.Background().internal/models/cache.go:34-73owns schema version 3 and the sharedproviders.jsondata path. The write and remove functions are also internal (lines 111-148).
These internal functions cannot be imported by an external Go module. Writing the cache independently would couple BONNIE to Kit's private schema. This is a request for a supported public operation, not for public access to the private cache structs.
Proposed Implementation
Extract the operation into reusable Kit code and make both the Kit CLI and a public SDK wrapper use it. Exact API names are open; an illustrative shape is:
func UpdateModels(ctx context.Context, opts UpdateModelsOptions) (UpdateModelsResult, error)
Requested contract:
- Accept caller cancellation and use a bounded network timeout (the CLI currently uses 30 seconds).
- Return structured results for updated, not-modified, and reset states, with provider/model counts where applicable. Do not print, parse CLI arguments, start a model, or require provider credentials.
- Preserve Kit's shared cache location and schema handling; support ETag/304 behavior without allowing a validator from one source to mask data from another source.
- Validate input before replacing the cache. A failed download or invalid input must not destroy the previous usable cache; use atomic replacement so readers do not see a partial file.
- Document whether an already loaded registry sees updates. Restart/next-process visibility is sufficient for BONNIE; live registry reload is not required.
- Add hermetic tests with temporary data directories and local HTTP servers for source selection, 200/304 responses, malformed/empty data, cancellation, failed writes, and embedded reset. Keep CLI behavior compatible.
Alternatives Considered
- I've considered workarounds or alternative approaches
Installing/executing Kit separately defeats the standalone-binary use case. Importing kit/internal/models is not allowed by Go. Copying Kit's updater or independently maintaining its cache schema would create a second implementation that can drift.
Checklist
- I've searched existing issues and this hasn't been requested yet
Searched open and closed issues for model update API, update-models, and model database. No matching public-updater request was found. This request follows the existing public-SDK pattern used for provider OAuth login (#180).
- Lingua principale
- Go
- Stelle
- 146
- Fork
- 31
- Merge medio
- 4h 35m
- PR unite (30g)
- 54
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di mark3labs/kit
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 24/100
mark3labs/kit#253 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di mark3labs/kit
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
area/frontend/library-panels automated-triage type/bug type/ux
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
deskevidence: --dry-run is ignored with --outcome-record, so the record is committed for realApertabug raised-by:verifier
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
medici-finance/assay#4554 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
microsoft/azure-linux-image-tools#954 ·
I maintainer di solito rispondono entro 1 giorno
-
help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno