| llm_break | R Documentation | 
llm_break objectThis object is used to break a extraction and validation loop defined in a prompt_wrap()
as evaluated by send_prompt(). When an extraction or validation function returns
this object, the loop will be broken and no further extraction or validation
functions are applied; instead, send_prompt() will be able to return
the result at that point. This may be useful in scenarios where
it is determined the LLM is unable to provide a response to a prompt.
llm_break(object_to_return = NULL, success = FALSE)
| object_to_return | The object to return as the response result
from  | 
| success | A logical indicating whether the  | 
An list of class "llm_break" containing the object to return and a logical indicating whether the evaluation was successful
llm_feedback()
Other prompt_wrap: 
llm_feedback(),
prompt_wrap()
Other prompt_evaluation: 
llm_feedback(),
send_prompt()
# Example usage within an extraction function similar to the one in 'quit_if()':
extraction_fn <- function(x) {
  quit_detect_regex <- "NO ANSWER"
  if (grepl(quit_detect_regex, x)) {
      return(llm_break(
        object_to_return = NULL,
        success = TRUE
      ))
  }
  return(x)
}
## Not run: 
  result <- "How many months old is the cat of my uncle?" |>
    answer_as_integer() |>
    prompt_wrap(
      modify_fn = function(prompt) {
        paste0(
          prompt, "\n\n",
          "Type only 'NO ANSWER' if you do not know."
        )
      },
      extraction_fn = extraction_fn,
      type = "break"
    ) |>
    send_prompt()
  result
  # NULL
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.