Run AI models anywhere.
Note
Muna requires iOS 15+.
Muna is distributed as a SwiftPM package, and can be added as a dependency in an Xcode project or in a SwiftPM package:
In your project editor, open the Package Dependencies
tab, search
for https://github.com/muna-ai/muna-swift.git and add the package to your project:
Add the following dependency to your Package.swift
file:
let package = Package(
name: "MySwiftPackage",
dependencies: [
.package(url: "https://github.com/muna-ai/muna-swift.git", from: "0.0.1"),
],
targets: [
.target(name: "MySwiftPackage", dependencies: ["Muna"]),
]
)
Before creating predictions, you will need to create a Muna account. Once you do, generate an access key:
First, create a Muna client:
import Muna
// 💥 Create a Muna client
let muna = Muna(accessKey: "...")
Then make a prediction:
// 🔥 Make a prediction
let prediction = try await muna.predictions.create(
tag: "@fxn/greeting",
inputs: ["name": "Sam"]
)
Finally, use the prediction results:
// 🚀 Use the results
print("Prediction result: \(prediction.results![0]!)")
Muna normally works by downloading and executing prediction functions at runtime. But because iOS requires strict sandboxing, you must download and embed predictors at build-time instead.
First, create an muna.config.swift
file at the root of your target directory:
import Muna
let config = Muna.Configuration(
// add all predictor tags to be embedded here
tags: [
"@fxn/greeting"
]
)
You can embed the predictors using the context menu by right-clicking on your project and selecting the
Embed Predictors
command:
You can also use the Swift CLI:
# Embed predictors
swift package --allow-writing-to-package-directory muna-embed
Note
Embedding predictors requires internet and file system access to download and embed the prediction function into your Xcode project.
Important
After embedding, Xcode might prompt you to either reload the project from disk or keep the current version in memory. Always reload your project from disk.
- Discover predictors to use in your apps.
- Join our Discord community.
- Check out our docs.
- Learn more about us on our blog.
- Reach out to us at [email protected].
Muna is a product of NatML Inc.