@capgo/capacitor-llm 8.0.12 → 8.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @capgo/capacitor-llm
2
2
 
3
- <a href="https://capgo.app/"><img src='https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png' alt='Capgo - Instant updates for capacitor'/></a>
3
+ <a href="https://capgo.app/"><img src="https://capgo.app/readme-banner.svg?repo=Cap-go/capacitor-llm" alt="Capgo - Instant updates for Capacitor" /></a>
4
4
 
5
5
  <div align="center">
6
6
  <h2><a href="https://capgo.app/?ref=plugin_llm"> ➡️ Get Instant updates for your App with Capgo 🚀</a></h2>
@@ -37,11 +37,13 @@ bunx cap sync
37
37
 
38
38
  ### iOS Additional Setup for Custom Models
39
39
 
40
- Apple Intelligence works without bundled model files on supported iOS versions. For custom models, the plugin supports MediaPipe through CocoaPods and ExecuTorch through Swift Package Manager.
40
+ Apple Intelligence works without bundled model files on supported iOS versions. For custom models, the plugin supports MediaPipe through CocoaPods and ExecuTorch when the host app links ExecuTorch with Swift Package Manager. The plugin package remains iOS 15 compatible; iOS ExecuTorch requires an iOS 17 or newer app target because ExecuTorch requires iOS 17.
41
41
 
42
42
  **Using CocoaPods:**
43
43
  The MediaPipe dependencies are already configured in the podspec. Make sure to run `pod install` after adding the plugin.
44
44
 
45
+ ExecuTorch is not provided by the CocoaPods integration. CocoaPods installs MediaPipe only. CocoaPods builds reject `engine: 'executorch'` with a clear runtime error unless the app also links ExecuTorch separately.
46
+
45
47
  **Note about Static Framework Warning:**
46
48
  When running `pod install`, you may see a warning about transitive dependencies with statically linked binaries. To fix this, update your Podfile:
47
49
 
@@ -73,7 +75,17 @@ end
73
75
  ```
74
76
 
75
77
  **Using Swift Package Manager:**
76
- The main Swift package stays compatible with iOS 15. To use ExecuTorch `.pte` models on iOS, add the ExecuTorch Swift package to your app target and link `executorch_llm`, `backend_xnnpack`, `kernels_llm`, `kernels_optimized`, `kernels_quantized`, and `kernels_torchao`. ExecuTorch currently requires iOS 17 or newer in the app target that links it. MediaPipe GenAI still does not officially support SPM, so use CocoaPods for MediaPipe `.task` models.
78
+ The plugin's `Package.swift` does not link ExecuTorch directly because that would force every Swift Package Manager user onto iOS 17 or newer, even when they only use Apple Intelligence or MediaPipe.
79
+
80
+ To use ExecuTorch on iOS, add it to your app target:
81
+
82
+ 1. Set the app target deployment version to iOS 17 or newer.
83
+ 2. In Xcode, open the app project, select **Package Dependencies**, and add `https://github.com/pytorch/executorch.git`.
84
+ 3. Use the `swiftpm-1.2.0` branch, or the ExecuTorch branch that matches the runtime version you want.
85
+ 4. Add these products to the app target: `executorch_llm`, `backend_xnnpack`, `kernels_llm`, `kernels_optimized`, `kernels_quantized`, and `kernels_torchao`.
86
+ 5. Add the `.pte` model and tokenizer file to the app target's Copy Bundle Resources, or download them at runtime.
87
+
88
+ If those ExecuTorch products are not linked into the app target, `setModel({ engine: 'executorch' })` rejects with a clear runtime error. MediaPipe GenAI still does not officially support SPM, so use CocoaPods for MediaPipe `.task` models.
77
89
 
78
90
  ## Adding a Model to Your App
79
91
 
@@ -81,7 +93,7 @@ The simplest cross-platform custom model path is ExecuTorch. It uses the same ki
81
93
 
82
94
  ### ExecuTorch Models (iOS and Android)
83
95
 
84
- iOS uses ExecuTorch when the app target links the ExecuTorch SwiftPM products. Android uses the ExecuTorch Maven package.
96
+ iOS uses ExecuTorch only when the host app links the ExecuTorch Swift Package products. It is not included by CocoaPods or by the plugin's `Package.swift`, so an app without those products can use Apple Intelligence or MediaPipe but will refuse `engine: 'executorch'`. Android uses the ExecuTorch Maven package.
85
97
 
86
98
  Bundle the model files:
87
99
 
@@ -12,7 +12,7 @@ import java.util.List;
12
12
  @CapacitorPlugin(name = "CapgoLLM")
13
13
  public class LLMPlugin extends Plugin {
14
14
 
15
- private final String pluginVersion = "8.0.12";
15
+ private final String pluginVersion = "8.0.14";
16
16
 
17
17
  private LLM llm;
18
18
 
@@ -18,7 +18,7 @@ import MediaPipeTasksGenAI
18
18
 
19
19
  @objc(LLMPlugin)
20
20
  public class LLMPlugin: CAPPlugin, CAPBridgedPlugin {
21
- private let pluginVersion: String = "8.0.12"
21
+ private let pluginVersion: String = "8.0.14"
22
22
  #if targetEnvironment(macCatalyst)
23
23
  private let catalystNotSupportedMessage = "CapgoLLM is not available on Mac Catalyst. Use an iOS/iPadOS target instead."
24
24
  #endif
@@ -78,6 +78,9 @@ public class LLMPlugin: CAPPlugin, CAPBridgedPlugin {
78
78
  private var execuTorchRunner: DynamicExecuTorchRunner?
79
79
  private var execuTorchChats: [String: ExecuTorchChatSession] = [:]
80
80
  private let execuTorchGenerationLock = NSLock()
81
+ private let execuTorchNotLinkedMessage = "ExecuTorch is not linked in this iOS app. " +
82
+ "It is not installed by CocoaPods; add the ExecuTorch Swift Package products " +
83
+ "to the app target on iOS 17+ or choose another engine."
81
84
  private var execuTorchIsGenerating = false
82
85
 
83
86
  @objc func setModel(_ call: CAPPluginCall) {
@@ -257,7 +260,9 @@ public class LLMPlugin: CAPPlugin, CAPBridgedPlugin {
257
260
  }
258
261
 
259
262
  guard DynamicExecuTorchRunner.isAvailable else {
260
- call.reject("ExecuTorch is not linked in this iOS app. Add the ExecuTorch Swift Package products to the app target.")
263
+ isReady = false
264
+ notifyListeners("readinessChange", data: ["readiness": execuTorchNotLinkedMessage])
265
+ call.reject(execuTorchNotLinkedMessage)
261
266
  return
262
267
  }
263
268
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-llm",
3
- "version": "8.0.12",
3
+ "version": "8.0.14",
4
4
  "description": "Adds support for LLM locally runned for Capacitor",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",