Skip to content

Fix Ollama keep_alive error for numeric values like -1#625

Open
zestysoft wants to merge 1 commit intovalentinfrlch:mainfrom
zestysoft:fix/ollama-keep-alive-numeric-values
Open

Fix Ollama keep_alive error for numeric values like -1#625
zestysoft wants to merge 1 commit intovalentinfrlch:mainfrom
zestysoft:fix/ollama-keep-alive-numeric-values

Conversation

@zestysoft
Copy link
Copy Markdown

@zestysoft zestysoft commented Mar 21, 2026

Summary

  • When keep_alive is set to -1 (forever) or 0 (unload immediately), the config flow stores them as strings ("-1", "0")
  • Ollama's Go backend fails to parse these: time: missing unit in duration "-1"
  • Added _normalize_keep_alive() to convert pure numeric strings to integers before sending to the API, while leaving duration strings like "5m" unchanged

Problem

ERROR (MainThread) [custom_components.llmvision.providers] Provider Ollama failed: time: missing unit in duration "-1"
ERROR (MainThread) [custom_components.llmvision.providers] Provider Ollama failed to generate title: time: missing unit in duration "-1"

🤖 Generated with Claude Code

When keep_alive is set to "-1" (forever) or "0" (unload immediately),
the value is stored as a string from the config flow. Ollama's Go
backend fails to parse these with: "time: missing unit in duration".
Ollama accepts -1 and 0 as integers, so convert pure numeric strings
to int before sending to the API.

Fixes the error: Provider Ollama failed: time: missing unit in duration "-1"

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@zestysoft
Copy link
Copy Markdown
Author

fwiw, this was tested in my live environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant