LocalAI/core/http/endpoints/openai
Richard Palethorpe 5195062e12
fix(realtime): Include noAction function in prompt template and handle tool_choice (#8372)
The realtime endpoint was not passing the noAction "answer" function to the
model in the prompt template, causing the model to always call user-provided
tools even when a direct response was appropriate.

Root cause:
- User tools were added to the funcs list
- TemplateMessages() was called to generate the prompt
- noAction function was only added AFTER templating
- This meant the prompt didn't include the "answer" function, even though
  the grammar did

Fix:
- Move noAction function creation before TemplateMessages() call so it's
  included in both the prompt and grammar
- Add proper tool_choice parameter handling to support "auto", "required",
  "none", and specific function selection
- Match behavior of the standard chat endpoint

💘 Generated with Crush

Assisted-by: Claude Sonnet 4.5 via Crush <crush@charm.land>

Signed-off-by: Richard Palethorpe <io@richiejp.com>
2026-02-03 14:30:37 +01:00
..
types feat(realtime): Add audio conversations (#6245) 2026-01-29 08:44:53 +01:00
chat.go fix(api): Add missing field in initial OpenAI streaming response (#8341) 2026-02-02 08:30:04 +01:00
completion.go chore(refactor): move logging to common package based on slog (#7668) 2025-12-21 19:33:13 +01:00
constants.go fix(api): SSE streaming format to comply with specification (#7182) 2025-11-09 22:00:27 +01:00
edit.go chore(refactor): move logging to common package based on slog (#7668) 2025-12-21 19:33:13 +01:00
embeddings.go chore(refactor): move logging to common package based on slog (#7668) 2025-12-21 19:33:13 +01:00
image.go feat(UI): image generation improvements (#7804) 2025-12-31 21:59:46 +01:00
inference.go feat: add support to logitbias and logprobs (#7283) 2025-11-16 13:27:36 +01:00
inpainting.go feat(UI): image generation improvements (#7804) 2025-12-31 21:59:46 +01:00
inpainting_test.go feat(UI): image generation improvements (#7804) 2025-12-31 21:59:46 +01:00
list.go feat: migrate to echo and enable cancellation of non-streaming requests (#7270) 2025-11-14 22:57:53 +01:00
realtime.go feat(realtime): Add audio conversations (#6245) 2026-01-29 08:44:53 +01:00
realtime_model.go fix(realtime): Include noAction function in prompt template and handle tool_choice (#8372) 2026-02-03 14:30:37 +01:00
transcription.go feat(api): Add transcribe response format request parameter & adjust STT backends (#8318) 2026-02-01 17:33:17 +01:00