Skip to contents

A program's interface (contract/programs.md): its description, its inputs and its outputs, each named and typed as JSON Schema, as every language describes it. For an AI function it is its formula and codebook: an input with a default (defaults_to()) is optional, its default in its shape; one output is result. Given a saved folder, it describes a program in it without loading or running anything, whatever language saved it (a module too, which R cannot run): a server, a check or a notebook can say what a program takes before deciding to load it.

Usage

ai_interface(x, ...)

# S3 method for class 'functai_fn'
ai_interface(x, ...)

# S3 method for class 'character'
ai_interface(x, node = NULL, ...)

Arguments

x

An AI function, or a saved folder (or its functai.json).

...

Unused.

node

For a folder: which program, by key ("module:name"); default the entry.

Value

The interface (a list, as JSON), of class functai_interface. Refused, it is an error of class functai_refusal with its code (saved-format, saved-malformed, saved-no-interface, interface-malformed, saved-differs).

Examples

mood <- ai(mood ~ review, "How does the customer feel about what they bought?",
  mood = choice("happy", "unhappy", "mixed"))
ai_interface(mood)
#> <interface> How does the customer feel about what they bought?
#>   inputs:
#>     review  {"type":"string"}
#>   outputs:
#>     result  {"enum":["happy","unhappy","mixed"],"type":"string"}