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