Skip to contents

A conversation is called like its program, and each call is a turn that sees the earlier ones. Memory belongs to the conversation; the program is unchanged, and still callable on its own. Turns are kept in a store, and nothing in it is ever deleted: continuing from an earlier turn makes a branch (continue_from()).

Usage

ai_conversation(
  program,
  id = NULL,
  store = NULL,
  context = all_turns(),
  earlier_without = character(0),
  remembers = NULL,
  sends = c("queue", "refuse", "branch"),
  ...
)

Arguments

program

An AI function or a program.

id

The conversation's id (letters, digits, ., _, -): the same id in the same store opens the same conversation. Default: a new one.

store

NULL (this R session's memory), a folder, TRUE (the default folder), or a store (folder_store(), memory_conversations(), or your own).

context

all_turns() (default) or last_turns().

earlier_without

Outputs the program now writes that its earlier turns lack (reasoning turned on, a first tool): earlier turns are shown without them.

remembers

A program's helpers' memory: list(answer = "conversation"), "turn", or remember(); a conversation used inside its turns, "own". Helpers remember nothing otherwise.

sends

Two sends at once (from two processes): "queue" (the default: the second waits, then continues from the first), "refuse" (conversation-busy), or "branch".

...

Settings for every turn (approve, lm, plugins, ...).

Value

A conversation (class functai_conversation): a function.

Details

chat <- ai_conversation(tutor, "alex", store = "tutoring/")   # the same line tomorrow opens it again
chat("Hi, I'm Alex.")
chat("What is 1/2 + 1/3?")                                     # sees the first turn
ai_turns(chat)                                                 # a tibble: each turn, its inputs and answer

Each turn's id is its call's id in the call log (rate() it), recorded before the model is asked. A turn whose tool needs a person's answer (approve = "changes") waits, saved: the call raises a functai_waiting condition holding $turn, and anyone who opens the conversation answers it with approve() or deny(), and it goes on, paying for nothing twice.