llama-cpp-pro 0.2.2
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/CHANGELOG.md +295 -0
- package/LICENSE +21 -0
- package/LlamaCpp.podspec +33 -0
- package/LlamaCppCapacitor.podspec +33 -0
- package/Package.swift +29 -0
- package/README.md +93 -0
- package/android/build.gradle +88 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/CMakeLists-arm64.txt +138 -0
- package/android/src/main/CMakeLists-x86_64.txt +141 -0
- package/android/src/main/CMakeLists.txt +138 -0
- package/android/src/main/java/ai/annadata/plugin/capacitor/LlamaCpp.java +1340 -0
- package/android/src/main/java/ai/annadata/plugin/capacitor/LlamaCppPlugin.java +814 -0
- package/android/src/main/java/ai/annadata/plugin/capacitor/ModelAdmissionController.java +214 -0
- package/android/src/main/jni-chat-session.cpp +261 -0
- package/android/src/main/jni-lora.cpp +197 -0
- package/android/src/main/jni-multimodal.cpp +167 -0
- package/android/src/main/jni-tts.cpp +290 -0
- package/android/src/main/jni-utils.h +148 -0
- package/android/src/main/jni.cpp +1808 -0
- package/android/src/main/jniLibs/arm64-v8a/libllama-cpp-arm64.so +0 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/build-native.sh +280 -0
- package/cmake/desktop-metal-embed.cmake +30 -0
- package/cmake/desktop-sources.cmake +100 -0
- package/cmake/ggml-backends.cmake +44 -0
- package/cpp/LICENSE +21 -0
- package/cpp/README.md +15 -0
- package/cpp/anyascii.c +22223 -0
- package/cpp/anyascii.h +42 -0
- package/cpp/cap-completion.cpp +942 -0
- package/cpp/cap-completion.h +127 -0
- package/cpp/cap-embedding.cpp +193 -0
- package/cpp/cap-embedding.h +35 -0
- package/cpp/cap-ios-bridge.cpp +1810 -0
- package/cpp/cap-ios-bridge.h +61 -0
- package/cpp/cap-llama.cpp +412 -0
- package/cpp/cap-llama.h +161 -0
- package/cpp/cap-mtmd.hpp +602 -0
- package/cpp/cap-native-server.cpp +1095 -0
- package/cpp/cap-native-server.h +40 -0
- package/cpp/cap-tts.cpp +591 -0
- package/cpp/cap-tts.h +59 -0
- package/cpp/cap-wasm-fs.cpp +156 -0
- package/cpp/cap-wasm-jspi.cpp +19 -0
- package/cpp/cap-wasm-jspi.h +30 -0
- package/cpp/cap-wasm-vfs.cpp +22 -0
- package/cpp/chat-parser.cpp +393 -0
- package/cpp/chat-parser.h +120 -0
- package/cpp/chat.cpp +2315 -0
- package/cpp/chat.h +221 -0
- package/cpp/common.cpp +1664 -0
- package/cpp/common.h +744 -0
- package/cpp/ggml-alloc.c +1028 -0
- package/cpp/ggml-alloc.h +76 -0
- package/cpp/ggml-backend-impl.h +255 -0
- package/cpp/ggml-backend-reg.cpp +600 -0
- package/cpp/ggml-backend.cpp +2121 -0
- package/cpp/ggml-backend.h +354 -0
- package/cpp/ggml-common.h +1878 -0
- package/cpp/ggml-cpp.h +39 -0
- package/cpp/ggml-cpu/amx/amx.cpp +221 -0
- package/cpp/ggml-cpu/amx/amx.h +8 -0
- package/cpp/ggml-cpu/amx/common.h +91 -0
- package/cpp/ggml-cpu/amx/mmq.cpp +2512 -0
- package/cpp/ggml-cpu/amx/mmq.h +10 -0
- package/cpp/ggml-cpu/arch/arm/cpu-feats.cpp +94 -0
- package/cpp/ggml-cpu/arch/arm/quants.c +3650 -0
- package/cpp/ggml-cpu/arch/arm/repack.cpp +1891 -0
- package/cpp/ggml-cpu/arch/x86/cpu-feats.cpp +327 -0
- package/cpp/ggml-cpu/arch/x86/quants.c +3820 -0
- package/cpp/ggml-cpu/arch/x86/repack.cpp +6307 -0
- package/cpp/ggml-cpu/arch-fallback.h +215 -0
- package/cpp/ggml-cpu/binary-ops.cpp +158 -0
- package/cpp/ggml-cpu/binary-ops.h +16 -0
- package/cpp/ggml-cpu/common.h +73 -0
- package/cpp/ggml-cpu/ggml-cpu-impl.h +559 -0
- package/cpp/ggml-cpu/ggml-cpu.c +3578 -0
- package/cpp/ggml-cpu/ggml-cpu.cpp +672 -0
- package/cpp/ggml-cpu/ops.cpp +10587 -0
- package/cpp/ggml-cpu/ops.h +114 -0
- package/cpp/ggml-cpu/quants.c +1193 -0
- package/cpp/ggml-cpu/quants.h +97 -0
- package/cpp/ggml-cpu/repack.cpp +1982 -0
- package/cpp/ggml-cpu/repack.h +120 -0
- package/cpp/ggml-cpu/simd-mappings.h +1184 -0
- package/cpp/ggml-cpu/traits.cpp +36 -0
- package/cpp/ggml-cpu/traits.h +38 -0
- package/cpp/ggml-cpu/unary-ops.cpp +186 -0
- package/cpp/ggml-cpu/unary-ops.h +28 -0
- package/cpp/ggml-cpu/vec.cpp +348 -0
- package/cpp/ggml-cpu/vec.h +1121 -0
- package/cpp/ggml-cpu.h +145 -0
- package/cpp/ggml-impl.h +622 -0
- package/cpp/ggml-metal-impl.h +688 -0
- package/cpp/ggml-metal.h +66 -0
- package/cpp/ggml-metal.m +6833 -0
- package/cpp/ggml-metal.metal +10754 -0
- package/cpp/ggml-opt.cpp +1093 -0
- package/cpp/ggml-opt.h +256 -0
- package/cpp/ggml-quants.c +5324 -0
- package/cpp/ggml-quants.h +106 -0
- package/cpp/ggml-threading.cpp +12 -0
- package/cpp/ggml-threading.h +14 -0
- package/cpp/ggml.c +7108 -0
- package/cpp/ggml.h +2492 -0
- package/cpp/gguf.cpp +1358 -0
- package/cpp/gguf.h +202 -0
- package/cpp/json-partial.cpp +256 -0
- package/cpp/json-partial.h +38 -0
- package/cpp/json-schema-to-grammar.cpp +985 -0
- package/cpp/json-schema-to-grammar.h +21 -0
- package/cpp/llama-adapter.cpp +388 -0
- package/cpp/llama-adapter.h +76 -0
- package/cpp/llama-arch.cpp +2355 -0
- package/cpp/llama-arch.h +499 -0
- package/cpp/llama-batch.cpp +875 -0
- package/cpp/llama-batch.h +160 -0
- package/cpp/llama-chat.cpp +783 -0
- package/cpp/llama-chat.h +65 -0
- package/cpp/llama-context.cpp +2788 -0
- package/cpp/llama-context.h +306 -0
- package/cpp/llama-cparams.cpp +5 -0
- package/cpp/llama-cparams.h +41 -0
- package/cpp/llama-cpp.h +30 -0
- package/cpp/llama-grammar.cpp +1229 -0
- package/cpp/llama-grammar.h +173 -0
- package/cpp/llama-graph.cpp +1891 -0
- package/cpp/llama-graph.h +810 -0
- package/cpp/llama-hparams.cpp +180 -0
- package/cpp/llama-hparams.h +233 -0
- package/cpp/llama-impl.cpp +167 -0
- package/cpp/llama-impl.h +61 -0
- package/cpp/llama-io.cpp +15 -0
- package/cpp/llama-io.h +35 -0
- package/cpp/llama-kv-cache-iswa.cpp +318 -0
- package/cpp/llama-kv-cache-iswa.h +135 -0
- package/cpp/llama-kv-cache.cpp +2059 -0
- package/cpp/llama-kv-cache.h +374 -0
- package/cpp/llama-kv-cells.h +491 -0
- package/cpp/llama-memory-hybrid.cpp +258 -0
- package/cpp/llama-memory-hybrid.h +137 -0
- package/cpp/llama-memory-recurrent.cpp +1146 -0
- package/cpp/llama-memory-recurrent.h +179 -0
- package/cpp/llama-memory.cpp +59 -0
- package/cpp/llama-memory.h +119 -0
- package/cpp/llama-mmap.cpp +609 -0
- package/cpp/llama-mmap.h +68 -0
- package/cpp/llama-model-loader.cpp +1166 -0
- package/cpp/llama-model-loader.h +170 -0
- package/cpp/llama-model-saver.cpp +282 -0
- package/cpp/llama-model-saver.h +37 -0
- package/cpp/llama-model.cpp +19061 -0
- package/cpp/llama-model.h +491 -0
- package/cpp/llama-sampling.cpp +2575 -0
- package/cpp/llama-sampling.h +32 -0
- package/cpp/llama-vocab.cpp +3792 -0
- package/cpp/llama-vocab.h +176 -0
- package/cpp/llama.cpp +358 -0
- package/cpp/llama.h +1373 -0
- package/cpp/log.cpp +428 -0
- package/cpp/log.h +103 -0
- package/cpp/minja/chat-template.hpp +550 -0
- package/cpp/minja/minja.hpp +3009 -0
- package/cpp/nlohmann/json.hpp +25526 -0
- package/cpp/nlohmann/json_fwd.hpp +187 -0
- package/cpp/regex-partial.cpp +204 -0
- package/cpp/regex-partial.h +56 -0
- package/cpp/sampling.cpp +579 -0
- package/cpp/sampling.h +107 -0
- package/cpp/tools/mtmd/clip-impl.h +473 -0
- package/cpp/tools/mtmd/clip.cpp +4322 -0
- package/cpp/tools/mtmd/clip.h +106 -0
- package/cpp/tools/mtmd/miniaudio/miniaudio.h +93468 -0
- package/cpp/tools/mtmd/mtmd-audio.cpp +769 -0
- package/cpp/tools/mtmd/mtmd-audio.h +47 -0
- package/cpp/tools/mtmd/mtmd-helper.cpp +460 -0
- package/cpp/tools/mtmd/mtmd-helper.h +95 -0
- package/cpp/tools/mtmd/mtmd.cpp +1066 -0
- package/cpp/tools/mtmd/mtmd.h +302 -0
- package/cpp/tools/mtmd/stb/stb_image.h +7988 -0
- package/cpp/unicode-data.cpp +7034 -0
- package/cpp/unicode-data.h +20 -0
- package/cpp/unicode.cpp +1061 -0
- package/cpp/unicode.h +68 -0
- package/cpp/vendor/cpp-httplib/httplib.cpp +16509 -0
- package/cpp/vendor/cpp-httplib/httplib.h +3883 -0
- package/desktop/electron-builder.config.cjs +157 -0
- package/desktop/entitlements.mac.plist +12 -0
- package/desktop/package.json +11 -0
- package/desktop/resolve-package-root.cjs +88 -0
- package/desktop/src/main/backend-selector.cjs +148 -0
- package/desktop/src/main/gpu-probe.cjs +142 -0
- package/desktop/src/main/index.cjs +58 -0
- package/desktop/src/main/ipc-handlers.cjs +212 -0
- package/desktop/src/main/model-store.cjs +50 -0
- package/desktop/src/main/preload.cjs +39 -0
- package/desktop/src/main/sidecar-client.cjs +76 -0
- package/desktop/src/main/sidecar-manager.cjs +364 -0
- package/dist/docs.json +14357 -0
- package/dist/esm/definitions.d.ts +731 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/desktop.d.ts +37 -0
- package/dist/esm/desktop.js +133 -0
- package/dist/esm/desktop.js.map +1 -0
- package/dist/esm/index.d.ts +200 -0
- package/dist/esm/index.js +612 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/isomorphic/desktop.runtime.d.ts +37 -0
- package/dist/esm/isomorphic/desktop.runtime.js +36 -0
- package/dist/esm/isomorphic/desktop.runtime.js.map +1 -0
- package/dist/esm/isomorphic/errors.d.ts +6 -0
- package/dist/esm/isomorphic/errors.js +9 -0
- package/dist/esm/isomorphic/errors.js.map +1 -0
- package/dist/esm/isomorphic/model.admission.d.ts +17 -0
- package/dist/esm/isomorphic/model.admission.js +27 -0
- package/dist/esm/isomorphic/model.admission.js.map +1 -0
- package/dist/esm/isomorphic/model.scheduler.d.ts +31 -0
- package/dist/esm/isomorphic/model.scheduler.js +95 -0
- package/dist/esm/isomorphic/model.scheduler.js.map +1 -0
- package/dist/esm/isomorphic/provider.desktop.d.ts +40 -0
- package/dist/esm/isomorphic/provider.desktop.js +411 -0
- package/dist/esm/isomorphic/provider.desktop.js.map +1 -0
- package/dist/esm/isomorphic/provider.factory.d.ts +2 -0
- package/dist/esm/isomorphic/provider.factory.js +16 -0
- package/dist/esm/isomorphic/provider.factory.js.map +1 -0
- package/dist/esm/isomorphic/provider.interface.d.ts +76 -0
- package/dist/esm/isomorphic/provider.interface.js +2 -0
- package/dist/esm/isomorphic/provider.interface.js.map +1 -0
- package/dist/esm/isomorphic/provider.native.d.ts +18 -0
- package/dist/esm/isomorphic/provider.native.js +173 -0
- package/dist/esm/isomorphic/provider.native.js.map +1 -0
- package/dist/esm/isomorphic/provider.web.d.ts +88 -0
- package/dist/esm/isomorphic/provider.web.js +573 -0
- package/dist/esm/isomorphic/provider.web.js.map +1 -0
- package/dist/esm/isomorphic/sidecar-sse.d.ts +14 -0
- package/dist/esm/isomorphic/sidecar-sse.js +76 -0
- package/dist/esm/isomorphic/sidecar-sse.js.map +1 -0
- package/dist/esm/isomorphic/wasmMemoryCalibration.d.ts +26 -0
- package/dist/esm/isomorphic/wasmMemoryCalibration.js +60 -0
- package/dist/esm/isomorphic/wasmMemoryCalibration.js.map +1 -0
- package/dist/esm/isomorphic/wasmMemoryPolicy.d.ts +55 -0
- package/dist/esm/isomorphic/wasmMemoryPolicy.js +93 -0
- package/dist/esm/isomorphic/wasmMemoryPolicy.js.map +1 -0
- package/dist/esm/storage/manifest.d.ts +13 -0
- package/dist/esm/storage/manifest.js +87 -0
- package/dist/esm/storage/manifest.js.map +1 -0
- package/dist/esm/storage/opfs.store.d.ts +31 -0
- package/dist/esm/storage/opfs.store.js +241 -0
- package/dist/esm/storage/opfs.store.js.map +1 -0
- package/dist/esm/web.d.ts +206 -0
- package/dist/esm/web.js +521 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/esm/workers/async-file.d.ts +13 -0
- package/dist/esm/workers/async-file.js +12 -0
- package/dist/esm/workers/async-file.js.map +1 -0
- package/dist/esm/workers/heapfs.d.ts +55 -0
- package/dist/esm/workers/heapfs.js +115 -0
- package/dist/esm/workers/heapfs.js.map +1 -0
- package/dist/esm/workers/wasm.engine.d.ts +86 -0
- package/dist/esm/workers/wasm.engine.js +504 -0
- package/dist/esm/workers/wasm.engine.js.map +1 -0
- package/dist/esm/workers/worker.protocol.d.ts +160 -0
- package/dist/esm/workers/worker.protocol.js +2 -0
- package/dist/esm/workers/worker.protocol.js.map +1 -0
- package/dist/plugin.cjs +3179 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.js +3181 -0
- package/dist/plugin.js.map +1 -0
- package/dist/wasm/llama_engine.d.ts +74 -0
- package/dist/wasm/llama_engine.js +1829 -0
- package/dist/wasm/llama_engine.wasm +0 -0
- package/dist/wasm/llama_engine_emscripten.mjs +2 -0
- package/dist/wasm/package.json +16 -0
- package/dist/workers/llm.worker.js +1226 -0
- package/dist/workers/llm.worker.js.map +7 -0
- package/extraResources/llama-wasm/llama_engine.d.ts +74 -0
- package/extraResources/llama-wasm/llama_engine.js +1829 -0
- package/extraResources/llama-wasm/llama_engine.wasm +0 -0
- package/extraResources/llama-wasm/llama_engine_emscripten.mjs +2 -0
- package/extraResources/llama-wasm/package.json +16 -0
- package/extraResources/sidecar/README.md +11 -0
- package/extraResources/sidecar/darwin-arm64 +0 -0
- package/extraResources/sidecar/darwin-x64 +0 -0
- package/ios/CMakeLists-arm64.txt +161 -0
- package/ios/CMakeLists-x86_64.txt +188 -0
- package/ios/CMakeLists.txt +161 -0
- package/ios/Frameworks/llama-cpp.framework/Info.plist +28 -0
- package/ios/Frameworks/llama-cpp.framework/llama-cpp +0 -0
- package/ios/Sources/LlamaCppCapacitor/LlamaCpp.swift +1365 -0
- package/ios/Sources/LlamaCppCapacitor/LlamaCppPlugin.swift +694 -0
- package/ios/Sources/LlamaCppCapacitor/LlamaNativeBridge.swift +349 -0
- package/ios/Sources/LlamaCppCapacitor/ModelAdmissionController.swift +177 -0
- package/ios/embed-metal-shaders.sh +24 -0
- package/ios/metal-embed.cmake +29 -0
- package/package.json +281 -0
- package/scripts/build-js-preserve-wasm.cjs +53 -0
- package/scripts/build-sidecar-linux.sh +6 -0
- package/scripts/build-sidecar-win.bat +19 -0
- package/scripts/build-sidecar.sh +184 -0
- package/scripts/embed-llama-ios-app-framework.sh +63 -0
- package/scripts/ensure-desktop-sidecar-bundle.cjs +103 -0
- package/scripts/ensure-llama-ios-xcframework.sh +108 -0
- package/scripts/fix-esm-extensions.cjs +45 -0
- package/scripts/prepare-js-dist.cjs +28 -0
- package/scripts/stage-desktop-resources.cjs +116 -0
- package/sidecar/CMakeLists.txt +192 -0
- package/sidecar/cap-sidecar-main.cpp +68 -0
- package/types/llama-cpp-pro.d.ts +441 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- **Package rename:** npm package and GitHub repository are now **`llama-cpp-pro`** (formerly `llama-cpp-capacitor` / `annadata-llama-cpp`). Install with `npm install llama-cpp-pro`. Existing `llama-cpp-capacitor` publishes on npm remain available.
|
|
12
|
+
|
|
13
|
+
## [0.2.1] - 2025-07-07
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
- **Full cross-platform gap closure** — All 47 methods in `LlamaCppPlugin` are now fully implemented on iOS, Android, Web/PWA, and Desktop. Zero stubs remain.
|
|
17
|
+
- **iOS — Session management** (`loadSession`/`saveSession`): Wired to `llama_load_session_file` / `llama_save_session_file` via new `LlamaNativeBridge` symbols. KV-cache state is correctly persisted and restored.
|
|
18
|
+
- **iOS — LoRA adapters** (`applyLoraAdapters`, `removeLoraAdapters`, `getLoadedLoraAdapters`): Now call `llama_apply_lora_adapters`, `llama_remove_lora_adapters`, `llama_get_loaded_lora_adapters` via `dlsym`.
|
|
19
|
+
- **iOS — Multimodal** (`initMultimodal`, `isMultimodalEnabled`, `getMultimodalSupport`, `releaseMultimodal`): Wired to `llama_init_multimodal`, `llama_is_multimodal_enabled`, `llama_get_multimodal_support`, `llama_release_multimodal`.
|
|
20
|
+
- **iOS — TTS/Vocoder** (all 6 methods): Wired to `llama_init_vocoder`, `llama_get_formatted_audio_completion`, `llama_get_audio_completion_guide_tokens`, `llama_decode_audio_tokens`, `llama_release_vocoder`.
|
|
21
|
+
- **iOS — Rerank**: Replaced empty-array stub with real `llama_rerank_json` → `completion::rerank()` call.
|
|
22
|
+
- **iOS — Bench**: Replaced `"[]"` stub with real `llama_bench` → `completion::bench()` call.
|
|
23
|
+
- **iOS — GPU reporting**: `initContext` now queries `llama_get_context_gpu_info` and surfaces actual Metal usage in the `gpu` / `reasonNoGPU` fields.
|
|
24
|
+
- **iOS — Download management**: Replaced blocking `Data(contentsOf:)` with `URLSession` + `URLSessionDownloadDelegate` for real streaming progress tracking and cancellable downloads.
|
|
25
|
+
- **Android — LoRA adapters**: Java `applyLoraAdapters`, `removeLoraAdapters`, `getLoadedLoraAdapters` now call their JNI counterparts in `jni-lora.cpp` (was no-op).
|
|
26
|
+
- **Android — Multimodal**: Java `initMultimodal`, `isMultimodalEnabled`, `getMultimodalSupport`, `releaseMultimodal` now call through to `jni-multimodal.cpp` (was flag-only).
|
|
27
|
+
- **Android — TTS/Vocoder**: Java `initVocoder`, `getFormattedAudioCompletion`, `getAudioCompletionGuideTokens`, `decodeAudioTokens`, `releaseVocoder` now call through to `jni-tts.cpp` (was flag-only).
|
|
28
|
+
- **Android — Session management**: Java `loadSession`/`saveSession` now call `loadSessionNative`/`saveSessionNative` backed by `llama_state_load_file` / `llama_state_save_file`.
|
|
29
|
+
- **Android — Rerank**: Replaced `Math.random()` mock with real `rerankNative` JNI call backed by `completion::rerank()`.
|
|
30
|
+
- **Android — Bench**: Replaced `"[]"` stub with `benchNative` → `completion::bench()`.
|
|
31
|
+
- **Android — Completion param propagation**: All 20+ sampling parameters now extracted from `JSObject` and forwarded to `common_params::sampling` (previously only `temperature`, `n_predict`, `prompt`).
|
|
32
|
+
- **Android — GPU reporting**: `initContext` now queries `modelInfoNative` and reflects actual Vulkan/GPU availability.
|
|
33
|
+
- **Web — `getFormattedChat`**: Delegates to `provider.getFormattedChat` when available (WASM Jinja path), with 4-template client-side fallback.
|
|
34
|
+
- **Web — `chat()`**: Now uses `getFormattedChat` internally for proper template formatting instead of naive role-prefix concatenation.
|
|
35
|
+
- **Web — Completion params**: All sampling parameters forwarded to provider (`top_p`, `top_k`, `min_p`, `repeat_penalty`, `seed`, `stop`, `grammar`).
|
|
36
|
+
- **C++ — New public ABI symbols** in `cap-ios-bridge.h`/`cap-ios-bridge.cpp`: `llama_rerank_json`, `llama_bench`, `llama_load_session_file`, `llama_save_session_file`, `llama_apply_lora_adapters`, `llama_remove_lora_adapters`, `llama_get_loaded_lora_adapters`, `llama_init_multimodal`, `llama_is_multimodal_enabled`, `llama_get_multimodal_support`, `llama_release_multimodal`, `llama_init_vocoder`, `llama_is_vocoder_enabled`, `llama_get_formatted_audio_completion`, `llama_get_audio_completion_guide_tokens`, `llama_decode_audio_tokens`, `llama_release_vocoder`, `llama_get_context_gpu_info`.
|
|
37
|
+
- **Documentation — Feature Coverage Matrix**: Added full 47-method cross-platform matrix to `README.md`.
|
|
38
|
+
- **Documentation — Build guides**: `README_BUILD_SYSTEM.md` and `BUILD_GUIDE.md` updated to cover iOS, Android, Web/PWA, and Desktop with step-by-step instructions for all platforms.
|
|
39
|
+
|
|
40
|
+
### Fixed
|
|
41
|
+
- **Android `rerank`**: Was returning random scores (`Math.random()`) — now correctly calls native reranking.
|
|
42
|
+
- **iOS/Android `bench`**: Was returning empty `"[]"` — now returns real pp/tg performance data.
|
|
43
|
+
- **iOS/Android `loadSession`/`saveSession`**: Was returning hardcoded zeros — now persists/restores actual KV-cache state.
|
|
44
|
+
- **iOS/Android LoRA**: Was silently succeeding with no effect — now applies/removes adapters natively.
|
|
45
|
+
- **iOS/Android Multimodal `getMultimodalSupport`**: Was hardcoded `{vision:true, audio:true}` — now queries actual model capabilities.
|
|
46
|
+
- **iOS/Android TTS**: All vocoder methods were stubs — now fully operational.
|
|
47
|
+
- **Android completion `stop` array**: Was silently ignored — now parsed and forwarded as `antiprompt` to llama.cpp.
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### Changed
|
|
52
|
+
- **App store size**: Build only **arm64-v8a** for Android (drop armeabi-v7a); strip iOS framework and Android `.so` debug symbols. See `APP_STORE_SIZE.md`.
|
|
53
|
+
- **Package**: Exclude `ios/Tests` from published `files`; `build-native.sh` builds Android arm64-only and strips binaries.
|
|
54
|
+
|
|
55
|
+
### Added
|
|
56
|
+
- **APP_STORE_SIZE.md**: Guide on what affects app size, what can be removed, and store-size optimizations.
|
|
57
|
+
|
|
58
|
+
## [0.1.0] - 2025-01-23
|
|
59
|
+
|
|
60
|
+
### Added
|
|
61
|
+
- **Complete iOS support**: Full native iOS build and packaging
|
|
62
|
+
- ARM64 framework (`llama-cpp.framework`) with Metal acceleration
|
|
63
|
+
- Automated copy to `ios/Frameworks/` for npm package
|
|
64
|
+
- CocoaPods `vendored_frameworks` in `LlamaCpp.podspec`
|
|
65
|
+
- **Unified build**: `build-native.sh` builds both iOS and Android; single workflow for publishing
|
|
66
|
+
|
|
67
|
+
### Changed
|
|
68
|
+
- **Android**: NDK detection uses versioned path (`ndk/<version>/`); build limited to arm64-v8a and armeabi-v7a (x86/x86_64 require separate CMake setup)
|
|
69
|
+
- **Android JNI**: `n_threads` via `cpuparams`, `llama_batch_add` as `capllama::llama_batch_add`; embedding fixes
|
|
70
|
+
- **NEON**: Guarded `vcvtnq_s32_f32` fallback for Clang/NDK to avoid redefinition with `arm_neon.h`
|
|
71
|
+
|
|
72
|
+
### Technical
|
|
73
|
+
- `package.json`: version 0.1.0; `ios/Frameworks` in `files`; keywords `ios`, `android`
|
|
74
|
+
- `PUBLISH_GUIDE.md`: Steps for building and publishing iOS + Android npm package
|
|
75
|
+
|
|
76
|
+
## [0.0.13] - 2025-08-30
|
|
77
|
+
|
|
78
|
+
### Fixed
|
|
79
|
+
- **Segmentation Fault Protection**: Added signal handlers to catch and handle segmentation faults during model loading
|
|
80
|
+
- **Enhanced Model Compatibility**: Added GGUF version checking and ultra-minimal parameter fallback
|
|
81
|
+
- **Memory Safety**: Disabled potentially problematic features (mmap, quantized matrix multiplication) in fallback mode
|
|
82
|
+
- **Crash Prevention**: Implemented multiple layers of protection against model loading crashes
|
|
83
|
+
|
|
84
|
+
### Technical
|
|
85
|
+
- Added signal handlers for SIGSEGV to prevent app crashes during model loading
|
|
86
|
+
- Enhanced model validation with GGUF version checking
|
|
87
|
+
- Implemented ultra-minimal parameter set with disabled mmap and quantized operations
|
|
88
|
+
- Added comprehensive error messages for model corruption and compatibility issues
|
|
89
|
+
- Improved memory safety by disabling potentially problematic llama.cpp features
|
|
90
|
+
|
|
91
|
+
## [0.0.12] - 2025-08-30
|
|
92
|
+
|
|
93
|
+
### Fixed
|
|
94
|
+
- **Enhanced File Path Resolution**: Added comprehensive path checking for model files across multiple Android directories
|
|
95
|
+
- **Improved Model Validation**: Enhanced file validation with better error handling and logging
|
|
96
|
+
- **Better Error Messages**: More descriptive error messages to help diagnose model loading issues
|
|
97
|
+
- **Robust File Detection**: Added automatic detection of model files in common Android storage locations
|
|
98
|
+
|
|
99
|
+
### Technical
|
|
100
|
+
- Added multiple path checking for model files (app files, Documents, external storage)
|
|
101
|
+
- Enhanced file validation with size and GGUF format checking
|
|
102
|
+
- Improved logging to show all checked paths and file status
|
|
103
|
+
- Better error handling with fallback to minimal parameters
|
|
104
|
+
- Added comprehensive path resolution for Android file system
|
|
105
|
+
|
|
106
|
+
## [0.0.11] - 2025-08-30
|
|
107
|
+
|
|
108
|
+
### Fixed
|
|
109
|
+
- **Model Validation**: Added comprehensive model file validation before loading
|
|
110
|
+
- **Crash Prevention**: Enhanced error handling to prevent crashes during model loading
|
|
111
|
+
- **GGUF Format Check**: Added validation to ensure the model file is a valid GGUF format
|
|
112
|
+
- **Exception Handling**: Added try-catch blocks around model loading operations
|
|
113
|
+
|
|
114
|
+
### Technical
|
|
115
|
+
- Added file existence and size validation before model loading
|
|
116
|
+
- Added GGUF magic number validation to ensure proper file format
|
|
117
|
+
- Enhanced exception handling with detailed error messages
|
|
118
|
+
- Added comprehensive logging for model validation steps
|
|
119
|
+
- Improved error messages to help diagnose model compatibility issues
|
|
120
|
+
|
|
121
|
+
## [0.0.10] - 2025-08-30
|
|
122
|
+
|
|
123
|
+
### Fixed
|
|
124
|
+
- **Model Loading Issues**: Enhanced model loading with better error handling and fallback parameters
|
|
125
|
+
- **Common Parameters**: Added comprehensive common_params initialization for proper model loading
|
|
126
|
+
- **Debug Logging**: Added detailed logging for model loading process to help diagnose issues
|
|
127
|
+
|
|
128
|
+
### Technical
|
|
129
|
+
- Added fallback to minimal parameters if standard parameters fail
|
|
130
|
+
- Enhanced error logging to show model path and parameters being used
|
|
131
|
+
- Added comprehensive common_params initialization with all required fields
|
|
132
|
+
- Improved model loading reliability with multiple parameter sets
|
|
133
|
+
|
|
134
|
+
## [0.0.9] - 2025-08-30
|
|
135
|
+
|
|
136
|
+
### Fixed
|
|
137
|
+
- **JNI Function Naming**: Fixed JNI function names to match Java native method declarations
|
|
138
|
+
- **UnsatisfiedLinkError**: Resolved "No implementation found" errors for native methods
|
|
139
|
+
- **Function Signature Mismatch**: Corrected JNI function signatures to match Java expectations
|
|
140
|
+
|
|
141
|
+
### Technical
|
|
142
|
+
- Renamed all JNI functions to include "Native" suffix to match Java declarations
|
|
143
|
+
- Removed duplicate wrapper functions that were causing conflicts
|
|
144
|
+
- Fixed function signatures (e.g., completionNative no longer expects params parameter)
|
|
145
|
+
- All native methods now properly link between Java and C++
|
|
146
|
+
|
|
147
|
+
## [0.0.8] - 2025-08-30
|
|
148
|
+
|
|
149
|
+
### Fixed
|
|
150
|
+
- **Android Native Library Naming**: Fixed library naming to use `libllama-cpp.so` instead of architecture-specific names
|
|
151
|
+
- **Java Library Loading**: Updated CMakeLists.txt to build libraries with generic names for Java compatibility
|
|
152
|
+
- **System.loadLibrary() Compatibility**: Java code can now properly load the native library
|
|
153
|
+
|
|
154
|
+
### Technical
|
|
155
|
+
- Changed library target names from `llama-cpp-arm64-v8a` to `llama-cpp` in CMakeLists.txt
|
|
156
|
+
- Updated all architecture-specific build configurations to use the same library name
|
|
157
|
+
- This ensures `System.loadLibrary("llama-cpp")` can find the correct library file
|
|
158
|
+
|
|
159
|
+
## [0.0.7] - 2025-08-30
|
|
160
|
+
|
|
161
|
+
### Fixed
|
|
162
|
+
- **Missing CPP Directory**: Added `cpp/` directory to npm package files to fix CMake build errors
|
|
163
|
+
- **NPM Package Issue**: The cpp directory containing llama.cpp source files was not included in the published package
|
|
164
|
+
- **CMake Build Failure**: Fixed "Cannot find source file" errors when installing plugin as npm dependency
|
|
165
|
+
|
|
166
|
+
### Technical
|
|
167
|
+
- Updated package.json files array to include cpp directory
|
|
168
|
+
- This ensures all necessary source files are available when the plugin is installed as a dependency
|
|
169
|
+
- CMake build system can now properly locate and compile llama.cpp source files
|
|
170
|
+
|
|
171
|
+
## [0.0.6] - 2025-08-30
|
|
172
|
+
|
|
173
|
+
### Fixed
|
|
174
|
+
- **CMake Path Issue**: Fixed incorrect relative path in CMakeLists.txt that was causing "Cannot find source file" errors
|
|
175
|
+
- **Android Build Success**: Resolved CMake configuration issue and successfully built native library
|
|
176
|
+
- **Path Resolution**: Corrected `LLAMACPP_LIB_DIR` from `../../cpp` to `../../../cpp` for proper source file location
|
|
177
|
+
|
|
178
|
+
### Technical
|
|
179
|
+
- Android native library now compiles successfully with correct file paths
|
|
180
|
+
- CMake build system properly locates all llama.cpp source files
|
|
181
|
+
- Ready for real model inference instead of placeholder responses
|
|
182
|
+
|
|
183
|
+
## [0.0.5] - 2025-08-30
|
|
184
|
+
|
|
185
|
+
### Fixed
|
|
186
|
+
- **ANDROID BUILD SUCCESS**: Fixed all compilation errors and successfully built native library
|
|
187
|
+
- Fixed JNI type declarations with proper namespace qualifiers (`rnllama::`)
|
|
188
|
+
- Added missing `llama_model_saver.cpp` to CMakeLists.txt
|
|
189
|
+
- Fixed CMake configuration to use generic implementation for all architectures
|
|
190
|
+
- Added missing `rnllama_verbose` symbol to JNI implementation
|
|
191
|
+
- Simplified build to focus on ARM64 architecture (most common for modern Android)
|
|
192
|
+
- Removed problematic CMake dependency that was causing build failures
|
|
193
|
+
|
|
194
|
+
### Technical
|
|
195
|
+
- Android native library now compiles successfully with all llama.cpp components
|
|
196
|
+
- JNI bridge properly connects Java plugin to C++ llama.cpp library
|
|
197
|
+
- Native context management and model loading implemented
|
|
198
|
+
- Ready for real model inference instead of placeholder responses
|
|
199
|
+
|
|
200
|
+
## [0.0.4] - 2025-08-30
|
|
201
|
+
|
|
202
|
+
### Fixed
|
|
203
|
+
- **REAL LLAMA.CPP INTEGRATION**: Replaced placeholder implementations with actual llama.cpp library calls
|
|
204
|
+
- Fixed Android JNI implementation to use real llama.cpp functions instead of sample text
|
|
205
|
+
- Updated completion method to perform actual text generation using the loaded model
|
|
206
|
+
- Fixed getFormattedChat to use native llama.cpp chat formatting
|
|
207
|
+
- Added proper native context management with real model loading
|
|
208
|
+
- Fixed type conversion issues in parameter extraction
|
|
209
|
+
|
|
210
|
+
### Technical
|
|
211
|
+
- Implemented proper JNI bridge between Java and C++ llama.cpp library
|
|
212
|
+
- Added native method declarations for all core functions
|
|
213
|
+
- Fixed JSObject parameter extraction with proper type casting
|
|
214
|
+
- Added native context ID tracking for proper resource management
|
|
215
|
+
- Integrated real tokenization and completion pipeline
|
|
216
|
+
|
|
217
|
+
## [0.0.3] - 2025-08-30
|
|
218
|
+
|
|
219
|
+
### Fixed
|
|
220
|
+
- Fixed Android compilation errors in LlamaCppPlugin.java
|
|
221
|
+
- Corrected JSArray method calls with proper exception handling
|
|
222
|
+
- Fixed saveSession method signature mismatch
|
|
223
|
+
- Added proper JSONException handling for all JSArray operations
|
|
224
|
+
- Resolved type conversion issues between Map<String,Object> and JSObject
|
|
225
|
+
|
|
226
|
+
### Technical
|
|
227
|
+
- Added try-catch blocks for all JSArray.getString() and JSArray.getInt() calls
|
|
228
|
+
- Fixed method parameter mismatches in Android implementation
|
|
229
|
+
- Improved error handling and type safety in Android plugin
|
|
230
|
+
|
|
231
|
+
## [0.0.2] - 2025-08-30
|
|
232
|
+
|
|
233
|
+
### Added
|
|
234
|
+
- Comprehensive API documentation (API_DOCUMENTATION.md)
|
|
235
|
+
- Quick reference guide (QUICK_REFERENCE.md)
|
|
236
|
+
- Complete TypeScript declarations (types/llama-cpp-pro.d.ts)
|
|
237
|
+
- Fixed build warnings and improved TypeScript configuration
|
|
238
|
+
- Enhanced IDE support with IntelliSense
|
|
239
|
+
|
|
240
|
+
### Documentation
|
|
241
|
+
- Complete API reference with examples
|
|
242
|
+
- Platform support matrix
|
|
243
|
+
- Performance tips and troubleshooting guide
|
|
244
|
+
- TypeScript type safety improvements
|
|
245
|
+
|
|
246
|
+
## [0.0.1] - 2025-08-29
|
|
247
|
+
|
|
248
|
+
### Added
|
|
249
|
+
- Initial release of CapacitorJS plugin for llama.cpp
|
|
250
|
+
- Complete native iOS implementation with Swift and C++ integration
|
|
251
|
+
- Complete native Android implementation with Java and JNI
|
|
252
|
+
- Web fallback implementation for unsupported features
|
|
253
|
+
- Comprehensive TypeScript definitions and interfaces
|
|
254
|
+
- Support for text completion (basic and streaming)
|
|
255
|
+
- Chat conversation functionality with message formatting
|
|
256
|
+
- Tokenization and detokenization
|
|
257
|
+
- Embeddings generation
|
|
258
|
+
- Session management (save/load conversation states)
|
|
259
|
+
- Multimodal support for image processing
|
|
260
|
+
- Text-to-Speech (TTS) with vocoder models
|
|
261
|
+
- LoRA adapters support (apply, remove, list)
|
|
262
|
+
- Performance benchmarking capabilities
|
|
263
|
+
- Structured output with JSON Schema support
|
|
264
|
+
- Error handling and result types
|
|
265
|
+
- Integration testing framework with Jest and custom test runner
|
|
266
|
+
- Build automation scripts for native compilation
|
|
267
|
+
- Comprehensive documentation (README, TESTING, CONTRIBUTING)
|
|
268
|
+
|
|
269
|
+
### Technical Features
|
|
270
|
+
- Native C++ integration using dlopen/dlsym on iOS
|
|
271
|
+
- JNI bridge implementation for Android
|
|
272
|
+
- CMake build system for cross-platform compilation
|
|
273
|
+
- Event-driven architecture with Capacitor listeners
|
|
274
|
+
- Memory management and context handling
|
|
275
|
+
- Cross-platform compatibility (iOS, Android, Web)
|
|
276
|
+
|
|
277
|
+
### Documentation
|
|
278
|
+
- Complete API reference
|
|
279
|
+
- Installation and setup instructions
|
|
280
|
+
- Usage examples and code samples
|
|
281
|
+
- Integration testing guide
|
|
282
|
+
- Platform-specific build instructions
|
|
283
|
+
- Troubleshooting guide
|
|
284
|
+
|
|
285
|
+
## [Unreleased]
|
|
286
|
+
|
|
287
|
+
### Planned
|
|
288
|
+
- Support for larger models (13B, 70B)
|
|
289
|
+
- Enhanced multimodal capabilities
|
|
290
|
+
- Real-time audio processing
|
|
291
|
+
- Advanced LoRA fine-tuning
|
|
292
|
+
- Model quantization optimization
|
|
293
|
+
- Performance monitoring and analytics
|
|
294
|
+
- Cloud model integration
|
|
295
|
+
- Advanced caching mechanisms
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Yakub Mohammad
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/LlamaCpp.podspec
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'LlamaCpp'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.license = package['license']
|
|
10
|
+
s.homepage = package['repository']['url']
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
|
+
|
|
14
|
+
# Swift implementation
|
|
15
|
+
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
16
|
+
s.ios.deployment_target = '14.0'
|
|
17
|
+
s.dependency 'Capacitor'
|
|
18
|
+
s.swift_version = '5.1'
|
|
19
|
+
|
|
20
|
+
# Include the pre-built native llama-cpp framework
|
|
21
|
+
# Built with: ./build-variants.sh --variant minimal (or core/development)
|
|
22
|
+
# Framework includes arm64 architecture with debug symbols stripped
|
|
23
|
+
# For building locally, see BUILD_GUIDE.md
|
|
24
|
+
s.vendored_frameworks = 'ios/Frameworks/llama-cpp.framework'
|
|
25
|
+
s.pod_target_xcconfig = {
|
|
26
|
+
'FRAMEWORK_SEARCH_PATHS' => '$(inherited) "$(PODS_TARGET_SRCROOT)/ios/Frameworks"'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
# Required for proper framework linking
|
|
30
|
+
s.user_target_xcconfig = {
|
|
31
|
+
'FRAMEWORK_SEARCH_PATHS' => '$(inherited) "$(PODS_TARGET_SRCROOT)/ios/Frameworks"'
|
|
32
|
+
}
|
|
33
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'LlamaCppCapacitor'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.license = package['license']
|
|
10
|
+
s.homepage = package['repository']['url']
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
|
+
|
|
14
|
+
# Swift implementation
|
|
15
|
+
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
16
|
+
s.ios.deployment_target = '15.0'
|
|
17
|
+
s.dependency 'Capacitor'
|
|
18
|
+
s.swift_version = '5.1'
|
|
19
|
+
|
|
20
|
+
# Include the pre-built native llama-cpp framework
|
|
21
|
+
# Built with: ./build-variants.sh --variant minimal (or core/development)
|
|
22
|
+
# Framework includes arm64 architecture with debug symbols stripped
|
|
23
|
+
# For building locally, see BUILD_GUIDE.md
|
|
24
|
+
s.vendored_frameworks = 'ios/Frameworks/llama-cpp.framework'
|
|
25
|
+
s.pod_target_xcconfig = {
|
|
26
|
+
'FRAMEWORK_SEARCH_PATHS' => '$(inherited) "$(PODS_TARGET_SRCROOT)/ios/Frameworks"'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
# Required for proper framework linking
|
|
30
|
+
s.user_target_xcconfig = {
|
|
31
|
+
'FRAMEWORK_SEARCH_PATHS' => '$(inherited) "$(PODS_TARGET_SRCROOT)/ios/Frameworks"'
|
|
32
|
+
}
|
|
33
|
+
end
|
package/Package.swift
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// swift-tools-version: 5.9
|
|
2
|
+
import PackageDescription
|
|
3
|
+
|
|
4
|
+
let package = Package(
|
|
5
|
+
name: "LlamaCppCapacitor",
|
|
6
|
+
platforms: [.iOS(.v15)],
|
|
7
|
+
products: [
|
|
8
|
+
.library(
|
|
9
|
+
name: "LlamaCppCapacitor",
|
|
10
|
+
targets: ["LlamaCppCapacitor"])
|
|
11
|
+
],
|
|
12
|
+
dependencies: [
|
|
13
|
+
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0")
|
|
14
|
+
],
|
|
15
|
+
targets: [
|
|
16
|
+
.target(
|
|
17
|
+
name: "LlamaCppCapacitor",
|
|
18
|
+
dependencies: [
|
|
19
|
+
.product(name: "Capacitor", package: "capacitor-swift-pm"),
|
|
20
|
+
.product(name: "Cordova", package: "capacitor-swift-pm"),
|
|
21
|
+
],
|
|
22
|
+
path: "ios/Sources/LlamaCppCapacitor",
|
|
23
|
+
linkerSettings: [
|
|
24
|
+
.linkedLibrary("c++"),
|
|
25
|
+
.linkedFramework("Accelerate")
|
|
26
|
+
]
|
|
27
|
+
)
|
|
28
|
+
]
|
|
29
|
+
)
|
package/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# llama-cpp-pro
|
|
2
|
+
|
|
3
|
+
[Actions Status](https://github.com/arusatech/llama-cpp-pro/actions)
|
|
4
|
+
[License: MIT](https://opensource.org/licenses/MIT)
|
|
5
|
+
[npm](https://www.npmjs.com/package/llama-cpp-pro/)
|
|
6
|
+
[Support: ANNADATA.AI](https://annadata.ai/)
|
|
7
|
+
[Principal Engineer / Architect: Mr. Yakub Mohammad](https://annadata.ai/)
|
|
8
|
+
|
|
9
|
+
A native Capacitor plugin that embeds [llama.cpp](https://github.com/ggerganov/llama.cpp) directly into mobile apps, enabling offline AI inference with comprehensive support for text generation, multimodal processing, TTS, LoRA adapters, and more.
|
|
10
|
+
|
|
11
|
+
[Annadata.ai](https://annadata.ai): Inference of [LLaMA](https://arxiv.org/abs/2302.13971) model in pure C/C++ used in [Annadata.ai](https://annadata.ai)
|
|
12
|
+
|
|
13
|
+
## 🚀 Features
|
|
14
|
+
|
|
15
|
+
- **Offline AI Inference**: Run large language models completely offline on mobile devices
|
|
16
|
+
- **Text Generation**: Complete text completion with streaming support
|
|
17
|
+
- **Chat Conversations**: Multi-turn conversations with context management
|
|
18
|
+
- **Multimodal Support**: Process images and audio alongside text
|
|
19
|
+
- **Text-to-Speech (TTS)**: Generate speech from text using vocoder models
|
|
20
|
+
- **LoRA Adapters**: Fine-tune models with LoRA adapters
|
|
21
|
+
- **Embeddings**: Generate vector embeddings for semantic search
|
|
22
|
+
- **Reranking**: Rank documents by relevance to queries
|
|
23
|
+
- **Session Management**: Save and load conversation states
|
|
24
|
+
- **Benchmarking**: Performance testing and optimization tools
|
|
25
|
+
- **Structured Output**: Generate JSON with schema validation
|
|
26
|
+
- **Cross-Platform**: iOS, Android, **Web/PWA**, and **Desktop** (Windows, macOS, Linux) with native optimizations
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## 📱 Platform Support
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
| Feature | iOS | Android | Web (PWA) | Desktop |
|
|
34
|
+
| ------------------ | ----- | ---------- | --------- | ---------------------- |
|
|
35
|
+
| Text Generation | ✅ | ✅ | ✅ | ✅ |
|
|
36
|
+
| Chat Conversations | ✅ | ✅ | ✅ | ✅ |
|
|
37
|
+
| Streaming | ✅ | ✅ | ✅ | ✅¹ |
|
|
38
|
+
| Multimodal | ✅ | ✅ | ✅² | ✅ |
|
|
39
|
+
| TTS | ✅ | ✅ | ✅² | ✅ |
|
|
40
|
+
| LoRA Adapters | ✅ | ✅ | ✅² | ✅ |
|
|
41
|
+
| Embeddings | ✅ | ✅ | ✅ | ✅ |
|
|
42
|
+
| Reranking | ✅ | ✅ | ✅³ | ✅ |
|
|
43
|
+
| Session Management | ✅ | ✅ | ✅⁴ | ✅ |
|
|
44
|
+
| Benchmarking | ✅ | ✅ | ✅ | ✅ |
|
|
45
|
+
| GPU Acceleration | Metal | CPU/Adreno | — | Vulkan/CUDA/ROCm/Metal |
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
¹ **Desktop:** SSE streaming from the native sidecar (`/v1/chat/completions`, `/v1/completions` with `stream: true`).
|
|
49
|
+
² **Web:** auxiliary GGUF files must be staged in WASM VFS.
|
|
50
|
+
³ **Web:** requires rank-pooling embedding model.
|
|
51
|
+
⁴ **Web:** sessions persist in worker MEMFS for tab lifetime.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Builds
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# iOS + Android + PWA (npm release / Capacitor)
|
|
59
|
+
./build-variants.sh --variant minimal
|
|
60
|
+
|
|
61
|
+
# iOS only / Android only
|
|
62
|
+
./build-variants.sh --variant ios-only
|
|
63
|
+
./build-variants.sh --variant android-only
|
|
64
|
+
|
|
65
|
+
# Desktop / Electron (macOS universal sidecar: arm64 + x64)
|
|
66
|
+
./build-variants.sh --variant desktop
|
|
67
|
+
./build-variants.sh --variant minimal --with-desktop --desktop-arch=universal
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
See [BUILD_GUIDE.md](BUILD_GUIDE.md) and [README_BUILD_SYSTEM.md](README_BUILD_SYSTEM.md) for full build, API, and troubleshooting details.
|
|
71
|
+
|
|
72
|
+
## 🤝 Contributing
|
|
73
|
+
|
|
74
|
+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
75
|
+
|
|
76
|
+
## 📄 License
|
|
77
|
+
|
|
78
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
79
|
+
|
|
80
|
+
## 🙏 Acknowledgments
|
|
81
|
+
|
|
82
|
+
- [llama.cpp](https://github.com/ggerganov/llama.cpp) - The core inference engine
|
|
83
|
+
- [Capacitor](https://capacitorjs.com/) - The cross-platform runtime
|
|
84
|
+
- [Annadata.ai](https://annadata.ai) - Complete system developed and powered by [npm](https://www.npmjs.com/package/llama-cpp-pro/)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
## 📞 Support
|
|
89
|
+
|
|
90
|
+
- 📧 Email: [support@arusatech.com](mailto:support@arusatech.com) ; [yakub@annadata.ai](mailto:yakub@annadata.ai)
|
|
91
|
+
- 🐛 Issues: [GitHub Issues](https://github.com/arusatech/llama-cpp-pro/issues)
|
|
92
|
+
- 📖 Documentation: [GitHub Wiki](https://github.com/arusatech/llama-cpp-pro/wiki)
|
|
93
|
+
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
buildscript {
|
|
9
|
+
repositories {
|
|
10
|
+
google()
|
|
11
|
+
mavenCentral()
|
|
12
|
+
}
|
|
13
|
+
dependencies {
|
|
14
|
+
classpath 'com.android.tools.build:gradle:8.7.2'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
apply plugin: 'com.android.library'
|
|
19
|
+
|
|
20
|
+
android {
|
|
21
|
+
namespace "ai.annadata.plugin.capacitor"
|
|
22
|
+
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
|
|
23
|
+
defaultConfig {
|
|
24
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
|
|
25
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
|
|
26
|
+
versionCode 1
|
|
27
|
+
versionName "1.0"
|
|
28
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
29
|
+
|
|
30
|
+
ndk {
|
|
31
|
+
abiFilters 'arm64-v8a'
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
externalNativeBuild {
|
|
36
|
+
cmake {
|
|
37
|
+
path "src/main/CMakeLists.txt"
|
|
38
|
+
version "3.22.1"
|
|
39
|
+
// Explicitly set NDK version to avoid Windows dependencies
|
|
40
|
+
ndkVersion "29.0.13113456"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
buildTypes {
|
|
45
|
+
release {
|
|
46
|
+
minifyEnabled false
|
|
47
|
+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
lintOptions {
|
|
52
|
+
abortOnError false
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
compileOptions {
|
|
56
|
+
sourceCompatibility JavaVersion.VERSION_21
|
|
57
|
+
targetCompatibility JavaVersion.VERSION_21
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
sourceSets {
|
|
61
|
+
main {
|
|
62
|
+
java {
|
|
63
|
+
srcDirs = ['src/main/java']
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Disable clean tasks that might cause issues
|
|
69
|
+
tasks.whenTaskAdded { task ->
|
|
70
|
+
if (task.name.contains('Clean') && task.name.contains('Debug')) {
|
|
71
|
+
task.enabled = false
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
repositories {
|
|
77
|
+
google()
|
|
78
|
+
mavenCentral()
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
dependencies {
|
|
82
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
83
|
+
implementation project(':capacitor-android')
|
|
84
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
85
|
+
testImplementation "junit:junit:$junitVersion"
|
|
86
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
87
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
88
|
+
}
|