LocalAI/core/schema
LocalAI [bot] 661a0c3b9d
fix(ollama): accept float-encoded integer options (fixes #9837) (#9849)
fix(ollama): accept float-encoded integer options (num_ctx, top_k, ...)

Home Assistant's Ollama integration encodes integer options as JSON
floats (e.g. `"num_ctx": 8192.0`). Stdlib `json.Unmarshal` refuses to
decode a number with fractional notation into an `int` field, so the
entire request was rejected with HTTP 400 before reaching the backend:

  Unmarshal type error: expected=int, got=number 8192.0,
  field=options.num_ctx

Add a custom `UnmarshalJSON` on `OllamaOptions` that routes the int
fields (`top_k`, `num_predict`, `seed`, `repeat_last_n`, `num_ctx`)
through `*json.Number`, then converts via `Int64()` with a `Float64()`
fallback. Public field types are unchanged, so endpoint code is
untouched. Float fields and `stop` continue to parse via the default
path.

Fixes #9837

Assisted-by: Claude Code:claude-opus-4-7

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
2026-05-16 18:38:19 +02:00
..
agent_jobs.go feat(api): Allow coding agents to interactively discover how to control and configure LocalAI (#9084) 2026-04-04 15:14:35 +02:00
anthropic.go fix(anthropic): show null index when not present, default to 0 (#9225) 2026-04-04 15:13:17 +02:00
anthropic_test.go feat: add distributed mode (#9124) 2026-03-30 00:47:27 +02:00
audio_transform.go feat: add LocalVQE backend and audio transformations UI (#9640) 2026-05-04 22:07:11 +02:00
backend.go feat: Add backend gallery (#5607) 2025-06-15 14:56:52 +02:00
diarization.go feat(api): add /v1/audio/diarization endpoint with sherpa-onnx + vibevoice.cpp (#9654) 2026-05-05 15:10:13 +02:00
elevenlabs.go feat: add distributed mode (#9124) 2026-03-30 00:47:27 +02:00
finetune.go feat: add distributed mode (#9124) 2026-03-30 00:47:27 +02:00
gallery-model.schema.json [gallery] add JSON schema for gallery model specification (#7890) 2026-01-06 22:10:43 +01:00
jina.go fix(reranker): tests and top_n check fix #7212 (#7284) 2025-11-16 17:53:23 +01:00
localai.go feat(insightface): add antispoofing (liveness) detection (#9515) 2026-04-23 18:28:15 +02:00
message.go feat(vllm): parity with llama.cpp backend (#9328) 2026-04-13 11:00:29 +02:00
message_test.go feat(vllm): parity with llama.cpp backend (#9328) 2026-04-13 11:00:29 +02:00
ollama.go fix(ollama): accept float-encoded integer options (fixes #9837) (#9849) 2026-05-16 18:38:19 +02:00
ollama_test.go fix(ollama): accept float-encoded integer options (fixes #9837) (#9849) 2026-05-16 18:38:19 +02:00
openai.go fix(streaming): comply with OpenAI usage / stream_options spec (#9815) 2026-05-14 08:53:46 +02:00
openresponses.go feat: add distributed mode (#9124) 2026-03-30 00:47:27 +02:00
prediction.go fix: implement encoding_format=base64 for embeddings endpoint (#9135) 2026-03-25 17:38:07 +01:00
quantization.go feat: add distributed mode (#9124) 2026-03-30 00:47:27 +02:00
request.go feat: add distributed mode (#9124) 2026-03-30 00:47:27 +02:00
schema_suite_test.go feat(llama.cpp): consolidate options and respect tokenizer template when enabled (#7120) 2025-11-07 21:23:50 +01:00
tokenize.go feat(api): Allow coding agents to interactively discover how to control and configure LocalAI (#9084) 2026-04-04 15:14:35 +02:00
transcription.go feat: support word-level timestamps for faster-whisper (#9621) 2026-05-06 00:32:52 +02:00
transcription_format.go feat: add distributed mode (#9124) 2026-03-30 00:47:27 +02:00