llm_feedback | R Documentation |
llm_feedback
objectThis object is used to send feedback to a LLM when a LLM reply
does not succesfully pass an extraction or validation function
(as handled by send_prompt()
and defined using prompt_wrap()
).
The feedback text is sent back to the LLM. The extraction or validation function
should then return this object with the feedback text that should be sent to the LLM.
llm_feedback(text, tool_result = FALSE)
text |
A character string containing the feedback text. This will be sent back to the LLM after not passing an extractor or validator function |
tool_result |
A logical indicating whether the feedback is a tool result.
If TRUE, |
An object of class "llm_feedback" (or "llm_feedback_tool_result") containing the feedback text to send back to the LLM
llm_break()
Other prompt_wrap:
llm_break()
,
prompt_wrap()
Other prompt_evaluation:
llm_break()
,
send_prompt()
# Example usage within a validation function similar to the one in 'answer_as_integer()':
validation_fn <- function(x, min = 0, max = 100) {
if (x != floor(x)) { # Not a whole number
return(llm_feedback(
"You must answer with only an integer (use no other characters)."
))
}
if (!is.null(min) && x < min) {
return(llm_feedback(glue::glue(
"The number should be greater than or equal to {min}."
)))
}
if (!is.null(max) && x > max) {
return(llm_feedback(glue::glue(
"The number should be less than or equal to {max}."
)))
}
return(TRUE)
}
# This validation_fn would be part of a prompt_wrap();
# see the `answer_as_integer()` function for an example of how to use it
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.