⚠️ Mixlayer is currently in open beta. Please excuse us if you encounter any issues while we get things ready.
Concepts
Tool Calling

Tool Calling

Experimental

Large language models are capable of performing a wide variety of tasks, but they can't do everything. They are typically bad at things such as math and their knowledge might be outdated because its only seen things up to its training cutoff date.

Sometimes you need to call out to a tool or service to augment its capabilities. Mixlayer makes this easy by providing a way to call out to tools from within your code.

How it works

When you call install with a tool definition, Mixlayer will insert a prompt into the context window to notify the model that the tool is available.

Any subsequent calls to gen will give the model an opportunity to invoke the tool if it thinks it'll be useful.

💡
Tool support needs to be enabled on in app's settings. When tools are enabled, Mixlayer will insert a special system prompt to guide the model into considering tool use during generation.

Examples

Calculator

In this example, we provide the model with a "calculator" tool. It simply evaluates a mathematical expression using the eval JS function and returns the result.

calculator.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' });