@capgo/capacitor-llm 8.0.9 → 8.0.11
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.
|
@@ -11,7 +11,15 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.author = package['author']
|
|
12
12
|
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
13
|
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
+
s.platform = :ios, '15.0'
|
|
14
15
|
s.ios.deployment_target = '15.0'
|
|
16
|
+
s.pod_target_xcconfig = {
|
|
17
|
+
'SUPPORTS_MACCATALYST' => 'NO',
|
|
18
|
+
'EXCLUDED_ARCHS[sdk=macosx*]' => 'arm64 x86_64'
|
|
19
|
+
}
|
|
20
|
+
s.user_target_xcconfig = {
|
|
21
|
+
'EXCLUDED_ARCHS[sdk=macosx*]' => 'arm64 x86_64'
|
|
22
|
+
}
|
|
15
23
|
s.dependency 'Capacitor'
|
|
16
24
|
s.dependency 'MediaPipeTasksGenAI'
|
|
17
25
|
s.dependency 'MediaPipeTasksGenAIC'
|
package/README.md
CHANGED
|
@@ -11,6 +11,8 @@ Adds support for LLM locally run for Capacitor
|
|
|
11
11
|
|
|
12
12
|
It uses Apple Intelligence (default) or MediaPipe custom models on iOS, and MediaPipe's tasks-genai on Android
|
|
13
13
|
|
|
14
|
+
**Mac Catalyst:** Native iOS functionality is disabled for Mac Catalyst builds. MediaPipe pods are skipped and native calls will return an unsupported response; use an iOS/iPadOS target for native features.
|
|
15
|
+
|
|
14
16
|
## Documentation
|
|
15
17
|
|
|
16
18
|
The most complete doc is available here: https://capgo.app/docs/plugins/llm/
|
|
@@ -78,7 +80,7 @@ MediaPipe GenAI does not officially support SPM yet (see [MediaPipe issue #5464]
|
|
|
78
80
|
1. Open your app project in Xcode
|
|
79
81
|
2. Go to **File > Add Package Dependencies...**
|
|
80
82
|
3. Enter the URL: `https://github.com/paescebu/SwiftTasksGenAI.git`
|
|
81
|
-
4. Select your desired version (e.g., 0.10.
|
|
83
|
+
4. Select your desired version (e.g., 0.10.27)
|
|
82
84
|
5. Add the `SwiftTasksGenAI` product to your app target
|
|
83
85
|
|
|
84
86
|
**Note:** SwiftTasksGenAI uses unsafe build flags, which means it cannot be added directly in Package.swift files, but works fine when added through Xcode's UI. This is the same approach used by SwiftTasksVision.
|
package/android/build.gradle
CHANGED
|
@@ -52,7 +52,7 @@ dependencies {
|
|
|
52
52
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
53
53
|
implementation project(':capacitor-android')
|
|
54
54
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
55
|
-
implementation 'com.google.mediapipe:tasks-genai:0.10.
|
|
55
|
+
implementation 'com.google.mediapipe:tasks-genai:0.10.27'
|
|
56
56
|
testImplementation "junit:junit:$junitVersion"
|
|
57
57
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
58
58
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
@@ -5,7 +5,7 @@ import FoundationModels
|
|
|
5
5
|
#endif
|
|
6
6
|
// For CocoaPods, MediaPipeTasksGenAI should always be available
|
|
7
7
|
// For SPM, we need conditional import when SPM support is added
|
|
8
|
-
#if canImport(MediaPipeTasksGenAI)
|
|
8
|
+
#if canImport(MediaPipeTasksGenAI) && !targetEnvironment(macCatalyst)
|
|
9
9
|
import MediaPipeTasksGenAI
|
|
10
10
|
#endif
|
|
11
11
|
|
|
@@ -16,7 +16,10 @@ import MediaPipeTasksGenAI
|
|
|
16
16
|
|
|
17
17
|
@objc(LLMPlugin)
|
|
18
18
|
public class LLMPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
19
|
-
private let pluginVersion: String = "8.0.
|
|
19
|
+
private let pluginVersion: String = "8.0.11"
|
|
20
|
+
#if targetEnvironment(macCatalyst)
|
|
21
|
+
private let catalystNotSupportedMessage = "CapgoLLM is not available on Mac Catalyst. Use an iOS/iPadOS target instead."
|
|
22
|
+
#endif
|
|
20
23
|
public let identifier = "LLMPlugin"
|
|
21
24
|
public let jsName = "CapgoLLM"
|
|
22
25
|
public var pluginMethods: [CAPPluginMethod] = [
|
|
@@ -49,7 +52,7 @@ public class LLMPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
49
52
|
private var appleChats: [String: Any] = [:]
|
|
50
53
|
#endif
|
|
51
54
|
|
|
52
|
-
#if COCOAPODS || canImport(MediaPipeTasksGenAI)
|
|
55
|
+
#if !targetEnvironment(macCatalyst) && (COCOAPODS || canImport(MediaPipeTasksGenAI))
|
|
53
56
|
private var llmInference: LlmInference?
|
|
54
57
|
#endif
|
|
55
58
|
|
|
@@ -59,6 +62,11 @@ public class LLMPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
59
62
|
return
|
|
60
63
|
}
|
|
61
64
|
|
|
65
|
+
#if targetEnvironment(macCatalyst)
|
|
66
|
+
call.reject(catalystNotSupportedMessage)
|
|
67
|
+
return
|
|
68
|
+
#endif
|
|
69
|
+
|
|
62
70
|
print("[CapgoLLM] Setting model path: \(path)")
|
|
63
71
|
|
|
64
72
|
// Extract model parameters
|
|
@@ -80,7 +88,7 @@ public class LLMPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
80
88
|
return
|
|
81
89
|
}
|
|
82
90
|
|
|
83
|
-
#if canImport(MediaPipeTasksGenAI)
|
|
91
|
+
#if !targetEnvironment(macCatalyst) && canImport(MediaPipeTasksGenAI)
|
|
84
92
|
Task {
|
|
85
93
|
do {
|
|
86
94
|
let modelURL: URL
|
|
@@ -151,11 +159,16 @@ public class LLMPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
151
159
|
}
|
|
152
160
|
}
|
|
153
161
|
#else
|
|
154
|
-
call.reject("MediaPipe is not available. Please install via CocoaPods.")
|
|
162
|
+
call.reject("MediaPipe is not available on this platform. Please install via CocoaPods on iOS.")
|
|
155
163
|
#endif
|
|
156
164
|
}
|
|
157
165
|
|
|
158
166
|
@objc func createChat(_ call: CAPPluginCall) {
|
|
167
|
+
#if targetEnvironment(macCatalyst)
|
|
168
|
+
call.reject(catalystNotSupportedMessage)
|
|
169
|
+
return
|
|
170
|
+
#endif
|
|
171
|
+
|
|
159
172
|
print("[CapgoLLM] Creating chat with model type: \(currentModelType)")
|
|
160
173
|
switch currentModelType {
|
|
161
174
|
case .appleIntelligence:
|
|
@@ -176,7 +189,7 @@ public class LLMPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
176
189
|
#endif
|
|
177
190
|
|
|
178
191
|
case .mediaPipe:
|
|
179
|
-
#if COCOAPODS || canImport(MediaPipeTasksGenAI)
|
|
192
|
+
#if !targetEnvironment(macCatalyst) && (COCOAPODS || canImport(MediaPipeTasksGenAI))
|
|
180
193
|
guard llmInference != nil else {
|
|
181
194
|
print("[CapgoLLM] Error: Model not loaded when creating chat")
|
|
182
195
|
call.reject("Model not loaded")
|
|
@@ -190,12 +203,18 @@ public class LLMPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
190
203
|
"id": id
|
|
191
204
|
])
|
|
192
205
|
#else
|
|
193
|
-
call.reject("MediaPipe is not available. Please install via CocoaPods.")
|
|
206
|
+
call.reject("MediaPipe is not available on this platform. Please install via CocoaPods on iOS.")
|
|
194
207
|
#endif
|
|
195
208
|
}
|
|
196
209
|
}
|
|
197
210
|
|
|
198
211
|
@objc func getReadiness(_ call: CAPPluginCall) {
|
|
212
|
+
#if targetEnvironment(macCatalyst)
|
|
213
|
+
call.resolve(["readiness": "unsupported_on_maccatalyst"])
|
|
214
|
+
notifyListeners("readinessChange", data: ["readiness": "unsupported_on_maccatalyst"])
|
|
215
|
+
return
|
|
216
|
+
#endif
|
|
217
|
+
|
|
199
218
|
let readiness = getReadinessStatus()
|
|
200
219
|
call.resolve(["readiness": readiness])
|
|
201
220
|
// Also notify listeners
|
|
@@ -232,6 +251,11 @@ public class LLMPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
232
251
|
}
|
|
233
252
|
|
|
234
253
|
@objc func sendMessage(_ call: CAPPluginCall) {
|
|
254
|
+
#if targetEnvironment(macCatalyst)
|
|
255
|
+
call.reject(catalystNotSupportedMessage)
|
|
256
|
+
return
|
|
257
|
+
#endif
|
|
258
|
+
|
|
235
259
|
let chatId = call.getString("chatId", "")
|
|
236
260
|
guard let message = call.getString("message") else {
|
|
237
261
|
call.reject("message not found")
|
|
@@ -318,7 +342,7 @@ public class LLMPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
318
342
|
#endif
|
|
319
343
|
|
|
320
344
|
case .mediaPipe:
|
|
321
|
-
#if COCOAPODS || canImport(MediaPipeTasksGenAI)
|
|
345
|
+
#if !targetEnvironment(macCatalyst) && (COCOAPODS || canImport(MediaPipeTasksGenAI))
|
|
322
346
|
guard let inference = llmInference else {
|
|
323
347
|
call.reject("Model not loaded")
|
|
324
348
|
return
|
|
@@ -358,7 +382,7 @@ public class LLMPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
358
382
|
}
|
|
359
383
|
}
|
|
360
384
|
#else
|
|
361
|
-
call.reject("MediaPipe is not available. Please install via CocoaPods.")
|
|
385
|
+
call.reject("MediaPipe is not available on this platform. Please install via CocoaPods on iOS.")
|
|
362
386
|
#endif
|
|
363
387
|
}
|
|
364
388
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/capacitor-llm",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.11",
|
|
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",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
},
|
|
79
79
|
"peerDependencies": {
|
|
80
80
|
"@capacitor/core": ">=8.0.0",
|
|
81
|
-
"@mediapipe/tasks-genai": "^0.10.
|
|
81
|
+
"@mediapipe/tasks-genai": "^0.10.27"
|
|
82
82
|
},
|
|
83
83
|
"prettier": "@ionic/prettier-config",
|
|
84
84
|
"swiftlint": "@ionic/swiftlint-config",
|