Function helps you run stateless Python functions (a.k.a “predictors”) on-device. Features include:
Cross platform: Function supports compiling and running Python functions across Android, iOS, macOS, Linux, Windows, and the browser.
Zero dependencies: Function compiles these prediction functions into self-contained binaries, meaning you can make predictions with zero dependencies.
Hardware acceleration: Function is designed to use all available compute acceleration hardware (e.g. GPU, NPU) and instruction sets (e.g. CoreML, DirectML, CUDA).
Let’s run the @fxn/greeting predictor which accepts a name and returns a
friendly greeting:
Copy
import { Function } from "fxnjs"// 💥 Create your Function clientconst fxn = new Function({ accessKey: "..." });// 🔥 Make a predictionconst prediction = await fxn.predictions.create({ tag: "@fxn/greeting", inputs: { name: "Yusuf" }});// 🚀 Print the resultconsole.log(prediction.results[0]);
You should see a friendly greeting. Congrats on your first prediction 🎉