feat: add FOREMAN_KEEP_ALIVE config for worker model residency
Allow configuring how long the worker model stays resident on the Ollama
target after a request via FOREMAN_KEEP_ALIVE env var. Accepts Ollama
duration strings ("-1" forever, "0" unload, "15m", "1h", etc). Defaults
to "-1" (pin forever). The embedder warm-up is unaffected and always
uses keep_alive=-1.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -48,6 +48,13 @@ type Config struct {
|
||||
// JobTTL is how long terminal jobs are retained before the pruner deletes them
|
||||
// (default 24h).
|
||||
JobTTL time.Duration
|
||||
|
||||
// KeepAlive is the keep_alive value sent in outbound /api/chat requests to the
|
||||
// Ollama target. It controls how long the worker model stays resident after a
|
||||
// request. Accepts Ollama duration strings like "15m", "1h", "-1" (forever), or
|
||||
// "0" (unload immediately). Default is "-1" (pin forever). This does NOT affect
|
||||
// the embedder, which is always pinned with keep_alive=-1.
|
||||
KeepAlive string
|
||||
}
|
||||
|
||||
// Load reads configuration from environment variables and returns a validated Config.
|
||||
@@ -64,6 +71,7 @@ func Load() (Config, error) {
|
||||
EmbedModel: os.Getenv("FOREMAN_EMBED_MODEL"),
|
||||
DBPath: envOr("FOREMAN_DB_PATH", "foreman.db"),
|
||||
WebhookSecret: os.Getenv("FOREMAN_WEBHOOK_SECRET"),
|
||||
KeepAlive: envOr("FOREMAN_KEEP_ALIVE", "-1"),
|
||||
}
|
||||
|
||||
pollStr := envOr("FOREMAN_POLL_INTERVAL", "30s")
|
||||
|
||||
Reference in New Issue
Block a user