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:
add_tools()
,
answer_as_boolean()
,
answer_as_code()
,
answer_as_integer()
,
answer_as_list()
,
answer_as_named_list()
,
answer_as_regex()
,
answer_by_chain_of_thought()
,
answer_by_react()
,
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
#> <tidyprompt>
#> The base prompt is modified by a prompt wrap, resulting in:
#> > Hi there!
#> >
#> > How is your day?
#> Use '<tidyprompt>$prompt_wraps' to show the prompt wraps.
#> Use '<tidyprompt>$base_prompt' to show the base prompt text.
#> Use '<tidyprompt> |> construct_prompt_text()' to get the full prompt text.
#>
prompt |>
construct_prompt_text()
#> [1] "Hi there!\n\nHow is your day?"