Skip to contents

Splits a single batched reply into its numbered <row_i> blocks and then applies the standard flat tag parser (llm_parse_tags()) inside each block. This is the parsing counterpart to the <row_i> protocol that LLMR uses when .rows_per_prompt > 1 together with .tags; it is exported so the protocol is inspectable and testable on its own.

Usage

llm_parse_rowpack_tags(text, tags, m)

Arguments

text

Character scalar: one batched model response containing <row_i>...</row_i> blocks, each wrapping flat field tags.

tags

Character vector of field tag names to extract within each block.

m

Integer: the number of items expected in the batch (local ids 1..m).

Value

A list of length m. Element i is the named list returned by llm_parse_tags() for <row_i>, or NULL when that block is absent, truncated, or otherwise unrecoverable.

Details

Robustness mirrors the internal scanner: reordered, duplicated, hallucinated, truncated, or accidentally nested <row_i> blocks are handled; only fully closed blocks contribute. Inner field tags are extracted by the same parser used in non-batched tag mode, so values coerce and decode identically.

Examples

txt <- paste(
  "<row_1><age>21</age><job>barista</job></row_1>",
  "<row_2><age>34</age><job>welder</job></row_2>",
  sep = "\n"
)
llm_parse_rowpack_tags(txt, tags = c("age", "job"), m = 2)