Skip to contents

When a turn ends and more than keep + every turns of its branch are not yet summarized, every turn but the last keep is folded into the summary (the earlier summary and those turns, given to summarize(earlier_summary, new_turns), new_turns a list of list(input..., output...) rows; default: an AI function of functai's, on lm when given). The summary is kept in the conversation (an entry at that turn, so each branch has its own), and the next turns are shown it as a section of the instruction, with only the turns after it. What a turn was shown is in its record, so a rated turn is asked again with the same summary. every keeps the summary's text the same for every turns: a provider's prompt cache keeps its prefix meanwhile.

Usage

compaction(
  keep = 20L,
  every = 10L,
  summarize = NULL,
  lm = NULL,
  name = "compaction"
)

Arguments

keep

How many recent turns are always shown whole.

every

How many more turns may pile up before the next summary.

summarize

A function of the earlier summary and the new turns, giving the summary's text.

lm

The model the default summarizer uses.

name

The plugin's name (two compactions on one conversation need two).

Value

A plugin.

Examples

if (FALSE) { # \dontrun{
chat <- ai_conversation(tutor, "alex", store = "tutoring/", plugins = list(compaction(keep = 20)))
} # }