llm_parse_tags: Parse XML-like tags emitted by an LLM

View source: R/tags_mode.R

llm_parse_tagsR Documentation

Parse XML-like tags emitted by an LLM

Description

Extracts simple XML-like tags from a character scalar or llmr_response, such as ⁠<age>21</age>⁠ and ⁠<job>student</job>⁠. This is intended for soft structured output, not full XML validation.

Usage

llm_parse_tags(x, tags)

Arguments

x

Character scalar or llmr_response.

tags

Character vector of tag names to extract.

Value

A named list of extracted tag values, or NULL when no requested tag is found.

See Also

llm_parse_tags_col(), llm_mutate_tags()

Examples

llm_parse_tags("<age>21</age><job>student</job>", tags = c("age", "job"))


LLMR documentation built on May 22, 2026, 1:07 a.m.