add_text: Add text to a tidyprompt

View source: R/misc_add_text.R

add_textR Documentation

Add text to a tidyprompt

Description

Add text to a prompt by adding a prompt_wrap() which will append the text to the before or after the current prompt text.

Usage

add_text(prompt, text, position = c("after", "before"), sep = "\n\n")

Arguments

prompt

A single string or a tidyprompt() object

text

Text to be added to the current prompt text

position

Where to add the text; either "after" or "before".

sep

Separator to be used between the current prompt text and the text to be added

Value

A tidyprompt() with an added prompt_wrap() which will append the text to the end of the current prompt text

See Also

Other pre_built_prompt_wraps: answer_as_boolean(), answer_as_integer(), answer_as_json(), answer_as_list(), answer_as_named_list(), answer_as_regex_match(), answer_as_text(), answer_by_chain_of_thought(), answer_by_react(), answer_using_r(), answer_using_sql(), answer_using_tools(), prompt_wrap(), quit_if(), set_system_prompt()

Other miscellaneous_prompt_wraps: quit_if(), set_system_prompt()

Examples

prompt <- "Hi there!" |>
  add_text("How is your day?")
prompt
prompt |>
  construct_prompt_text()

tidyprompt documentation built on April 4, 2025, 12:24 a.m.