liblloyal 1.0.0
Branched Inference for llama.cpp
Loading...
Searching...
No Matches
lloyal::chat_out::ParseResult Struct Reference

Result from parsing model output. More...

#include <lloyal/chat_out.hpp>

Public Attributes

std::string content
 Main response text (visible to user)
 
std::string reasoning_content
 Extracted thinking/reasoning blocks (empty if none)
 
std::vector< ToolCalltool_calls
 Extracted tool calls (empty array if none)
 

Detailed Description

Result from parsing model output.

For thinking models (e.g. Qwen3), reasoning_content contains text from <think>...</think> blocks while content contains the visible response. Store both fields separately in your message history so that chat_in::format() can reconstruct the template correctly on subsequent turns.

auto parsed = chat_out::parse(raw_output, fmt.format, fmt.reasoning_format,
false, fmt.thinking_forced_open, fmt.parser);
// Build assistant message with separate fields
json assistant_msg = {{"role", "assistant"}, {"content", parsed.content}};
if (!parsed.reasoning_content.empty()) {
assistant_msg["reasoning_content"] = parsed.reasoning_content;
}
messages.push_back(assistant_msg);
// On next turn, format() reconstructs thinking blocks from reasoning_content
full_inputs.messages_json = messages.dump();
auto full_result = chat_in::format(model, full_inputs);
FormatResult format(const llama_model *model, const FormatInputs &inputs)
Format chat messages using model's chat template with full format awareness.
Definition chat_in.hpp:135
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.
Definition chat_out.hpp:142

Definition at line 77 of file chat_out.hpp.

Member Data Documentation

◆ content

std::string lloyal::chat_out::ParseResult::content

Main response text (visible to user)

Definition at line 78 of file chat_out.hpp.

◆ reasoning_content

std::string lloyal::chat_out::ParseResult::reasoning_content

Extracted thinking/reasoning blocks (empty if none)

Definition at line 79 of file chat_out.hpp.

◆ tool_calls

std::vector<ToolCall> lloyal::chat_out::ParseResult::tool_calls

Extracted tool calls (empty array if none)

Definition at line 80 of file chat_out.hpp.


The documentation for this struct was generated from the following file: