A named, versioned set of hooks: functions FunctAI calls at fixed points
of a call or a conversation's turn. Each is given an event and returns an
ai_change() (or NULL: no opinion), and every change is recorded in the
call's record, so a rated call is asked again as it was.
Usage
ai_plugin(name, version = "0.0.0", ..., description = "", api = 1L)
on_hook(plugin, hook, handler)Arguments
- name
Lower-case letters, digits,
_and-, starting with a letter: its changes and entries are named by it.- version
Its own version, recorded with each change.
- ...
Handlers by hook:
before_call = function(call) ....- description
What it does.
- api
The plugin API it was written for (1).
- plugin
A plugin.
- hook
A hook's name.
- handler
A function of one event.
Details
| hook | when | it may change |
turn_start | a conversation's turn is sent, before it is recorded | inputs |
context | the turn's earlier turns are chosen | keep, without, sections |
before_call | an AI function is about to be asked (a program's steps too) | instruction, sections, lm, settings, tools |
request | a provider request is about to be sent | returns another lm15 request |
tool_call | a tool is about to run | inputs, block; or ai_ask() a person |
tool_result | a tool ran | output |
turn_end | a turn ended (hears only; may keep_entry() entries) |
Plugins are set as settings: an AI function's or a program's own
(.plugins), a conversation's, a block's (with_ai_config(plugins = )),
or the session's (ai_config(plugins = )). The program's own run first,
then each layer out to the session's, so the host's handlers see what the
program's did and have the last word. A host's program_plugins = FALSE
drops the program's own. A handler runs in the call's own R session, with
all its power: a plugin is code you trust.