LayaKit: a Swift package that runs one Laya decision per call on Core ML
SwiftPM package ported from laya-coreml. Point it at the aac6fef Core ML bundles (general or ANE) and call predict with choice, score or noul; no Python at runtime.
# LayaKit
A Swift package that runs one Laya typed decision per call on-device via Core ML — no Python at runtime. Ported from [`mizorewww/laya-coreml`](https://github.com/mizorewww/laya-coreml).
## Requirements
- macOS 15+
- Apple silicon
- Xcode 26+
## Install
Add LayaKit as a SwiftPM dependency:
```swift
.package(url: "https://github.com/<org>/LayaKit", from: "1.0.0")
```
```swift
.target(
name: "YourTarget",
dependencies: [.product(name: "LayaKit", package: "LayaKit")]
)
```
## Download bundles
```
pip install -U huggingface_hub
hf download aac6fef/laya-multilingual-coreml --local-dir models/general
hf download aac6fef/laya-multilingual-coreml-ane --local-dir models/ane
```
## Usage
```swift
let agent = try await LayaAgent(bundle: URL(fileURLWithPath: "models/ane"))
let answer = try agent.predict(state: "I was billed twice. Refund the duplicate.",
question: .choice(instructions: "Who should handle this?",
options: ["billing", "technical", "sales"]))
```
## Question types
| Case | Parameters | Description |
| --- | --- | --- |
| `.choice` | `instructions: String`, `options: [String]`, `descriptions: [String: String]?` | Pick one label out of a set of options, optionally with a description per option. |
| `.score` | `instructions: String`, `levels: [String]` | Rate along an ordered scale; each level is described by a string. |
| `.noul` | `instructions: String`, `falseText: String?`, `trueText: String?` | A yes/no judgment, optionally with custom text for the false/true cases. |
## CLI usage
`laya-cli` runs a single question against a bundle and prints the answer as JSON.
```
laya-cli --bundle <path> --state <text> --question <path-to-json> [--bench N]
```
- `--bun