cactus-react-native 1.5.0 → 1.10.0
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/Cactus.podspec +1 -1
- package/README.md +347 -241
- package/android/CMakeLists.txt +24 -5
- package/android/src/main/jniLibs/arm64-v8a/libcactus.a +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libcurl.a +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libmbedcrypto.a +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libmbedtls.a +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libmbedx509.a +0 -0
- package/cpp/HybridCactus.cpp +197 -117
- package/cpp/HybridCactus.hpp +18 -9
- package/cpp/cactus_ffi.h +66 -42
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus.h +0 -1
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_cloud.h +48 -0
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_ffi.h +66 -42
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_utils.h +568 -135
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/engine.h +148 -17
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/graph.h +145 -36
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/kernel.h +187 -6
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/kernel_utils.h +49 -149
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Info.plist +0 -0
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/cactus +0 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus.h +0 -1
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_cloud.h +48 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_ffi.h +66 -42
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_utils.h +568 -135
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/engine.h +148 -17
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/graph.h +145 -36
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/kernel.h +187 -6
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/kernel_utils.h +49 -149
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Info.plist +0 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/_CodeSignature/CodeResources +1 -1
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/cactus +0 -0
- package/lib/module/classes/CactusLM.js +16 -49
- package/lib/module/classes/CactusLM.js.map +1 -1
- package/lib/module/classes/CactusSTT.js +41 -75
- package/lib/module/classes/CactusSTT.js.map +1 -1
- package/lib/module/classes/CactusVAD.js +95 -0
- package/lib/module/classes/CactusVAD.js.map +1 -0
- package/lib/module/hooks/useCactusLM.js +10 -11
- package/lib/module/hooks/useCactusLM.js.map +1 -1
- package/lib/module/hooks/useCactusSTT.js +23 -62
- package/lib/module/hooks/useCactusSTT.js.map +1 -1
- package/lib/module/hooks/useCactusVAD.js +171 -0
- package/lib/module/hooks/useCactusVAD.js.map +1 -0
- package/lib/module/index.js +2 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/modelRegistry.js +52 -0
- package/lib/module/modelRegistry.js.map +1 -0
- package/lib/module/native/Cactus.js +103 -23
- package/lib/module/native/Cactus.js.map +1 -1
- package/lib/module/native/CactusIndex.js.map +1 -1
- package/lib/module/native/index.js +0 -3
- package/lib/module/native/index.js.map +1 -1
- package/lib/module/types/CactusVAD.js +4 -0
- package/lib/module/{specs/CactusUtil.nitro.js.map → types/CactusVAD.js.map} +1 -1
- package/lib/typescript/src/classes/CactusLM.d.ts +5 -7
- package/lib/typescript/src/classes/CactusLM.d.ts.map +1 -1
- package/lib/typescript/src/classes/CactusSTT.d.ts +9 -12
- package/lib/typescript/src/classes/CactusSTT.d.ts.map +1 -1
- package/lib/typescript/src/classes/CactusVAD.d.ts +20 -0
- package/lib/typescript/src/classes/CactusVAD.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useCactusLM.d.ts +2 -2
- package/lib/typescript/src/hooks/useCactusLM.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useCactusSTT.d.ts +6 -8
- package/lib/typescript/src/hooks/useCactusSTT.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useCactusVAD.d.ts +15 -0
- package/lib/typescript/src/hooks/useCactusVAD.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +7 -5
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/modelRegistry.d.ts +5 -0
- package/lib/typescript/src/modelRegistry.d.ts.map +1 -0
- package/lib/typescript/src/native/Cactus.d.ts +13 -11
- package/lib/typescript/src/native/Cactus.d.ts.map +1 -1
- package/lib/typescript/src/native/CactusIndex.d.ts +2 -2
- package/lib/typescript/src/native/CactusIndex.d.ts.map +1 -1
- package/lib/typescript/src/native/index.d.ts +0 -3
- package/lib/typescript/src/native/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/Cactus.nitro.d.ts +7 -6
- package/lib/typescript/src/specs/Cactus.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types/CactusIndex.d.ts +2 -2
- package/lib/typescript/src/types/CactusIndex.d.ts.map +1 -1
- package/lib/typescript/src/types/CactusLM.d.ts +19 -11
- package/lib/typescript/src/types/CactusLM.d.ts.map +1 -1
- package/lib/typescript/src/types/CactusSTT.d.ts +44 -12
- package/lib/typescript/src/types/CactusSTT.d.ts.map +1 -1
- package/lib/typescript/src/types/CactusVAD.d.ts +34 -0
- package/lib/typescript/src/types/CactusVAD.d.ts.map +1 -0
- package/lib/typescript/src/types/common.d.ts +1 -6
- package/lib/typescript/src/types/common.d.ts.map +1 -1
- package/nitro.json +0 -11
- package/nitrogen/generated/android/cactus+autolinking.cmake +0 -5
- package/nitrogen/generated/android/cactusOnLoad.cpp +0 -30
- package/nitrogen/generated/ios/Cactus-Swift-Cxx-Bridge.cpp +0 -50
- package/nitrogen/generated/ios/Cactus-Swift-Cxx-Bridge.hpp +9 -147
- package/nitrogen/generated/ios/Cactus-Swift-Cxx-Umbrella.hpp +0 -13
- package/nitrogen/generated/ios/CactusAutolinking.mm +0 -26
- package/nitrogen/generated/ios/CactusAutolinking.swift +0 -30
- package/nitrogen/generated/shared/c++/HybridCactusSpec.cpp +5 -4
- package/nitrogen/generated/shared/c++/HybridCactusSpec.hpp +7 -6
- package/package.json +3 -3
- package/src/classes/CactusLM.ts +18 -65
- package/src/classes/CactusSTT.ts +52 -90
- package/src/classes/CactusVAD.ts +129 -0
- package/src/hooks/useCactusLM.ts +14 -17
- package/src/hooks/useCactusSTT.ts +47 -98
- package/src/hooks/useCactusVAD.ts +215 -0
- package/src/index.tsx +21 -12
- package/src/modelRegistry.ts +65 -0
- package/src/native/Cactus.ts +131 -38
- package/src/native/CactusIndex.ts +2 -2
- package/src/native/index.ts +0 -3
- package/src/specs/Cactus.nitro.ts +16 -7
- package/src/types/CactusIndex.ts +2 -2
- package/src/types/CactusLM.ts +19 -11
- package/src/types/CactusSTT.ts +47 -13
- package/src/types/CactusVAD.ts +39 -0
- package/src/types/common.ts +1 -6
- package/android/src/main/java/com/margelo/nitro/cactus/HybridCactusCrypto.kt +0 -46
- package/android/src/main/java/com/margelo/nitro/cactus/HybridCactusDeviceInfo.kt +0 -27
- package/android/src/main/jniLibs/arm64-v8a/libcactus_util.a +0 -0
- package/cpp/HybridCactusUtil.cpp +0 -47
- package/cpp/HybridCactusUtil.hpp +0 -27
- package/cpp/cactus_util.h +0 -25
- package/ios/HybridCactusCrypto.swift +0 -37
- package/ios/HybridCactusDeviceInfo.swift +0 -32
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_telemetry.h +0 -656
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_telemetry.h +0 -656
- package/ios/cactus_util.xcframework/Info.plist +0 -39
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/cactus_util.h +0 -25
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/database.h +0 -27
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/ios_utils.h +0 -10
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/logging.h +0 -25
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Info.plist +0 -0
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/cactus_util +0 -0
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/cactus_util.h +0 -25
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/database.h +0 -27
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/ios_utils.h +0 -10
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/logging.h +0 -25
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Info.plist +0 -0
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/_CodeSignature/CodeResources +0 -135
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/cactus_util +0 -0
- package/lib/module/api/Database.js +0 -45
- package/lib/module/api/Database.js.map +0 -1
- package/lib/module/api/RemoteLM.js +0 -201
- package/lib/module/api/RemoteLM.js.map +0 -1
- package/lib/module/config/CactusConfig.js +0 -12
- package/lib/module/config/CactusConfig.js.map +0 -1
- package/lib/module/models.js +0 -336
- package/lib/module/models.js.map +0 -1
- package/lib/module/native/CactusCrypto.js +0 -10
- package/lib/module/native/CactusCrypto.js.map +0 -1
- package/lib/module/native/CactusDeviceInfo.js +0 -13
- package/lib/module/native/CactusDeviceInfo.js.map +0 -1
- package/lib/module/native/CactusUtil.js +0 -36
- package/lib/module/native/CactusUtil.js.map +0 -1
- package/lib/module/specs/CactusCrypto.nitro.js +0 -4
- package/lib/module/specs/CactusCrypto.nitro.js.map +0 -1
- package/lib/module/specs/CactusDeviceInfo.nitro.js +0 -4
- package/lib/module/specs/CactusDeviceInfo.nitro.js.map +0 -1
- package/lib/module/specs/CactusUtil.nitro.js +0 -4
- package/lib/module/telemetry/Telemetry.js +0 -154
- package/lib/module/telemetry/Telemetry.js.map +0 -1
- package/lib/typescript/src/api/Database.d.ts +0 -12
- package/lib/typescript/src/api/Database.d.ts.map +0 -1
- package/lib/typescript/src/api/RemoteLM.d.ts +0 -14
- package/lib/typescript/src/api/RemoteLM.d.ts.map +0 -1
- package/lib/typescript/src/config/CactusConfig.d.ts +0 -7
- package/lib/typescript/src/config/CactusConfig.d.ts.map +0 -1
- package/lib/typescript/src/models.d.ts +0 -6
- package/lib/typescript/src/models.d.ts.map +0 -1
- package/lib/typescript/src/native/CactusCrypto.d.ts +0 -5
- package/lib/typescript/src/native/CactusCrypto.d.ts.map +0 -1
- package/lib/typescript/src/native/CactusDeviceInfo.d.ts +0 -7
- package/lib/typescript/src/native/CactusDeviceInfo.d.ts.map +0 -1
- package/lib/typescript/src/native/CactusUtil.d.ts +0 -6
- package/lib/typescript/src/native/CactusUtil.d.ts.map +0 -1
- package/lib/typescript/src/specs/CactusCrypto.nitro.d.ts +0 -8
- package/lib/typescript/src/specs/CactusCrypto.nitro.d.ts.map +0 -1
- package/lib/typescript/src/specs/CactusDeviceInfo.nitro.d.ts +0 -16
- package/lib/typescript/src/specs/CactusDeviceInfo.nitro.d.ts.map +0 -1
- package/lib/typescript/src/specs/CactusUtil.nitro.d.ts +0 -10
- package/lib/typescript/src/specs/CactusUtil.nitro.d.ts.map +0 -1
- package/lib/typescript/src/telemetry/Telemetry.d.ts +0 -34
- package/lib/typescript/src/telemetry/Telemetry.d.ts.map +0 -1
- package/nitrogen/generated/android/c++/JDeviceInfo.hpp +0 -74
- package/nitrogen/generated/android/c++/JHybridCactusCryptoSpec.cpp +0 -65
- package/nitrogen/generated/android/c++/JHybridCactusCryptoSpec.hpp +0 -65
- package/nitrogen/generated/android/c++/JHybridCactusDeviceInfoSpec.cpp +0 -85
- package/nitrogen/generated/android/c++/JHybridCactusDeviceInfoSpec.hpp +0 -66
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/DeviceInfo.kt +0 -50
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/HybridCactusCryptoSpec.kt +0 -58
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/HybridCactusDeviceInfoSpec.kt +0 -62
- package/nitrogen/generated/ios/c++/HybridCactusCryptoSpecSwift.cpp +0 -11
- package/nitrogen/generated/ios/c++/HybridCactusCryptoSpecSwift.hpp +0 -77
- package/nitrogen/generated/ios/c++/HybridCactusDeviceInfoSpecSwift.cpp +0 -11
- package/nitrogen/generated/ios/c++/HybridCactusDeviceInfoSpecSwift.hpp +0 -88
- package/nitrogen/generated/ios/swift/DeviceInfo.swift +0 -98
- package/nitrogen/generated/ios/swift/Func_void_DeviceInfo.swift +0 -47
- package/nitrogen/generated/ios/swift/Func_void_std__optional_std__string_.swift +0 -54
- package/nitrogen/generated/ios/swift/HybridCactusCryptoSpec.swift +0 -57
- package/nitrogen/generated/ios/swift/HybridCactusCryptoSpec_cxx.swift +0 -139
- package/nitrogen/generated/ios/swift/HybridCactusDeviceInfoSpec.swift +0 -58
- package/nitrogen/generated/ios/swift/HybridCactusDeviceInfoSpec_cxx.swift +0 -164
- package/nitrogen/generated/shared/c++/DeviceInfo.hpp +0 -92
- package/nitrogen/generated/shared/c++/HybridCactusCryptoSpec.cpp +0 -21
- package/nitrogen/generated/shared/c++/HybridCactusCryptoSpec.hpp +0 -63
- package/nitrogen/generated/shared/c++/HybridCactusDeviceInfoSpec.cpp +0 -22
- package/nitrogen/generated/shared/c++/HybridCactusDeviceInfoSpec.hpp +0 -67
- package/nitrogen/generated/shared/c++/HybridCactusUtilSpec.cpp +0 -23
- package/nitrogen/generated/shared/c++/HybridCactusUtilSpec.hpp +0 -66
- package/src/api/Database.ts +0 -55
- package/src/api/RemoteLM.ts +0 -273
- package/src/config/CactusConfig.ts +0 -11
- package/src/models.ts +0 -344
- package/src/native/CactusCrypto.ts +0 -11
- package/src/native/CactusDeviceInfo.ts +0 -18
- package/src/native/CactusUtil.ts +0 -43
- package/src/specs/CactusCrypto.nitro.ts +0 -6
- package/src/specs/CactusDeviceInfo.nitro.ts +0 -15
- package/src/specs/CactusUtil.nitro.ts +0 -8
- package/src/telemetry/Telemetry.ts +0 -236
|
@@ -8,31 +8,18 @@
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
10
|
// Forward declarations of C++ defined types
|
|
11
|
-
// Forward declaration of `DeviceInfo` to properly resolve imports.
|
|
12
|
-
namespace margelo::nitro::cactus { struct DeviceInfo; }
|
|
13
|
-
// Forward declaration of `HybridCactusCryptoSpec` to properly resolve imports.
|
|
14
|
-
namespace margelo::nitro::cactus { class HybridCactusCryptoSpec; }
|
|
15
|
-
// Forward declaration of `HybridCactusDeviceInfoSpec` to properly resolve imports.
|
|
16
|
-
namespace margelo::nitro::cactus { class HybridCactusDeviceInfoSpec; }
|
|
17
11
|
// Forward declaration of `HybridCactusFileSystemSpec` to properly resolve imports.
|
|
18
12
|
namespace margelo::nitro::cactus { class HybridCactusFileSystemSpec; }
|
|
19
13
|
// Forward declaration of `HybridCactusImageSpec` to properly resolve imports.
|
|
20
14
|
namespace margelo::nitro::cactus { class HybridCactusImageSpec; }
|
|
21
15
|
|
|
22
16
|
// Forward declarations of Swift defined types
|
|
23
|
-
// Forward declaration of `HybridCactusCryptoSpec_cxx` to properly resolve imports.
|
|
24
|
-
namespace Cactus { class HybridCactusCryptoSpec_cxx; }
|
|
25
|
-
// Forward declaration of `HybridCactusDeviceInfoSpec_cxx` to properly resolve imports.
|
|
26
|
-
namespace Cactus { class HybridCactusDeviceInfoSpec_cxx; }
|
|
27
17
|
// Forward declaration of `HybridCactusFileSystemSpec_cxx` to properly resolve imports.
|
|
28
18
|
namespace Cactus { class HybridCactusFileSystemSpec_cxx; }
|
|
29
19
|
// Forward declaration of `HybridCactusImageSpec_cxx` to properly resolve imports.
|
|
30
20
|
namespace Cactus { class HybridCactusImageSpec_cxx; }
|
|
31
21
|
|
|
32
22
|
// Include C++ defined types
|
|
33
|
-
#include "DeviceInfo.hpp"
|
|
34
|
-
#include "HybridCactusCryptoSpec.hpp"
|
|
35
|
-
#include "HybridCactusDeviceInfoSpec.hpp"
|
|
36
23
|
#include "HybridCactusFileSystemSpec.hpp"
|
|
37
24
|
#include "HybridCactusImageSpec.hpp"
|
|
38
25
|
#include <NitroModules/Promise.hpp>
|
|
@@ -106,140 +93,6 @@ namespace margelo::nitro::cactus::bridge::swift {
|
|
|
106
93
|
return Func_void_std__exception_ptr_Wrapper(std::move(value));
|
|
107
94
|
}
|
|
108
95
|
|
|
109
|
-
// pragma MARK: std::shared_ptr<HybridCactusCryptoSpec>
|
|
110
|
-
/**
|
|
111
|
-
* Specialized version of `std::shared_ptr<HybridCactusCryptoSpec>`.
|
|
112
|
-
*/
|
|
113
|
-
using std__shared_ptr_HybridCactusCryptoSpec_ = std::shared_ptr<HybridCactusCryptoSpec>;
|
|
114
|
-
std::shared_ptr<HybridCactusCryptoSpec> create_std__shared_ptr_HybridCactusCryptoSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
|
|
115
|
-
void* NON_NULL get_std__shared_ptr_HybridCactusCryptoSpec_(std__shared_ptr_HybridCactusCryptoSpec_ cppType);
|
|
116
|
-
|
|
117
|
-
// pragma MARK: std::weak_ptr<HybridCactusCryptoSpec>
|
|
118
|
-
using std__weak_ptr_HybridCactusCryptoSpec_ = std::weak_ptr<HybridCactusCryptoSpec>;
|
|
119
|
-
inline std__weak_ptr_HybridCactusCryptoSpec_ weakify_std__shared_ptr_HybridCactusCryptoSpec_(const std::shared_ptr<HybridCactusCryptoSpec>& strong) noexcept { return strong; }
|
|
120
|
-
|
|
121
|
-
// pragma MARK: Result<std::shared_ptr<Promise<std::string>>>
|
|
122
|
-
using Result_std__shared_ptr_Promise_std__string___ = Result<std::shared_ptr<Promise<std::string>>>;
|
|
123
|
-
inline Result_std__shared_ptr_Promise_std__string___ create_Result_std__shared_ptr_Promise_std__string___(const std::shared_ptr<Promise<std::string>>& value) noexcept {
|
|
124
|
-
return Result<std::shared_ptr<Promise<std::string>>>::withValue(value);
|
|
125
|
-
}
|
|
126
|
-
inline Result_std__shared_ptr_Promise_std__string___ create_Result_std__shared_ptr_Promise_std__string___(const std::exception_ptr& error) noexcept {
|
|
127
|
-
return Result<std::shared_ptr<Promise<std::string>>>::withError(error);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// pragma MARK: std::optional<std::string>
|
|
131
|
-
/**
|
|
132
|
-
* Specialized version of `std::optional<std::string>`.
|
|
133
|
-
*/
|
|
134
|
-
using std__optional_std__string_ = std::optional<std::string>;
|
|
135
|
-
inline std::optional<std::string> create_std__optional_std__string_(const std::string& value) noexcept {
|
|
136
|
-
return std::optional<std::string>(value);
|
|
137
|
-
}
|
|
138
|
-
inline bool has_value_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
|
|
139
|
-
return optional.has_value();
|
|
140
|
-
}
|
|
141
|
-
inline std::string get_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
|
|
142
|
-
return *optional;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// pragma MARK: std::shared_ptr<Promise<std::optional<std::string>>>
|
|
146
|
-
/**
|
|
147
|
-
* Specialized version of `std::shared_ptr<Promise<std::optional<std::string>>>`.
|
|
148
|
-
*/
|
|
149
|
-
using std__shared_ptr_Promise_std__optional_std__string___ = std::shared_ptr<Promise<std::optional<std::string>>>;
|
|
150
|
-
inline std::shared_ptr<Promise<std::optional<std::string>>> create_std__shared_ptr_Promise_std__optional_std__string___() noexcept {
|
|
151
|
-
return Promise<std::optional<std::string>>::create();
|
|
152
|
-
}
|
|
153
|
-
inline PromiseHolder<std::optional<std::string>> wrap_std__shared_ptr_Promise_std__optional_std__string___(std::shared_ptr<Promise<std::optional<std::string>>> promise) noexcept {
|
|
154
|
-
return PromiseHolder<std::optional<std::string>>(std::move(promise));
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// pragma MARK: std::function<void(const std::optional<std::string>& /* result */)>
|
|
158
|
-
/**
|
|
159
|
-
* Specialized version of `std::function<void(const std::optional<std::string>&)>`.
|
|
160
|
-
*/
|
|
161
|
-
using Func_void_std__optional_std__string_ = std::function<void(const std::optional<std::string>& /* result */)>;
|
|
162
|
-
/**
|
|
163
|
-
* Wrapper class for a `std::function<void(const std::optional<std::string>& / * result * /)>`, this can be used from Swift.
|
|
164
|
-
*/
|
|
165
|
-
class Func_void_std__optional_std__string__Wrapper final {
|
|
166
|
-
public:
|
|
167
|
-
explicit Func_void_std__optional_std__string__Wrapper(std::function<void(const std::optional<std::string>& /* result */)>&& func): _function(std::make_unique<std::function<void(const std::optional<std::string>& /* result */)>>(std::move(func))) {}
|
|
168
|
-
inline void call(std::optional<std::string> result) const noexcept {
|
|
169
|
-
_function->operator()(result);
|
|
170
|
-
}
|
|
171
|
-
private:
|
|
172
|
-
std::unique_ptr<std::function<void(const std::optional<std::string>& /* result */)>> _function;
|
|
173
|
-
} SWIFT_NONCOPYABLE;
|
|
174
|
-
Func_void_std__optional_std__string_ create_Func_void_std__optional_std__string_(void* NON_NULL swiftClosureWrapper) noexcept;
|
|
175
|
-
inline Func_void_std__optional_std__string__Wrapper wrap_Func_void_std__optional_std__string_(Func_void_std__optional_std__string_ value) noexcept {
|
|
176
|
-
return Func_void_std__optional_std__string__Wrapper(std::move(value));
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// pragma MARK: std::shared_ptr<Promise<DeviceInfo>>
|
|
180
|
-
/**
|
|
181
|
-
* Specialized version of `std::shared_ptr<Promise<DeviceInfo>>`.
|
|
182
|
-
*/
|
|
183
|
-
using std__shared_ptr_Promise_DeviceInfo__ = std::shared_ptr<Promise<DeviceInfo>>;
|
|
184
|
-
inline std::shared_ptr<Promise<DeviceInfo>> create_std__shared_ptr_Promise_DeviceInfo__() noexcept {
|
|
185
|
-
return Promise<DeviceInfo>::create();
|
|
186
|
-
}
|
|
187
|
-
inline PromiseHolder<DeviceInfo> wrap_std__shared_ptr_Promise_DeviceInfo__(std::shared_ptr<Promise<DeviceInfo>> promise) noexcept {
|
|
188
|
-
return PromiseHolder<DeviceInfo>(std::move(promise));
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// pragma MARK: std::function<void(const DeviceInfo& /* result */)>
|
|
192
|
-
/**
|
|
193
|
-
* Specialized version of `std::function<void(const DeviceInfo&)>`.
|
|
194
|
-
*/
|
|
195
|
-
using Func_void_DeviceInfo = std::function<void(const DeviceInfo& /* result */)>;
|
|
196
|
-
/**
|
|
197
|
-
* Wrapper class for a `std::function<void(const DeviceInfo& / * result * /)>`, this can be used from Swift.
|
|
198
|
-
*/
|
|
199
|
-
class Func_void_DeviceInfo_Wrapper final {
|
|
200
|
-
public:
|
|
201
|
-
explicit Func_void_DeviceInfo_Wrapper(std::function<void(const DeviceInfo& /* result */)>&& func): _function(std::make_unique<std::function<void(const DeviceInfo& /* result */)>>(std::move(func))) {}
|
|
202
|
-
inline void call(DeviceInfo result) const noexcept {
|
|
203
|
-
_function->operator()(result);
|
|
204
|
-
}
|
|
205
|
-
private:
|
|
206
|
-
std::unique_ptr<std::function<void(const DeviceInfo& /* result */)>> _function;
|
|
207
|
-
} SWIFT_NONCOPYABLE;
|
|
208
|
-
Func_void_DeviceInfo create_Func_void_DeviceInfo(void* NON_NULL swiftClosureWrapper) noexcept;
|
|
209
|
-
inline Func_void_DeviceInfo_Wrapper wrap_Func_void_DeviceInfo(Func_void_DeviceInfo value) noexcept {
|
|
210
|
-
return Func_void_DeviceInfo_Wrapper(std::move(value));
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// pragma MARK: std::shared_ptr<HybridCactusDeviceInfoSpec>
|
|
214
|
-
/**
|
|
215
|
-
* Specialized version of `std::shared_ptr<HybridCactusDeviceInfoSpec>`.
|
|
216
|
-
*/
|
|
217
|
-
using std__shared_ptr_HybridCactusDeviceInfoSpec_ = std::shared_ptr<HybridCactusDeviceInfoSpec>;
|
|
218
|
-
std::shared_ptr<HybridCactusDeviceInfoSpec> create_std__shared_ptr_HybridCactusDeviceInfoSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
|
|
219
|
-
void* NON_NULL get_std__shared_ptr_HybridCactusDeviceInfoSpec_(std__shared_ptr_HybridCactusDeviceInfoSpec_ cppType);
|
|
220
|
-
|
|
221
|
-
// pragma MARK: std::weak_ptr<HybridCactusDeviceInfoSpec>
|
|
222
|
-
using std__weak_ptr_HybridCactusDeviceInfoSpec_ = std::weak_ptr<HybridCactusDeviceInfoSpec>;
|
|
223
|
-
inline std__weak_ptr_HybridCactusDeviceInfoSpec_ weakify_std__shared_ptr_HybridCactusDeviceInfoSpec_(const std::shared_ptr<HybridCactusDeviceInfoSpec>& strong) noexcept { return strong; }
|
|
224
|
-
|
|
225
|
-
// pragma MARK: Result<std::shared_ptr<Promise<std::optional<std::string>>>>
|
|
226
|
-
using Result_std__shared_ptr_Promise_std__optional_std__string____ = Result<std::shared_ptr<Promise<std::optional<std::string>>>>;
|
|
227
|
-
inline Result_std__shared_ptr_Promise_std__optional_std__string____ create_Result_std__shared_ptr_Promise_std__optional_std__string____(const std::shared_ptr<Promise<std::optional<std::string>>>& value) noexcept {
|
|
228
|
-
return Result<std::shared_ptr<Promise<std::optional<std::string>>>>::withValue(value);
|
|
229
|
-
}
|
|
230
|
-
inline Result_std__shared_ptr_Promise_std__optional_std__string____ create_Result_std__shared_ptr_Promise_std__optional_std__string____(const std::exception_ptr& error) noexcept {
|
|
231
|
-
return Result<std::shared_ptr<Promise<std::optional<std::string>>>>::withError(error);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
// pragma MARK: Result<std::shared_ptr<Promise<DeviceInfo>>>
|
|
235
|
-
using Result_std__shared_ptr_Promise_DeviceInfo___ = Result<std::shared_ptr<Promise<DeviceInfo>>>;
|
|
236
|
-
inline Result_std__shared_ptr_Promise_DeviceInfo___ create_Result_std__shared_ptr_Promise_DeviceInfo___(const std::shared_ptr<Promise<DeviceInfo>>& value) noexcept {
|
|
237
|
-
return Result<std::shared_ptr<Promise<DeviceInfo>>>::withValue(value);
|
|
238
|
-
}
|
|
239
|
-
inline Result_std__shared_ptr_Promise_DeviceInfo___ create_Result_std__shared_ptr_Promise_DeviceInfo___(const std::exception_ptr& error) noexcept {
|
|
240
|
-
return Result<std::shared_ptr<Promise<DeviceInfo>>>::withError(error);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
96
|
// pragma MARK: std::shared_ptr<Promise<bool>>
|
|
244
97
|
/**
|
|
245
98
|
* Specialized version of `std::shared_ptr<Promise<bool>>`.
|
|
@@ -357,6 +210,15 @@ namespace margelo::nitro::cactus::bridge::swift {
|
|
|
357
210
|
using std__weak_ptr_HybridCactusFileSystemSpec_ = std::weak_ptr<HybridCactusFileSystemSpec>;
|
|
358
211
|
inline std__weak_ptr_HybridCactusFileSystemSpec_ weakify_std__shared_ptr_HybridCactusFileSystemSpec_(const std::shared_ptr<HybridCactusFileSystemSpec>& strong) noexcept { return strong; }
|
|
359
212
|
|
|
213
|
+
// pragma MARK: Result<std::shared_ptr<Promise<std::string>>>
|
|
214
|
+
using Result_std__shared_ptr_Promise_std__string___ = Result<std::shared_ptr<Promise<std::string>>>;
|
|
215
|
+
inline Result_std__shared_ptr_Promise_std__string___ create_Result_std__shared_ptr_Promise_std__string___(const std::shared_ptr<Promise<std::string>>& value) noexcept {
|
|
216
|
+
return Result<std::shared_ptr<Promise<std::string>>>::withValue(value);
|
|
217
|
+
}
|
|
218
|
+
inline Result_std__shared_ptr_Promise_std__string___ create_Result_std__shared_ptr_Promise_std__string___(const std::exception_ptr& error) noexcept {
|
|
219
|
+
return Result<std::shared_ptr<Promise<std::string>>>::withError(error);
|
|
220
|
+
}
|
|
221
|
+
|
|
360
222
|
// pragma MARK: Result<std::shared_ptr<Promise<bool>>>
|
|
361
223
|
using Result_std__shared_ptr_Promise_bool___ = Result<std::shared_ptr<Promise<bool>>>;
|
|
362
224
|
inline Result_std__shared_ptr_Promise_bool___ create_Result_std__shared_ptr_Promise_bool___(const std::shared_ptr<Promise<bool>>& value) noexcept {
|
|
@@ -8,21 +8,12 @@
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
10
|
// Forward declarations of C++ defined types
|
|
11
|
-
// Forward declaration of `DeviceInfo` to properly resolve imports.
|
|
12
|
-
namespace margelo::nitro::cactus { struct DeviceInfo; }
|
|
13
|
-
// Forward declaration of `HybridCactusCryptoSpec` to properly resolve imports.
|
|
14
|
-
namespace margelo::nitro::cactus { class HybridCactusCryptoSpec; }
|
|
15
|
-
// Forward declaration of `HybridCactusDeviceInfoSpec` to properly resolve imports.
|
|
16
|
-
namespace margelo::nitro::cactus { class HybridCactusDeviceInfoSpec; }
|
|
17
11
|
// Forward declaration of `HybridCactusFileSystemSpec` to properly resolve imports.
|
|
18
12
|
namespace margelo::nitro::cactus { class HybridCactusFileSystemSpec; }
|
|
19
13
|
// Forward declaration of `HybridCactusImageSpec` to properly resolve imports.
|
|
20
14
|
namespace margelo::nitro::cactus { class HybridCactusImageSpec; }
|
|
21
15
|
|
|
22
16
|
// Include C++ defined types
|
|
23
|
-
#include "DeviceInfo.hpp"
|
|
24
|
-
#include "HybridCactusCryptoSpec.hpp"
|
|
25
|
-
#include "HybridCactusDeviceInfoSpec.hpp"
|
|
26
17
|
#include "HybridCactusFileSystemSpec.hpp"
|
|
27
18
|
#include "HybridCactusImageSpec.hpp"
|
|
28
19
|
#include <NitroModules/Promise.hpp>
|
|
@@ -43,10 +34,6 @@ namespace margelo::nitro::cactus { class HybridCactusImageSpec; }
|
|
|
43
34
|
#include <NitroModules/DateToChronoDate.hpp>
|
|
44
35
|
|
|
45
36
|
// Forward declarations of Swift defined types
|
|
46
|
-
// Forward declaration of `HybridCactusCryptoSpec_cxx` to properly resolve imports.
|
|
47
|
-
namespace Cactus { class HybridCactusCryptoSpec_cxx; }
|
|
48
|
-
// Forward declaration of `HybridCactusDeviceInfoSpec_cxx` to properly resolve imports.
|
|
49
|
-
namespace Cactus { class HybridCactusDeviceInfoSpec_cxx; }
|
|
50
37
|
// Forward declaration of `HybridCactusFileSystemSpec_cxx` to properly resolve imports.
|
|
51
38
|
namespace Cactus { class HybridCactusFileSystemSpec_cxx; }
|
|
52
39
|
// Forward declaration of `HybridCactusImageSpec_cxx` to properly resolve imports.
|
|
@@ -12,10 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
#include "HybridCactus.hpp"
|
|
14
14
|
#include "HybridCactusIndex.hpp"
|
|
15
|
-
#include "HybridCactusUtil.hpp"
|
|
16
15
|
#include "HybridCactusFileSystemSpecSwift.hpp"
|
|
17
|
-
#include "HybridCactusCryptoSpecSwift.hpp"
|
|
18
|
-
#include "HybridCactusDeviceInfoSpecSwift.hpp"
|
|
19
16
|
#include "HybridCactusImageSpecSwift.hpp"
|
|
20
17
|
|
|
21
18
|
@interface CactusAutolinking : NSObject
|
|
@@ -45,15 +42,6 @@
|
|
|
45
42
|
return std::make_shared<HybridCactusIndex>();
|
|
46
43
|
}
|
|
47
44
|
);
|
|
48
|
-
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
49
|
-
"CactusUtil",
|
|
50
|
-
[]() -> std::shared_ptr<HybridObject> {
|
|
51
|
-
static_assert(std::is_default_constructible_v<HybridCactusUtil>,
|
|
52
|
-
"The HybridObject \"HybridCactusUtil\" is not default-constructible! "
|
|
53
|
-
"Create a public constructor that takes zero arguments to be able to autolink this HybridObject.");
|
|
54
|
-
return std::make_shared<HybridCactusUtil>();
|
|
55
|
-
}
|
|
56
|
-
);
|
|
57
45
|
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
58
46
|
"CactusFileSystem",
|
|
59
47
|
[]() -> std::shared_ptr<HybridObject> {
|
|
@@ -61,20 +49,6 @@
|
|
|
61
49
|
return hybridObject;
|
|
62
50
|
}
|
|
63
51
|
);
|
|
64
|
-
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
65
|
-
"CactusCrypto",
|
|
66
|
-
[]() -> std::shared_ptr<HybridObject> {
|
|
67
|
-
std::shared_ptr<HybridCactusCryptoSpec> hybridObject = Cactus::CactusAutolinking::createCactusCrypto();
|
|
68
|
-
return hybridObject;
|
|
69
|
-
}
|
|
70
|
-
);
|
|
71
|
-
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
72
|
-
"CactusDeviceInfo",
|
|
73
|
-
[]() -> std::shared_ptr<HybridObject> {
|
|
74
|
-
std::shared_ptr<HybridCactusDeviceInfoSpec> hybridObject = Cactus::CactusAutolinking::createCactusDeviceInfo();
|
|
75
|
-
return hybridObject;
|
|
76
|
-
}
|
|
77
|
-
);
|
|
78
52
|
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
79
53
|
"CactusImage",
|
|
80
54
|
[]() -> std::shared_ptr<HybridObject> {
|
|
@@ -23,36 +23,6 @@ public final class CactusAutolinking {
|
|
|
23
23
|
}()
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
/**
|
|
27
|
-
* Creates an instance of a Swift class that implements `HybridCactusCryptoSpec`,
|
|
28
|
-
* and wraps it in a Swift class that can directly interop with C++ (`HybridCactusCryptoSpec_cxx`)
|
|
29
|
-
*
|
|
30
|
-
* This is generated by Nitrogen and will initialize the class specified
|
|
31
|
-
* in the `"autolinking"` property of `nitro.json` (in this case, `HybridCactusCrypto`).
|
|
32
|
-
*/
|
|
33
|
-
public static func createCactusCrypto() -> bridge.std__shared_ptr_HybridCactusCryptoSpec_ {
|
|
34
|
-
let hybridObject = HybridCactusCrypto()
|
|
35
|
-
return { () -> bridge.std__shared_ptr_HybridCactusCryptoSpec_ in
|
|
36
|
-
let __cxxWrapped = hybridObject.getCxxWrapper()
|
|
37
|
-
return __cxxWrapped.getCxxPart()
|
|
38
|
-
}()
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Creates an instance of a Swift class that implements `HybridCactusDeviceInfoSpec`,
|
|
43
|
-
* and wraps it in a Swift class that can directly interop with C++ (`HybridCactusDeviceInfoSpec_cxx`)
|
|
44
|
-
*
|
|
45
|
-
* This is generated by Nitrogen and will initialize the class specified
|
|
46
|
-
* in the `"autolinking"` property of `nitro.json` (in this case, `HybridCactusDeviceInfo`).
|
|
47
|
-
*/
|
|
48
|
-
public static func createCactusDeviceInfo() -> bridge.std__shared_ptr_HybridCactusDeviceInfoSpec_ {
|
|
49
|
-
let hybridObject = HybridCactusDeviceInfo()
|
|
50
|
-
return { () -> bridge.std__shared_ptr_HybridCactusDeviceInfoSpec_ in
|
|
51
|
-
let __cxxWrapped = hybridObject.getCxxWrapper()
|
|
52
|
-
return __cxxWrapped.getCxxPart()
|
|
53
|
-
}()
|
|
54
|
-
}
|
|
55
|
-
|
|
56
26
|
/**
|
|
57
27
|
* Creates an instance of a Swift class that implements `HybridCactusImageSpec`,
|
|
58
28
|
* and wraps it in a Swift class that can directly interop with C++ (`HybridCactusImageSpec_cxx`)
|
|
@@ -19,17 +19,18 @@ namespace margelo::nitro::cactus {
|
|
|
19
19
|
prototype.registerHybridMethod("tokenize", &HybridCactusSpec::tokenize);
|
|
20
20
|
prototype.registerHybridMethod("scoreWindow", &HybridCactusSpec::scoreWindow);
|
|
21
21
|
prototype.registerHybridMethod("transcribe", &HybridCactusSpec::transcribe);
|
|
22
|
-
prototype.registerHybridMethod("
|
|
23
|
-
prototype.registerHybridMethod("
|
|
22
|
+
prototype.registerHybridMethod("detectLanguage", &HybridCactusSpec::detectLanguage);
|
|
23
|
+
prototype.registerHybridMethod("streamTranscribeStart", &HybridCactusSpec::streamTranscribeStart);
|
|
24
24
|
prototype.registerHybridMethod("streamTranscribeProcess", &HybridCactusSpec::streamTranscribeProcess);
|
|
25
|
-
prototype.registerHybridMethod("
|
|
26
|
-
prototype.registerHybridMethod("
|
|
25
|
+
prototype.registerHybridMethod("streamTranscribeStop", &HybridCactusSpec::streamTranscribeStop);
|
|
26
|
+
prototype.registerHybridMethod("vad", &HybridCactusSpec::vad);
|
|
27
27
|
prototype.registerHybridMethod("embed", &HybridCactusSpec::embed);
|
|
28
28
|
prototype.registerHybridMethod("imageEmbed", &HybridCactusSpec::imageEmbed);
|
|
29
29
|
prototype.registerHybridMethod("audioEmbed", &HybridCactusSpec::audioEmbed);
|
|
30
30
|
prototype.registerHybridMethod("reset", &HybridCactusSpec::reset);
|
|
31
31
|
prototype.registerHybridMethod("stop", &HybridCactusSpec::stop);
|
|
32
32
|
prototype.registerHybridMethod("destroy", &HybridCactusSpec::destroy);
|
|
33
|
+
prototype.registerHybridMethod("setTelemetryEnvironment", &HybridCactusSpec::setTelemetryEnvironment);
|
|
33
34
|
});
|
|
34
35
|
}
|
|
35
36
|
|
|
@@ -53,22 +53,23 @@ namespace margelo::nitro::cactus {
|
|
|
53
53
|
|
|
54
54
|
public:
|
|
55
55
|
// Methods
|
|
56
|
-
virtual std::shared_ptr<Promise<void>> init(const std::string& modelPath,
|
|
56
|
+
virtual std::shared_ptr<Promise<void>> init(const std::string& modelPath, const std::optional<std::string>& corpusDir, std::optional<bool> cacheIndex) = 0;
|
|
57
57
|
virtual std::shared_ptr<Promise<std::string>> complete(const std::string& messagesJson, double responseBufferSize, const std::optional<std::string>& optionsJson, const std::optional<std::string>& toolsJson, const std::optional<std::function<void(const std::string& /* token */, double /* tokenId */)>>& callback) = 0;
|
|
58
58
|
virtual std::shared_ptr<Promise<std::vector<double>>> tokenize(const std::string& text) = 0;
|
|
59
59
|
virtual std::shared_ptr<Promise<std::string>> scoreWindow(const std::vector<double>& tokens, double start, double end, double context) = 0;
|
|
60
60
|
virtual std::shared_ptr<Promise<std::string>> transcribe(const std::variant<std::vector<double>, std::string>& audio, const std::string& prompt, double responseBufferSize, const std::optional<std::string>& optionsJson, const std::optional<std::function<void(const std::string& /* token */, double /* tokenId */)>>& callback) = 0;
|
|
61
|
-
virtual std::shared_ptr<Promise<
|
|
62
|
-
virtual std::shared_ptr<Promise<void>>
|
|
63
|
-
virtual std::shared_ptr<Promise<std::string>> streamTranscribeProcess(const std::
|
|
64
|
-
virtual std::shared_ptr<Promise<std::string>>
|
|
65
|
-
virtual std::shared_ptr<Promise<
|
|
61
|
+
virtual std::shared_ptr<Promise<std::string>> detectLanguage(const std::variant<std::vector<double>, std::string>& audio, double responseBufferSize, const std::optional<std::string>& optionsJson) = 0;
|
|
62
|
+
virtual std::shared_ptr<Promise<void>> streamTranscribeStart(const std::optional<std::string>& optionsJson) = 0;
|
|
63
|
+
virtual std::shared_ptr<Promise<std::string>> streamTranscribeProcess(const std::vector<double>& audio) = 0;
|
|
64
|
+
virtual std::shared_ptr<Promise<std::string>> streamTranscribeStop() = 0;
|
|
65
|
+
virtual std::shared_ptr<Promise<std::string>> vad(const std::variant<std::vector<double>, std::string>& audio, double responseBufferSize, const std::optional<std::string>& optionsJson) = 0;
|
|
66
66
|
virtual std::shared_ptr<Promise<std::vector<double>>> embed(const std::string& text, double embeddingBufferSize, bool normalize) = 0;
|
|
67
67
|
virtual std::shared_ptr<Promise<std::vector<double>>> imageEmbed(const std::string& imagePath, double embeddingBufferSize) = 0;
|
|
68
68
|
virtual std::shared_ptr<Promise<std::vector<double>>> audioEmbed(const std::string& audioPath, double embeddingBufferSize) = 0;
|
|
69
69
|
virtual std::shared_ptr<Promise<void>> reset() = 0;
|
|
70
70
|
virtual std::shared_ptr<Promise<void>> stop() = 0;
|
|
71
71
|
virtual std::shared_ptr<Promise<void>> destroy() = 0;
|
|
72
|
+
virtual std::shared_ptr<Promise<void>> setTelemetryEnvironment(const std::string& cacheDir) = 0;
|
|
72
73
|
|
|
73
74
|
protected:
|
|
74
75
|
// Hybrid Setup
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cactus-react-native",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "Run AI models locally on mobile devices",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"react": "19.1.0",
|
|
84
84
|
"react-native": "0.81.1",
|
|
85
85
|
"react-native-builder-bob": "^0.40.14",
|
|
86
|
-
"react-native-nitro-modules": "^0.
|
|
86
|
+
"react-native-nitro-modules": "^0.33.9",
|
|
87
87
|
"release-it": "^19.0.4",
|
|
88
88
|
"turbo": "^2.5.6",
|
|
89
89
|
"typescript": "^5.9.2"
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"peerDependencies": {
|
|
92
92
|
"react": "*",
|
|
93
93
|
"react-native": "*",
|
|
94
|
-
"react-native-nitro-modules": "^0.
|
|
94
|
+
"react-native-nitro-modules": "^0.33.9"
|
|
95
95
|
},
|
|
96
96
|
"workspaces": [
|
|
97
97
|
"example"
|
package/src/classes/CactusLM.ts
CHANGED
|
@@ -13,19 +13,15 @@ import type {
|
|
|
13
13
|
CactusLMImageEmbedResult,
|
|
14
14
|
CactusLMParams,
|
|
15
15
|
} from '../types/CactusLM';
|
|
16
|
-
import {
|
|
17
|
-
import { CactusConfig } from '../config/CactusConfig';
|
|
18
|
-
import { getErrorMessage } from '../utils/error';
|
|
19
|
-
import { RemoteLM } from '../api/RemoteLM';
|
|
20
|
-
import models from '../models';
|
|
16
|
+
import { getRegistry } from '../modelRegistry';
|
|
21
17
|
import type { CactusModel } from '../types/common';
|
|
22
18
|
|
|
23
19
|
export class CactusLM {
|
|
24
20
|
private readonly cactus = new Cactus();
|
|
25
21
|
|
|
26
22
|
private readonly model: string;
|
|
27
|
-
private readonly contextSize: number;
|
|
28
23
|
private readonly corpusDir?: string;
|
|
24
|
+
private readonly cacheIndex: boolean;
|
|
29
25
|
private readonly options: {
|
|
30
26
|
quantization: 'int4' | 'int8';
|
|
31
27
|
pro: boolean;
|
|
@@ -36,9 +32,8 @@ export class CactusLM {
|
|
|
36
32
|
private isGenerating = false;
|
|
37
33
|
|
|
38
34
|
private static readonly defaultModel = 'qwen3-0.6b';
|
|
39
|
-
private static readonly defaultContextSize = 2048;
|
|
40
35
|
private static readonly defaultOptions = {
|
|
41
|
-
quantization: '
|
|
36
|
+
quantization: 'int8' as const,
|
|
42
37
|
pro: false,
|
|
43
38
|
};
|
|
44
39
|
private static readonly quantizationExceptions: {
|
|
@@ -50,15 +45,12 @@ export class CactusLM {
|
|
|
50
45
|
private static readonly defaultCompleteOptions = {
|
|
51
46
|
maxTokens: 512,
|
|
52
47
|
};
|
|
53
|
-
private static readonly defaultCompleteMode = 'local';
|
|
54
48
|
private static readonly defaultEmbedBufferSize = 2048;
|
|
55
49
|
|
|
56
|
-
constructor({ model,
|
|
57
|
-
Telemetry.init(CactusConfig.telemetryToken);
|
|
58
|
-
|
|
50
|
+
constructor({ model, corpusDir, cacheIndex, options }: CactusLMParams = {}) {
|
|
59
51
|
this.model = model ?? CactusLM.defaultModel;
|
|
60
|
-
this.contextSize = contextSize ?? CactusLM.defaultContextSize;
|
|
61
52
|
this.corpusDir = corpusDir;
|
|
53
|
+
this.cacheIndex = cacheIndex ?? false;
|
|
62
54
|
this.options = {
|
|
63
55
|
quantization:
|
|
64
56
|
options?.quantization ??
|
|
@@ -88,8 +80,9 @@ export class CactusLM {
|
|
|
88
80
|
|
|
89
81
|
this.isDownloading = true;
|
|
90
82
|
try {
|
|
83
|
+
const registry = await getRegistry();
|
|
91
84
|
const modelConfig =
|
|
92
|
-
|
|
85
|
+
registry[this.model]?.quantization[this.options.quantization];
|
|
93
86
|
const url = this.options.pro ? modelConfig?.pro?.apple : modelConfig?.url;
|
|
94
87
|
|
|
95
88
|
if (!url) {
|
|
@@ -124,14 +117,10 @@ export class CactusLM {
|
|
|
124
117
|
modelPath = await CactusFileSystem.getModelPath(this.getModelName());
|
|
125
118
|
}
|
|
126
119
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
} catch (error) {
|
|
132
|
-
Telemetry.logInit(this.model, false, getErrorMessage(error));
|
|
133
|
-
throw error;
|
|
134
|
-
}
|
|
120
|
+
const cacheDir = await CactusFileSystem.getCactusDirectory();
|
|
121
|
+
await this.cactus.setTelemetryEnvironment(cacheDir);
|
|
122
|
+
await this.cactus.init(modelPath, this.corpusDir, this.cacheIndex);
|
|
123
|
+
this.isInitialized = true;
|
|
135
124
|
}
|
|
136
125
|
|
|
137
126
|
public async complete({
|
|
@@ -139,7 +128,6 @@ export class CactusLM {
|
|
|
139
128
|
options,
|
|
140
129
|
tools,
|
|
141
130
|
onToken,
|
|
142
|
-
mode,
|
|
143
131
|
}: CactusLMCompleteParams): Promise<CactusLMCompleteResult> {
|
|
144
132
|
if (this.isGenerating) {
|
|
145
133
|
throw new Error('CactusLM is already generating');
|
|
@@ -150,49 +138,22 @@ export class CactusLM {
|
|
|
150
138
|
type: 'function' as const,
|
|
151
139
|
function: tool,
|
|
152
140
|
}));
|
|
153
|
-
mode = mode ?? CactusLM.defaultCompleteMode;
|
|
154
141
|
|
|
155
142
|
const responseBufferSize =
|
|
156
143
|
8 * (options.maxTokens ?? CactusLM.defaultCompleteOptions.maxTokens) +
|
|
157
144
|
256;
|
|
158
145
|
|
|
159
|
-
|
|
160
|
-
await this.init();
|
|
146
|
+
await this.init();
|
|
161
147
|
|
|
162
|
-
|
|
163
|
-
|
|
148
|
+
this.isGenerating = true;
|
|
149
|
+
try {
|
|
150
|
+
return await this.cactus.complete(
|
|
164
151
|
messages,
|
|
165
152
|
responseBufferSize,
|
|
166
153
|
options,
|
|
167
154
|
toolsInternal,
|
|
168
155
|
onToken
|
|
169
156
|
);
|
|
170
|
-
Telemetry.logCompletion(
|
|
171
|
-
this.model,
|
|
172
|
-
result.success,
|
|
173
|
-
result.success ? undefined : result.response,
|
|
174
|
-
result
|
|
175
|
-
);
|
|
176
|
-
return result;
|
|
177
|
-
} catch (localError) {
|
|
178
|
-
if (mode === 'local') {
|
|
179
|
-
Telemetry.logCompletion(this.model, false, getErrorMessage(localError));
|
|
180
|
-
throw localError;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
Telemetry.logCompletion(
|
|
184
|
-
this.model,
|
|
185
|
-
false,
|
|
186
|
-
`Local completion error: ${getErrorMessage(localError)}. Falling back to remote completion.`
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
try {
|
|
190
|
-
return RemoteLM.complete(messages, options, toolsInternal, onToken);
|
|
191
|
-
} catch (remoteError) {
|
|
192
|
-
throw new Error(
|
|
193
|
-
`Remote completion error: ${getErrorMessage(remoteError)}`
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
157
|
} finally {
|
|
197
158
|
this.isGenerating = false;
|
|
198
159
|
}
|
|
@@ -232,11 +193,7 @@ export class CactusLM {
|
|
|
232
193
|
CactusLM.defaultEmbedBufferSize,
|
|
233
194
|
normalize
|
|
234
195
|
);
|
|
235
|
-
Telemetry.logEmbedding(this.model, true);
|
|
236
196
|
return { embedding };
|
|
237
|
-
} catch (error) {
|
|
238
|
-
Telemetry.logEmbedding(this.model, false, getErrorMessage(error));
|
|
239
|
-
throw error;
|
|
240
197
|
} finally {
|
|
241
198
|
this.isGenerating = false;
|
|
242
199
|
}
|
|
@@ -257,11 +214,7 @@ export class CactusLM {
|
|
|
257
214
|
imagePath,
|
|
258
215
|
CactusLM.defaultEmbedBufferSize
|
|
259
216
|
);
|
|
260
|
-
Telemetry.logImageEmbedding(this.model, true);
|
|
261
217
|
return { embedding };
|
|
262
|
-
} catch (error) {
|
|
263
|
-
Telemetry.logImageEmbedding(this.model, false, getErrorMessage(error));
|
|
264
|
-
throw error;
|
|
265
218
|
} finally {
|
|
266
219
|
this.isGenerating = false;
|
|
267
220
|
}
|
|
@@ -287,15 +240,15 @@ export class CactusLM {
|
|
|
287
240
|
this.isInitialized = false;
|
|
288
241
|
}
|
|
289
242
|
|
|
290
|
-
public getModels(): CactusModel[] {
|
|
291
|
-
return Object.values(
|
|
243
|
+
public async getModels(): Promise<CactusModel[]> {
|
|
244
|
+
return Object.values(await getRegistry());
|
|
292
245
|
}
|
|
293
246
|
|
|
294
247
|
private isModelPath(model: string): boolean {
|
|
295
248
|
return model.startsWith('file://') || model.startsWith('/');
|
|
296
249
|
}
|
|
297
250
|
|
|
298
|
-
|
|
251
|
+
public getModelName(): string {
|
|
299
252
|
return `${this.model}-${this.options.quantization}${this.options.pro ? '-pro' : ''}`;
|
|
300
253
|
}
|
|
301
254
|
}
|