Skip to main content

llama_rs_compute_tool_call_haystack

Function llama_rs_compute_tool_call_haystack 

Source
pub unsafe extern "C" fn llama_rs_compute_tool_call_haystack(
    model: *const llama_model,
    out_haystack: *mut *mut c_char,
    out_error: *mut *mut c_char,
) -> llama_rs_status
Expand description

Render the model’s chat template with the autoparser’s standard tool-call vs. plain-assistant synthetic turns and return the diff slice that surrounds the tool-call payload. The returned haystack is the text that lives between the model’s tool-call open/close markers (with any reasoning prelude stripped). Marker extraction from the haystack is performed in Rust.

On success (LLAMA_RS_STATUS_OK):

  • If the model declares no tool-call markers (or an empty haystack), *out_haystack is left as nullptr.
  • Otherwise *out_haystack is a heap-allocated null-terminated string owned by the caller. Free via llama_rs_string_free.

On LLAMA_RS_STATUS_EXCEPTION, *out_error is set to a heap-allocated message; free via llama_rs_string_free.