⚠️ Mixlayer is currently in open beta. Please excuse us if you encounter any issues while we get things ready.
Built-in Functions
install

install(tool)

Experimental

install makes a tool available to any subsequent completions generated by the model. This function is only available to apps that have tool usage enabled in their settings.

Arguments

tool.name string
The name the model should use to refer to the tool.


options.description string
A natural language description of the tool's purpose. The model will use this description when figuring out when to use it.


options.fn function
A Javascript function that will be called when the tool is invoked. The function should return an object with the output of the tool.


options.parameters object
An object that describes the parameters that the tool accepts. Each key in the object is the name of a parameter, and the value is an object that describes the parameter.

Example

In this example, we provide the model with a calculator tool it can use to solve simple math problems that are Javascript expressions.

prompt.js
const MATH_TOOL = { 
    name: 'calculator', 
    description: 'Evaluate mathematical expressions', 
    fn: ({expression}) => { 
        return { answer: eval(expression) };
    },
    parameters: { 
        expression: { 
            param_type: 'string', 
            description: 'Math problem to evaluate', 
            required: true 
        }
    }
}
 
install(MATH_TOOL); 
prompt(`what is 96 * 124?`, { role: 'user' });
gen({limit: 500, role: 'assistant' });