|
liblloyal 1.0.0
Branched Inference for llama.cpp
|
Chat output parsing (tool calls, reasoning, content) More...
Classes | |
| struct | ParseResult |
| Result from parsing model output. More... | |
| struct | ToolCall |
| A single tool call extracted from model output. More... | |
Functions | |
| ParseResult | parse (const std::string &output, common_chat_format format, common_reasoning_format reasoning_format=COMMON_REASONING_FORMAT_NONE, bool is_partial=false, bool thinking_forced_open=false, const std::string &parser_data="") |
| Parse model output with explicit format. | |
| ParseResult | parse (const llama_model *model, const std::string &output, bool is_partial=false) |
| Parse model output with auto-detected format from model template. | |
Chat output parsing (tool calls, reasoning, content)
Wraps llama.cpp's common_chat_parse() to extract structured content from model output. Pairs with lloyal::chat_in – use the format from chat_in::FormatResult to select the correct parser.
|
inline |
Parse model output with auto-detected format from model template.
Convenience overload that detects the format from the model's template. More expensive than the explicit-format overload since it initializes templates and applies them to detect the format.
| model | Llama model pointer |
| output | The raw model output text to parse |
| is_partial | True if output is incomplete (streaming) |
Definition at line 200 of file chat_out.hpp.
|
inline |
Parse model output with explicit format.
Uses the format detected by chat_in::format() to apply the correct parser. For most formats, this delegates to common_chat_parse() which handles 25+ model-specific output formats (DeepSeek, Mistral, Hermes, etc.).
| output | The raw model output text to parse |
| format | The chat format (from chat_in::FormatResult.format) |
| reasoning_format | How to handle reasoning/thinking blocks |
| is_partial | True if output is incomplete (streaming) |
| thinking_forced_open | Whether thinking tag was forced open |
| parser_data | Serialized PEG parser (from chat_in::FormatResult.parser). Required for PEG format models; ignored for others. |
parser_data parameter must contain the serialized PEG parser from chat_in::FormatResult::parser. Omitting it will cause parse failures for these formats.<think>...</think> blocks — storing raw output as content would re-inject thinking tags as literal text when re-formatted.Definition at line 142 of file chat_out.hpp.