diff --git a/README.md b/README.md index 75eeb8a..538e666 100644 --- a/README.md +++ b/README.md @@ -78,10 +78,11 @@ One model. Two of its keys decide whether the service can run at all; the third | `serveArgs` | The full argument list handed to `llama-server`, composed by the Set Model action | | `uiPassword` | The password for the proxy's basic auth; the username is always `admin` | | `modelSelection` | What the Set Model form last submitted, so it can be prefilled next time — read by nothing else | +| `modelSettings` | Context size, GPU layers and extra flags last used for each model — read only by Set Model | Nothing else writes the file, and neither `serveArgs` nor `uiPassword` is defaulted — both are absent until you run their action, and each absence raises a task. -`modelSelection` holds the chosen `selection` plus, when Custom was chosen, a `custom` object carrying that variant's fields; picking a preset clears `custom`. The daemon never reads it, so it cannot disagree with `serveArgs` about what is actually running — at worst it prefills a form with a stale answer. +`modelSelection` holds the chosen `selection` plus a `custom` object with the last Custom submission's fields; picking another entry leaves `custom` in place so Custom stays prefilled. `modelSettings` is a list of `{hfRepo, hfFile, ctx, ngl, extraArgs}`, one per model, replaced on each submit of that model. Entries are matched to the list by the weights they resolve to — the same cached file, or the same quant tag before download — so a Custom model keeps its settings once it shows up as a downloaded entry. Stores from before `modelSettings` fall back to `modelSelection.custom`. The daemon reads neither, so they cannot disagree with `serveArgs` about what is actually running — at worst they prefill a form with a stale answer. **No configuration file reaches the application.** Two environment variables are set, both redirecting caches onto the volume so downloaded weights survive a container rebuild: @@ -127,12 +128,13 @@ Three actions, all user-facing. Chooses what the server runs — either a curated preset or a model of your own. -- **What it changes:** `serveArgs` and `modelSelection` in `store.json`, replacing each entirely. +- **What it changes:** `serveArgs` and `modelSelection` in `store.json`, replacing each entirely, and the chosen model's entry in `modelSettings`. - **Cost:** seconds to write, then a restart — and, if the model is not already cached, a download that can take a long time. - **Repeat safety:** safe to re-run. Switching back to a previously used model is fast, because the old one is still cached. -- **The form reopens on your current selection**, read back from `modelSelection`, so changing one setting does not mean re-entering the rest. With nothing chosen yet it falls back to the hardware-filtered default. +- **Every entry has its own context size, GPU layers and extra flags**, prefilled with what that model last ran with (`modelSettings`), or with the preset's context and full GPU offload the first time. Switching to another model and back keeps them. +- **The form reopens on the running model**, which stays selectable: change its settings and submit to restart with them. Submitting it unchanged writes the same `serveArgs` and does not restart. With nothing chosen yet the form falls back to the hardware-filtered default. - **Presets are filtered to your hardware.** The form reads the accelerator's memory — VRAM on NVIDIA and ROCm, system memory otherwise — and disables any preset that would not fit, defaulting to the smallest that does. The field's help text lists every preset with the memory it needs. The estimate is the quantized weights plus roughly a quarter for the context cache. -- **Models already downloaded to the volume appear in the same list**, so a model you fetched before can be reselected without retyping its repo or re-downloading it. A downloaded file that is a preset's quant stays under that preset, while other quants of the same repo get their own entries. A downloaded entry is passed to `llama-server` as `-hf / -hff ` so the exact cached quant is reused. Those entries run at a fixed 8192-token context with full GPU offload; use Custom for anything else. +- **Models already downloaded to the volume appear in the same list**, so a model you fetched before can be reselected without retyping its repo or re-downloading it. A downloaded file that is a preset's quant stays under that preset, while other quants of the same repo get their own entries. A downloaded entry is passed to `llama-server` as `-hf / -hff ` so the exact cached quant is reused; a first-time downloaded entry defaults to an 8192-token context. When the entry is the running model, its repo and file arguments are kept as they were written. - **Custom** takes a HuggingFace GGUF repo, optionally a specific file, a context size, a GPU-layer count, and extra server flags. Those extra flags are split on whitespace, so a quoted value with spaces will not survive. ### Set UI Password @@ -169,8 +171,8 @@ Because they are conditional, clearing either value later raises its task again One check, on the daemon. -| Check | Method | Grace Period | -| ------------------------- | ---------------------- | ------------ | +| Check | Method | Grace Period | +| ------------------------- | ---------------------------------------- | ------------ | | `primary` "llama.cpp API" | HTTP GET `/health` on port 8080 succeeds | 1 hour | **The hour-long grace is for the model download**, which happens on the first start after a selection and is bounded only by size and bandwidth. The server opens its port before loading the model, but `/health` returns HTTP 503 until loading completes; an open port alone is not readiness. The probe runs inside `llama-cpp-sub`, bypassing the proxy's authentication. A failure after the grace period calls for checking download errors, available memory, and the daemon logs. @@ -195,7 +197,7 @@ The `main` volume is backed up — `sdk.Backups.ofVolumes('main')` — with one 6. **Model presets are filtered by detected memory**, and the fit estimate is approximate — a preset that is enabled can still be tight at large context sizes. 7. **Extra server flags are split on whitespace**, so quoted arguments containing spaces do not survive. 8. **Models are excluded from backups.** After a restore, the selected model downloads again on first start. -9. **Downloaded models are listed by repo and file.** A cached file matching a curated preset's quant is not duplicated; other quants from the same repo remain separate entries. Downloaded entries do not expose context or GPU-layer settings — use Custom for those. +9. **Downloaded models are listed by repo and file.** A cached file matching a curated preset's quant is not duplicated; other quants from the same repo remain separate entries. Settings are remembered per model, so deleting a model with Delete Model Cache and downloading it again keeps them. 10. **Saved inference states are upstream-version-specific.** Custom `--slot-save-path` caches may need to be recreated after an update; the package does not convert them. This does not affect downloaded GGUF weights or `store.json`. --- diff --git a/instructions.md b/instructions.md index c80d72f..9e1a607 100644 --- a/instructions.md +++ b/instructions.md @@ -16,7 +16,7 @@ Two tasks appear on the dashboard on a fresh install: 1. **Set UI Password** — generates your web UI login password. The username is always `admin`; copy the password it returns (you'll need it the first time you open the UI or connect a client). Run it again any time to rotate the password. -2. **Set Model** — choose what llama.cpp serves. The form shows curated presets, lists the memory each one needs, and disables ones too large for the detected memory. Models you have already downloaded are listed too, so you can switch back to one without re-entering or re-downloading it. If none of the presets fit, pick **Custom** and paste a HuggingFace repo such as `unsloth/Qwen2.5-7B-Instruct-GGUF:Q4_K_M`. On a GPU variant, leave `GPU layers` at 999 to offload everything; on the CPU-only `generic` variant the field is ignored. +2. **Set Model** — choose what llama.cpp serves. The form shows curated presets, lists the memory each one needs, and disables ones too large for the detected memory. Models you have already downloaded are listed too, so you can switch back to one without re-entering or re-downloading it. Every entry has its own context size, GPU layers and extra arguments, and remembers what you last used with that model. If none of the presets fit, pick **Custom** and paste a HuggingFace repo such as `unsloth/Qwen2.5-7B-Instruct-GGUF:Q4_K_M`. On a GPU variant, leave `GPU layers` at 999 to offload everything; on the CPU-only `generic` variant the field is ignored. Complete both tasks, then start the service from the dashboard. The first launch downloads weights — expect several gigabytes and a few minutes (or longer over a slow link) before the API answers. The API health check stays pending until the model finishes loading, even if the chat UI opens earlier. Subsequent restarts are fast. @@ -44,7 +44,7 @@ curl -s -u admin: /v1/chat/completions \ ### Actions -- **Set Model** — switch to a different preset, a model you already downloaded, or a custom GGUF. The form opens with your current selection already filled in, so you can change one setting without re-entering the rest. The service restarts with the new weights; uncached models download on this restart. +- **Set Model** — switch to a different preset, a model you already downloaded, or a custom GGUF. The form opens on the model you are running, with its settings filled in, so you can change its context size or flags and submit; submitting without changes does not restart anything. Each model remembers its own settings, so switching away and back keeps them. The service restarts with the new weights; uncached models download on this restart. - **Set UI Password** — generate a new web UI password (username stays `admin`). Use it for first-time setup or to rotate the password later; when rotating, it asks you to confirm, since saved logins stop working. - **Delete Model Cache** — pick a downloaded model from the list, with its size, and remove it to reclaim disk space. The model you are currently running can't be deleted; switch to another one with Set Model first. A deleted model will be re-downloaded if you select it again. @@ -52,5 +52,4 @@ curl -s -u admin: /v1/chat/completions \ - **One model at a time.** Switching models restarts the service. - **Models are large.** A 70B Q4 file is ~40 GB; even small models are several gigabytes. Confirm free disk before selecting a preset. -- **Already-downloaded models are added to the list with fixed settings.** They run at an 8192-token context with full GPU offload; pick **Custom** if you need a different context size or extra flags. - **Saved slot caches may not survive an upstream update.** If you use `--slot-save-path` in Custom's extra arguments and restoring an old slot fails, replay its prompt and save the slot again. Your downloaded model weights are unaffected. diff --git a/startos/actions/setModel.ts b/startos/actions/setModel.ts index 03875f7..1b7ef4e 100644 --- a/startos/actions/setModel.ts +++ b/startos/actions/setModel.ts @@ -14,32 +14,44 @@ import { isGpuVariant, lastOptionValue, } from '../utils' -import { models } from './presets' +import { models, type ModelPreset } from './presets' const { InputSpec, Value, Variants } = sdk const cachedPrefix = 'cached:' const cachedCtx = 8192 +const defaultNgl = 999 const cachedId = (repo: string, file: string) => `${cachedPrefix}${repoFolderName(repo)}:${file}` type ServeTarget = { repo: string; quant?: string; file?: string } +type ModelSettings = { ctx: number; ngl: number; extraArgs?: string } + +type SavedSettings = ModelSettings & { hfRepo: string; hfFile?: string } + +type Store = NonNullable>> + +const readStore = (effects: T.Effects) => storeJson.read().const(effects) + +// `repo:QUANT` plus an optional explicit file, as given to `-hf`/`-hff`. +function parseTarget(hfRepo: string, hfFile?: string): ServeTarget { + const [repo, quant] = hfRepo.split(':') + return { repo, quant: quant || undefined, file: hfFile || undefined } +} + +const presetTarget = (model: ModelPreset) => + parseTarget(model.hfRepo, model.hfFile) + // The repo, optional quant tag, and optional explicit file the daemon was last // started with. Custom entries are written as `repo:QUANT` with no `-hff`, so // the quant tag is what identifies the running file. -async function serveTarget(effects: T.Effects): Promise { - const serveArgs = - (await storeJson.read((s) => s?.serveArgs).const(effects)) ?? [] +function serveTarget(store: Store | null): ServeTarget | null { + const serveArgs = store?.serveArgs ?? [] const repoArg = lastOptionValue(serveArgs, hfRepoFlags) if (!repoArg) return null - const [repo, quant] = repoArg.split(':') - return { - repo, - quant: quant || undefined, - file: lastOptionValue(serveArgs, hfFileFlags), - } + return parseTarget(repoArg, lastOptionValue(serveArgs, hfFileFlags)) } // The cached file the target refers to. An explicit `-hff` wins; otherwise the @@ -60,30 +72,50 @@ function targetFile( return files.length === 1 ? files[0] : undefined } +// Whether two targets name the same weights: the same cached file once both +// resolve to one, otherwise the same quant tag with no explicit file. +function sameModel(a: ServeTarget, b: ServeTarget, cached: CachedModel[]) { + if (a.repo !== b.repo) return false + const fileA = targetFile(a, cached) + const fileB = targetFile(b, cached) + if (fileA && fileB) return fileA === fileB + return ( + !a.file && + !b.file && + (a.quant ?? '').toLowerCase() === (b.quant ?? '').toLowerCase() + ) +} + function matchingPreset(target: ServeTarget, cached: CachedModel[]) { - const file = targetFile(target, cached) - return models.find((model) => { - const [repo, quant] = model.hfRepo.split(':') - if (repo !== target.repo) return false - const presetTarget = { repo, quant, file: model.hfFile } - const presetFile = targetFile(presetTarget, cached) - if (file && presetFile) return file === presetFile - return ( - !target.file && - !model.hfFile && - (target.quant ?? '').toLowerCase() === (quant ?? '').toLowerCase() - ) - }) + return models.find((model) => sameModel(target, presetTarget(model), cached)) +} + +// The settings this model was last run with. Stores written before +// `modelSettings` existed only have the last Custom submission. +function settingsFor( + target: ServeTarget, + store: Store | null, + cached: CachedModel[], +): ModelSettings | undefined { + const candidates: SavedSettings[] = [ + ...(store?.modelSelection?.custom ? [store.modelSelection.custom] : []), + ...(store?.modelSettings ?? []), + ] + const saved = candidates + .filter((s) => sameModel(target, parseTarget(s.hfRepo, s.hfFile), cached)) + .pop() + return saved && { ctx: saved.ctx, ngl: saved.ngl, extraArgs: saved.extraArgs } } // The dropdown entry that matches the model actually running, if it is one of // ours. A Custom entry that has since been downloaded resolves to its cache -// entry, so the running model shows up checked and disabled rather than as a -// duplicate next to a checked Custom. -async function inUseVariantId(effects: T.Effects): Promise { - const target = await serveTarget(effects) +// entry, so the running model shows up once rather than as a duplicate next to +// a Custom. +function inUseVariantId( + target: ServeTarget | null, + cached: CachedModel[], +): string | null { if (!target) return null - const cached = await listCachedModels() const preset = matchingPreset(target, cached) if (preset) return preset.id const file = targetFile(target, cached) @@ -92,6 +124,43 @@ async function inUseVariantId(effects: T.Effects): Promise { return match ? cachedId(match.repo, match.file) : null } +// Context, GPU layers and extra flags, prefilled with `defaults`. Shared by +// every entry so each model keeps its own. +const settingsFields = (defaults: ModelSettings) => ({ + ctx: Value.number({ + name: i18n('Context size'), + description: i18n( + 'Maximum context length in tokens. 0 uses the model default.', + ), + required: true, + default: defaults.ctx, + min: 0, + max: 1024 * 1024, + step: 1, + integer: true, + }), + ngl: Value.number({ + name: i18n('GPU layers'), + description: i18n( + 'Number of model layers to offload to GPU. Use a large value (e.g. 999) to offload everything; ignored on the generic CPU variant.', + ), + required: true, + default: defaults.ngl, + min: 0, + max: 999, + step: 1, + integer: true, + }), + extraArgs: Value.text({ + name: i18n('Extra arguments'), + description: i18n( + 'Additional llama-server flags, space-separated. Advanced — split on whitespace, so quoted values will not survive.', + ), + required: false, + default: defaults.extraArgs ?? null, + }), +}) + const customVariant = { name: i18n('Custom'), spec: InputSpec.of({ @@ -111,38 +180,7 @@ const customVariant = { required: false, default: null, }), - ctx: Value.number({ - name: i18n('Context size'), - description: i18n( - 'Maximum context length in tokens. 0 uses the model default.', - ), - required: true, - default: 8192, - min: 0, - max: 1024 * 1024, - step: 1, - integer: true, - }), - ngl: Value.number({ - name: i18n('GPU layers'), - description: i18n( - 'Number of model layers to offload to GPU. Use a large value (e.g. 999) to offload everything; ignored on the generic CPU variant.', - ), - required: true, - default: 999, - min: 0, - max: 999, - step: 1, - integer: true, - }), - extraArgs: Value.text({ - name: i18n('Extra arguments'), - description: i18n( - 'Additional llama-server flags, space-separated. Advanced — split on whitespace, so quoted values will not survive.', - ), - required: false, - default: null, - }), + ...settingsFields({ ctx: cachedCtx, ngl: defaultNgl }), }), } @@ -150,6 +188,7 @@ const inputSpec = InputSpec.of({ config: Value.dynamicUnion(async ({ effects }) => { const { memoryGB } = await detectHardware(effects) const enabledPresets = models.filter((m) => memoryGB >= m.minMemoryGB) + const store = await readStore(effects) // Anything already on disk can be selected again without re-downloading. // Preset files are left out because their entry is already in the list. const allCached = await listCachedModels() @@ -167,7 +206,14 @@ const inputSpec = InputSpec.of({ (filesPerRepo.get(c.repo) ?? 0) > 1 ? `${c.repo} · ${c.file}` : c.repo, - spec: InputSpec.of({}), + spec: InputSpec.of( + settingsFields( + settingsFor(c, store, allCached) ?? { + ctx: cachedCtx, + ngl: defaultNgl, + }, + ), + ), }, ]) @@ -175,37 +221,38 @@ const inputSpec = InputSpec.of({ ...Object.fromEntries( models.map((m) => [ m.id, - { name: i18n(m.displayName), spec: InputSpec.of({}) }, + { + name: i18n(m.displayName), + spec: InputSpec.of( + settingsFields( + settingsFor(presetTarget(m), store, allCached) ?? { + ctx: m.defaultCtx, + ngl: defaultNgl, + }, + ), + ), + }, ]), ), ...Object.fromEntries(cachedVariants), custom: customVariant, } - const inUseId = await inUseVariantId(effects) - const savedSelection = await storeJson - .read((s) => s?.modelSelection?.selection) - .const(effects) - + // The running model stays selectable so its settings can be changed; + // submitting it unchanged writes the same arguments and does not restart. + const inUseId = inUseVariantId(serveTarget(store), allCached) const enabledIds = new Set([ ...enabledPresets.map((m) => m.id), ...cachedVariants.map(([id]) => id as string), 'custom', ]) - // The model already in use cannot be selected again; it would only trigger - // a pointless restart. Custom stays enabled so its fields remain editable. - const disabledId = - inUseId ?? (savedSelection !== 'custom' ? savedSelection : undefined) - if (disabledId && disabledId in variants) { - enabledIds.delete(disabledId) - } const disabledIds = Object.keys(variants).filter( (id) => !enabledIds.has(id), ) - const selectable = (id: string) => !disabledIds.includes(id) const defaultId = - enabledPresets.find((m) => selectable(m.id))?.id ?? - cached.map((c) => cachedId(c.repo, c.file)).find(selectable) ?? + (inUseId && enabledIds.has(inUseId) ? inUseId : undefined) ?? + enabledPresets[0]?.id ?? + cachedVariants[0]?.[0] ?? 'custom' return { @@ -219,12 +266,34 @@ const inputSpec = InputSpec.of({ `- ${i18n('Custom')}: ${i18n('any HuggingFace GGUF model, with your own context size, GPU layers and server flags')}`, ].join('\n'), variants: Variants.of(variants), - default: defaultId, + default: defaultId as string, disabled: disabledIds.length > 0 ? disabledIds : false, } }), }) +// The settings as form values; the text field takes null, not undefined. +const settingsValue = (s: ModelSettings) => ({ + ctx: s.ctx, + ngl: s.ngl, + extraArgs: s.extraArgs ?? null, +}) + +function serveArgsFor( + hfRepo: string, + hfFile: string | undefined, + settings: ModelSettings, +): string[] { + const serveArgs = ['-hf', hfRepo] + if (hfFile) serveArgs.push('-hff', hfFile) + if (settings.ctx > 0) serveArgs.push('-c', String(settings.ctx)) + if (isGpuVariant) serveArgs.push('-ngl', String(settings.ngl)) + if (settings.extraArgs) { + serveArgs.push(...settings.extraArgs.split(/\s+/).filter(Boolean)) + } + return serveArgs +} + export const setModel = sdk.Action.withInput( 'set-model', @@ -244,116 +313,102 @@ export const setModel = sdk.Action.withInput( inputSpec, async ({ effects }) => { - const inUseId = await inUseVariantId(effects) - const saved = await storeJson.read((s) => s?.modelSelection).const(effects) - if (inUseId) { - // Show the running model as the selection; keep the Custom fields around - // so switching back to Custom is still prefilled. - return saved?.selection === 'custom' - ? { - config: { - selection: inUseId, - value: {}, - other: { custom: saved.custom }, - }, - } - : { config: { selection: inUseId, value: {} } } + const store = await readStore(effects) + const cached = await listCachedModels() + const target = serveTarget(store) + const inUseId = inUseVariantId(target, cached) + const saved = store?.modelSelection + // Keep the Custom fields around so switching to Custom is still prefilled. + const other = saved?.custom ? { other: { custom: saved.custom } } : {} + if (target && inUseId) { + const settings = settingsFor(target, store, cached) + return { + config: { + selection: inUseId, + value: settings ? settingsValue(settings) : {}, + ...other, + }, + } } if (!saved) return {} const selection = saved.selection if (selection === 'custom') { return { config: { selection, value: saved.custom ?? {} } } } - if (selection.startsWith(cachedPrefix)) { - const cached = await listCachedModels() - if (!cached.some((c) => cachedId(c.repo, c.file) === selection)) return {} - return { config: { selection, value: {} } } - } - if (models.some((m) => m.id === selection)) { - return { config: { selection, value: {} } } + const preset = models.find((m) => m.id === selection) + const selected = preset + ? presetTarget(preset) + : cached.find((c) => cachedId(c.repo, c.file) === selection) + if (!selected) return {} + const settings = settingsFor(selected, store, cached) + return { + config: { + selection, + value: settings ? settingsValue(settings) : {}, + ...other, + }, } - return {} }, async ({ effects, input }) => { const config = input.config - let serveArgs: string[] - let modelSelection: { - selection: string - custom: - | { - hfRepo: string - hfFile?: string - ctx: number - ngl: number - extraArgs?: string - } - | undefined + const store = await storeJson.read().once() + const cached = await listCachedModels() + const running = serveTarget(store) + const settings: ModelSettings = { + ctx: config.value.ctx, + ngl: config.value.ngl, + extraArgs: config.value.extraArgs?.trim() || undefined, } + let hfRepo: string + let hfFile: string | undefined if (config.selection === 'custom') { - const v = config.value - serveArgs = ['-hf', v.hfRepo] - if (v.hfFile && v.hfFile.trim().length > 0) { - serveArgs.push('-hff', v.hfFile.trim()) - } - if (v.ctx > 0) serveArgs.push('-c', String(v.ctx)) - if (isGpuVariant) serveArgs.push('-ngl', String(v.ngl)) - if (v.extraArgs && v.extraArgs.trim().length > 0) { - serveArgs.push(...v.extraArgs.split(/\s+/).filter(Boolean)) - } - modelSelection = { - selection: 'custom', - custom: { - hfRepo: v.hfRepo, - hfFile: v.hfFile?.trim() || undefined, - ctx: v.ctx, - ngl: v.ngl, - extraArgs: v.extraArgs?.trim() || undefined, - }, - } - } else if (config.selection.startsWith(cachedPrefix)) { - const cached = await listCachedModels() - const match = cached.find( - (c) => cachedId(c.repo, c.file) === config.selection, - ) - if (!match) { - throw new Error( - i18n('That downloaded model is no longer in the cache.'), - ) - } - const target = await serveTarget(effects) - const isCurrent = - target !== null && - target.repo === match.repo && - targetFile(target, cached) === match.file - if (isCurrent) { - // Already the running model: keep its context and extra flags intact. - await storeJson.merge(effects, { - modelSelection: { selection: config.selection, custom: undefined }, - }) - return - } - serveArgs = [ - '-hf', - match.repo, - '-hff', - match.file, - '-c', - String(cachedCtx), - ] - if (isGpuVariant) serveArgs.push('-ngl', '999') - modelSelection = { selection: config.selection, custom: undefined } + hfRepo = config.value.hfRepo.trim() + hfFile = config.value.hfFile?.trim() || undefined } else { - const preset = models.find((m) => m.id === config.selection) - if (!preset) { - throw new Error(`Unknown preset: ${config.selection}`) + let target: ServeTarget + if (config.selection.startsWith(cachedPrefix)) { + const match = cached.find( + (c) => cachedId(c.repo, c.file) === config.selection, + ) + if (!match) { + throw new Error( + i18n('That downloaded model is no longer in the cache.'), + ) + } + target = match + } else { + const preset = models.find((m) => m.id === config.selection) + if (!preset) { + throw new Error(`Unknown preset: ${config.selection}`) + } + target = presetTarget(preset) } - serveArgs = ['-hf', preset.hfRepo] - if (preset.hfFile) serveArgs.push('-hff', preset.hfFile) - serveArgs.push('-c', String(preset.defaultCtx)) - if (isGpuVariant) serveArgs.push('-ngl', '999') - modelSelection = { selection: config.selection, custom: undefined } + // Already the running model: keep the repo and file arguments as they + // were written, so unchanged settings yield identical serveArgs and no + // restart. + if (running && sameModel(running, target, cached)) target = running + hfRepo = target.quant ? `${target.repo}:${target.quant}` : target.repo + hfFile = target.file } - await storeJson.merge(effects, { serveArgs, modelSelection }) + + const newTarget = parseTarget(hfRepo, hfFile) + const modelSettings: SavedSettings[] = [ + ...(store?.modelSettings ?? []).filter( + (s) => !sameModel(parseTarget(s.hfRepo, s.hfFile), newTarget, cached), + ), + { hfRepo, hfFile, ...settings }, + ] + await storeJson.merge(effects, { + serveArgs: serveArgsFor(hfRepo, hfFile, settings), + modelSelection: { + selection: config.selection, + custom: + config.selection === 'custom' + ? { hfRepo, hfFile, ...settings } + : store?.modelSelection?.custom, + }, + modelSettings, + }) }, ) diff --git a/startos/fileModels/store.json.ts b/startos/fileModels/store.json.ts index 2166586..d17a596 100644 --- a/startos/fileModels/store.json.ts +++ b/startos/fileModels/store.json.ts @@ -19,6 +19,18 @@ const shape = z.looseObject({ }) .optional() .catch(undefined), + modelSettings: z + .array( + z.looseObject({ + hfRepo: z.string(), + hfFile: z.string().optional(), + ctx: z.number(), + ngl: z.number(), + extraArgs: z.string().optional(), + }), + ) + .optional() + .catch(undefined), }) export const storeJson = FileHelper.json( diff --git a/startos/versions/current.ts b/startos/versions/current.ts index 5a7c61b..8f9b389 100644 --- a/startos/versions/current.ts +++ b/startos/versions/current.ts @@ -1,17 +1,17 @@ import { IMPOSSIBLE, VersionInfo } from '@start9labs/start-sdk' export const current = VersionInfo.of({ - version: '11669:1', + version: '11669:2', releaseNotes: { en_US: - 'Stops trusting certificates from a compromised certificate authority (eMudhra).', + 'Set Model now remembers the context size, GPU layers and extra arguments you last used with each model, so switching away and back keeps them. Presets and downloaded models expose these settings too, and the running model can be reselected to change them.', es_ES: - 'Deja de confiar en los certificados de una autoridad de certificación comprometida (eMudhra).', + 'Establecer modelo ahora recuerda el tamaño de contexto, las capas en GPU y los argumentos adicionales que usó por última vez con cada modelo, así que cambiar a otro y volver los conserva. Los presets y los modelos descargados también muestran estos ajustes, y el modelo en uso se puede volver a seleccionar para cambiarlos.', de_DE: - 'Vertraut Zertifikaten einer kompromittierten Zertifizierungsstelle (eMudhra) nicht mehr.', + 'Modell festlegen merkt sich jetzt Kontextgröße, GPU-Layer und zusätzliche Argumente, die Sie zuletzt mit jedem Modell verwendet haben, sodass sie beim Wechsel zu einem anderen Modell und zurück erhalten bleiben. Auch Presets und heruntergeladene Modelle bieten diese Einstellungen, und das laufende Modell kann erneut ausgewählt werden, um sie zu ändern.', pl_PL: - 'Przestaje ufać certyfikatom przejętego urzędu certyfikacji (eMudhra).', - fr_FR: `Ne fait plus confiance aux certificats d'une autorité de certification compromise (eMudhra).`, + 'Ustaw model zapamiętuje teraz rozmiar kontekstu, warstwy GPU i dodatkowe argumenty ostatnio użyte z każdym modelem, więc przełączenie na inny model i z powrotem ich nie traci. Presety i pobrane modele również udostępniają te ustawienia, a uruchomiony model można wybrać ponownie, aby je zmienić.', + fr_FR: `Définir le modèle mémorise désormais la taille de contexte, les couches GPU et les arguments supplémentaires utilisés en dernier avec chaque modèle : passer à un autre modèle puis revenir les conserve. Les préréglages et les modèles téléchargés proposent aussi ces réglages, et le modèle en cours peut être resélectionné pour les modifier.`, }, migrations: { up: async ({ effects }) => {},