Skip to contents

with_instructions() replaces a signature's instructions. append_instructions() adds text after the existing instructions, separated by a blank line. Both keep the input and output fields and return a new signature; the original is unchanged.

Usage

with_instructions(x, instructions)

append_instructions(x, instructions)

Arguments

x

A signature from signature(), or a signature string such as "question -> answer".

instructions

One string. Empty text is allowed when the signature stays valid; append_instructions() then returns the instructions unchanged.

Value

A new signature.

Examples

base <- signature(
  "text -> summary",
  instructions = "Summarize the text."
)

concise <- append_instructions(base, "Use at most 30 words.")
concise@instructions
#> [1] "Summarize the text.\n\nUse at most 30 words."

with_instructions(base, "Return one sentence.")@instructions
#> [1] "Return one sentence."
base@instructions
#> [1] "Summarize the text."