% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/llama.R
\name{llama_chat_parse}
\alias{llama_chat_parse}
\title{Parse raw model output into content and tool calls}
\usage{
llama_chat_parse(input, format, is_partial = FALSE, parser = NULL)
}
\arguments{
\item{input}{Raw generated text from the model.}

\item{format}{Integer format id as returned in
\code{llama_chat_build()$format}.}

\item{is_partial}{Set \code{TRUE} when \code{input} is an incomplete stream
prefix (enables partial/streaming-tolerant parsing).}

\item{parser}{Serialized PEG parser arena as returned in
\code{llama_chat_build()$parser}. Required for PEG-based formats
(\code{PEG_SIMPLE}/\code{PEG_NATIVE}/\code{PEG_CONSTRUCTED}, e.g. Mistral /
Ministral); ignored otherwise. Pass \code{llama_chat_build()$parser}
straight through.}
}
\value{
A list with \code{content}, \code{reasoning_content}, and
  \code{tool_calls} — the latter a data frame with columns \code{name},
  \code{arguments} (a JSON string), and \code{id} (zero rows if none).
}
\description{
Inverse of the formatting done by \code{\link{llama_chat_build}}: takes the
model's raw generated text and the \code{format} id returned by
\code{llama_chat_build()}, and extracts assistant \code{content}, any
\code{reasoning_content}, and structured tool calls (name, arguments JSON,
id) using llama.cpp's per-format parsers (\code{common_chat_parse}).
}
\seealso{
[llama_chat_build]
}
