LocalAI/core/http/endpoints/openai
Ettore Di Giacinto 21c84f432f
feat(function): Add tool streaming, XML Tool Call Parsing Support (#7865)
* feat(function): Add XML Tool Call Parsing Support

Extend the function parsing system in LocalAI to support XML-style tool calls, similar to how JSON tool calls are currently parsed. This will allow models that return XML format (like <tool_call><function=name><parameter=key>value</parameter></function></tool_call>) to be properly parsed alongside text content.

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* thinking before tool calls, more strict support for corner cases with no tools

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* Support streaming tools

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* Iterative JSON

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* Iterative parsing

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* Consume JSON marker

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* Fixup

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* add tests

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* Fix pending TODOs

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* Don't run other parsing with ParseRegex

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

---------

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
2026-01-05 18:25:40 +01:00
..
types fix(realtime): Add transcription session created event, match OpenAI behavior (#6445) 2025-10-13 21:48:13 +02:00
chat.go feat(function): Add tool streaming, XML Tool Call Parsing Support (#7865) 2026-01-05 18:25:40 +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 chore(refactor): move logging to common package based on slog (#7668) 2025-12-21 19:33:13 +01:00
realtime_model.go chore(refactor): move logging to common package based on slog (#7668) 2025-12-21 19:33:13 +01:00
transcription.go chore(refactor): move logging to common package based on slog (#7668) 2025-12-21 19:33:13 +01:00
video.go feat: migrate to echo and enable cancellation of non-streaming requests (#7270) 2025-11-14 22:57:53 +01:00