Tools for Apple's LLM in JavaScript
In the previous post (Using tools with Apple's on-device LLM) we've seen how to write an MCP-like tool for Apple's on-device LLM. But for that you need Xcode and Swift. Is there a way to write such tools in JavaScript?
Yes, there is! If you want to experiment with Apple's on-device LLM, simply download this iOS app (it also works on Macs). In this app you can implement an MCP-like tool in JavaScript and hook it up to the built-in LLM. Here's a simple example:
async function call(base, exponent) {
return parseFloat(base) ** parseFloat(exponent)
}
A more useful example is this:
async function call(lat, lng) {
let response = await fetchUrl(“https://arax.ee/weather/forecast”, “POST”, JSON.stringify({“latitude”: parseFloat(lat), “longitude”: parseFloat(lng)}))
return response.body
}