Decorates a tool or agent with one or more examples, which is an effective way to ensure correct behavior.

demonstrate(x, input, output)
demonstrate_all(x, examples)

Arguments

x

The Tool or Agent object.

input,output

Input and output objects constituting an example. They are assumed to be scalar and, if non-atomic, are wrapped in a list when being combined with the data.frame of existing examples. To add multiple examples at once, use demonstrate_all.

examples

A data.frame with an “input” and “output” column containing input and output objects, respectively.

Details

The input and output objects for each example are converted to/from text in the same way as the actual input and output. For agents, those mappings are configured by prompt_as and output_as. For tools, the input should be a list of arguments corresponding to the function formals, modulo any customization via can_accept_as. The tool output is probably best described as a string, as anything more complex, like JSON schema, tends to confuse agents.

Value

The input object except with newly declared examples.

Author

Michael Lawrence

Examples

if (FALSE) { # \dontrun{
    aggregate_tool <- tool(aggregate) |>
        can_accept_as(x = class_formula, data = class_name, FUN = class_name) |>
        demonstrate(c(x = MPG.city ~ Origin, alist(data = Cars93, FUN = median)),
                    "the median of MPG.city by Origin in Cars93")
    agent <- equip(llama(), aggregate_tool)
    data(Cars93, package = "MASS")
    predict(agent,
            "Mean of MPG.city for each Manufacturer in the Cars93 dataset")
} # }