Skip to content

fix(serve): accept keep_alive as number or string#30

Merged
sharpninja merged 1 commit intomainfrom
fix/keep-alive-polymorphic
Apr 23, 2026
Merged

fix(serve): accept keep_alive as number or string#30
sharpninja merged 1 commit intomainfrom
fix/keep-alive-polymorphic

Conversation

@sharpninja
Copy link
Copy Markdown
Owner

Summary

Ollama wire protocol allows keep_alive as either a duration string ("5m", "10s", "-1", "0") or an integer seconds. Real ollama CLI sends a number; open-webui sends a string. Previous DTO typed keep_alive as string?, which 500'd on numeric input:

Cannot get the value of a token type 'Number' as a string.

Changed OllamaChatRequest, OllamaGenerateRequest, and OllamaEmbeddingsRequest to JsonElement? so either shape deserializes cleanly. Field is still not used by the server (no lifecycle management yet), just consumed and ignored.

Test plan

  • 3 new tests cover number + string forms on /api/chat and /api/generate
  • Serve suite: 45 -> 48 green
  • Repro was ollama run bitnet-b1.58-sharp "hello" hitting 500 with the above exception

🤖 Generated with Claude Code

Ollama wire protocol allows keep_alive as either a duration string
("5m", "10s", "-1", "0") or an integer seconds. Real ollama CLI sends
a number; open-webui sends a string. Previous DTO typed keep_alive as
string? which 500'd on numeric input with:

  Cannot get the value of a token type 'Number' as a string.

Change OllamaChatRequest, OllamaGenerateRequest, and
OllamaEmbeddingsRequest to accept JsonElement? so either shape
deserializes cleanly. The field is still not used by the server (no
model lifecycle management yet), just consumed and ignored.

Three new tests cover number + string forms on /api/chat and
/api/generate. Serve suite: 45 -> 48 green.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@sharpninja sharpninja merged commit d154799 into main Apr 23, 2026
1 of 2 checks passed
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