fix(serve): accept keep_alive as number or string#30
Merged
sharpninja merged 1 commit intomainfrom Apr 23, 2026
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ollama wire protocol allows
keep_aliveas 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 typedkeep_aliveasstring?, which 500'd on numeric input:Changed
OllamaChatRequest,OllamaGenerateRequest, andOllamaEmbeddingsRequesttoJsonElement?so either shape deserializes cleanly. Field is still not used by the server (no lifecycle management yet), just consumed and ignored.Test plan
/api/chatand/api/generateollama run bitnet-b1.58-sharp "hello"hitting 500 with the above exception🤖 Generated with Claude Code