cactus-react-native 1.5.0 → 1.7.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 +149 -117
- package/cpp/HybridCactus.hpp +14 -10
- package/cpp/cactus_ffi.h +54 -43
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus.h +0 -1
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_ffi.h +54 -43
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_utils.h +318 -123
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/engine.h +118 -15
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/graph.h +77 -32
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/kernel.h +68 -6
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/kernel_utils.h +21 -155
- 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_ffi.h +54 -43
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_utils.h +318 -123
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/engine.h +118 -15
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/graph.h +77 -32
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/kernel.h +68 -6
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/kernel_utils.h +21 -155
- 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 +30 -79
- 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 +85 -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 +8 -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 +12 -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 +6 -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 +33 -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 +4 -4
- package/nitrogen/generated/shared/c++/HybridCactusSpec.hpp +6 -6
- package/package.json +3 -3
- package/src/classes/CactusLM.ts +18 -65
- package/src/classes/CactusSTT.ts +39 -97
- 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 +18 -12
- package/src/modelRegistry.ts +65 -0
- package/src/native/Cactus.ts +102 -41
- package/src/native/CactusIndex.ts +2 -2
- package/src/native/index.ts +0 -3
- package/src/specs/Cactus.nitro.ts +11 -7
- package/src/types/CactusIndex.ts +2 -2
- package/src/types/CactusLM.ts +19 -11
- package/src/types/CactusSTT.ts +33 -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
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
#include <arm_neon.h>
|
|
5
5
|
#if defined(__APPLE__)
|
|
6
6
|
#include <TargetConditionals.h>
|
|
7
|
+
#include <sys/sysctl.h>
|
|
7
8
|
#endif
|
|
8
9
|
#if defined(__ANDROID__)
|
|
9
10
|
#include <sys/auxv.h>
|
|
@@ -43,59 +44,6 @@ inline void stream_store_f16x8(__fp16* dst, float16x8_t val) {
|
|
|
43
44
|
#endif
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
#if defined(__ARM_FEATURE_DOTPROD)
|
|
47
|
-
inline int32x4_t accum_dot(int32x4_t acc, int8x16_t a, int8x16_t b) {
|
|
48
|
-
return vdotq_s32(acc, a, b);
|
|
49
|
-
}
|
|
50
|
-
#else
|
|
51
|
-
inline int32x4_t accum_dot(int32x4_t acc, int8x16_t a, int8x16_t b) {
|
|
52
|
-
int16x8_t prod_low = vmull_s8(vget_low_s8(a), vget_low_s8(b));
|
|
53
|
-
int32x4_t acc_high = vpaddlq_s16(vmull_s8(vget_high_s8(a), vget_high_s8(b)));
|
|
54
|
-
return vaddq_s32(vaddq_s32(acc, vpaddlq_s16(prod_low)), acc_high);
|
|
55
|
-
}
|
|
56
|
-
#endif
|
|
57
|
-
|
|
58
|
-
// I8MM support: runtime detection on Android, compile-time on Apple
|
|
59
|
-
#if defined(__ANDROID__) && defined(__aarch64__)
|
|
60
|
-
|
|
61
|
-
inline bool cactus_has_i8mm() {
|
|
62
|
-
static int8_t supported = -1;
|
|
63
|
-
if (supported == -1) {
|
|
64
|
-
unsigned long hwcaps = getauxval(AT_HWCAP2);
|
|
65
|
-
supported = (hwcaps & HWCAP2_I8MM) ? 1 : 0;
|
|
66
|
-
}
|
|
67
|
-
return supported;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
__attribute__((target("arch=armv8.2-a+i8mm")))
|
|
71
|
-
inline int32x4_t accum_matmul(int32x4_t acc, int8x16_t a, int8x16_t b) {
|
|
72
|
-
return vmmlaq_s32(acc, a, b);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
#elif defined(__APPLE__) && defined(__aarch64__)
|
|
76
|
-
|
|
77
|
-
inline bool cactus_has_i8mm() {
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
__attribute__((target("i8mm")))
|
|
82
|
-
inline int32x4_t accum_matmul(int32x4_t acc, int8x16_t a, int8x16_t b) {
|
|
83
|
-
return vmmlaq_s32(acc, a, b);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
#else
|
|
87
|
-
|
|
88
|
-
inline bool cactus_has_i8mm() {
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
#endif
|
|
93
|
-
|
|
94
|
-
inline float16x8_t accum_f16_dot(float16x8_t acc, float16x8_t a_low, float16x8_t a_high,
|
|
95
|
-
float16x8_t b_low, float16x8_t b_high) {
|
|
96
|
-
acc = vfmaq_f16(acc, a_low, b_low);
|
|
97
|
-
return vfmaq_f16(acc, a_high, b_high);
|
|
98
|
-
}
|
|
99
47
|
|
|
100
48
|
inline float32x4_t fast_exp_f32x4(float32x4_t x) {
|
|
101
49
|
const float32x4_t log2e = vdupq_n_f32(1.4426950408889634f);
|
|
@@ -154,102 +102,6 @@ inline float32x4_t fast_tanh_f32x4(float32x4_t x) {
|
|
|
154
102
|
return result;
|
|
155
103
|
}
|
|
156
104
|
|
|
157
|
-
inline int8x16_t unpack_int4_lo(uint8x16_t packed) {
|
|
158
|
-
uint8x16_t lo = vandq_u8(packed, vdupq_n_u8(0x0F));
|
|
159
|
-
uint8x16_t sign_mask = vcgtq_u8(lo, vdupq_n_u8(7));
|
|
160
|
-
uint8x16_t correction = vandq_u8(sign_mask, vdupq_n_u8(16));
|
|
161
|
-
return vreinterpretq_s8_u8(vsubq_u8(lo, correction));
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
inline int8x16_t unpack_int4_hi(uint8x16_t packed) {
|
|
165
|
-
uint8x16_t hi = vshrq_n_u8(packed, 4);
|
|
166
|
-
uint8x16_t sign_mask = vcgtq_u8(hi, vdupq_n_u8(7));
|
|
167
|
-
uint8x16_t correction = vandq_u8(sign_mask, vdupq_n_u8(16));
|
|
168
|
-
return vreinterpretq_s8_u8(vsubq_u8(hi, correction));
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
inline void unpack_int4_to_int8x32(uint8x16_t packed, int8x16_t& out_lo, int8x16_t& out_hi) {
|
|
172
|
-
int8x16_t lo_nibbles = unpack_int4_lo(packed);
|
|
173
|
-
int8x16_t hi_nibbles = unpack_int4_hi(packed);
|
|
174
|
-
int8x16x2_t interleaved = vzipq_s8(lo_nibbles, hi_nibbles);
|
|
175
|
-
out_lo = interleaved.val[0];
|
|
176
|
-
out_hi = interleaved.val[1];
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
inline int32x4_t int4_dot_asm(int32x4_t acc, uint8x16_t packed, int8x16_t a_lo, int8x16_t a_hi) {
|
|
180
|
-
#if defined(__aarch64__)
|
|
181
|
-
int8x16_t b_lo, b_hi;
|
|
182
|
-
|
|
183
|
-
__asm__ __volatile__ (
|
|
184
|
-
"movi v16.16b, #0x0F \n" // low nibble mask
|
|
185
|
-
"movi v17.16b, #7 \n" // sign threshold
|
|
186
|
-
"movi v18.16b, #16 \n" // sign correction
|
|
187
|
-
|
|
188
|
-
"and %[b_lo].16b, %[packed].16b, v16.16b \n"
|
|
189
|
-
|
|
190
|
-
"ushr %[b_hi].16b, %[packed].16b, #4 \n"
|
|
191
|
-
|
|
192
|
-
"cmgt v19.16b, %[b_lo].16b, v17.16b \n"
|
|
193
|
-
"and v19.16b, v19.16b, v18.16b \n"
|
|
194
|
-
"sub %[b_lo].16b, %[b_lo].16b, v19.16b \n"
|
|
195
|
-
|
|
196
|
-
"cmgt v20.16b, %[b_hi].16b, v17.16b \n"
|
|
197
|
-
"and v20.16b, v20.16b, v18.16b \n"
|
|
198
|
-
"sub %[b_hi].16b, %[b_hi].16b, v20.16b \n"
|
|
199
|
-
|
|
200
|
-
"zip1 v21.16b, %[b_lo].16b, %[b_hi].16b \n"
|
|
201
|
-
"zip2 v22.16b, %[b_lo].16b, %[b_hi].16b \n"
|
|
202
|
-
|
|
203
|
-
".arch armv8.2-a+dotprod \n"
|
|
204
|
-
"sdot %[acc].4s, %[a_lo].16b, v21.16b \n"
|
|
205
|
-
"sdot %[acc].4s, %[a_hi].16b, v22.16b \n"
|
|
206
|
-
|
|
207
|
-
: [acc] "+w"(acc), [b_lo] "=w"(b_lo), [b_hi] "=w"(b_hi)
|
|
208
|
-
: [packed] "w"(packed), [a_lo] "w"(a_lo), [a_hi] "w"(a_hi)
|
|
209
|
-
: "v16", "v17", "v18", "v19", "v20", "v21", "v22"
|
|
210
|
-
);
|
|
211
|
-
|
|
212
|
-
return acc;
|
|
213
|
-
#else
|
|
214
|
-
int8x16_t b_lo, b_hi;
|
|
215
|
-
unpack_int4_to_int8x32(packed, b_lo, b_hi);
|
|
216
|
-
acc = accum_dot(acc, a_lo, b_lo);
|
|
217
|
-
acc = accum_dot(acc, a_hi, b_hi);
|
|
218
|
-
return acc;
|
|
219
|
-
#endif
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
inline int32_t int4_dot_m1_asm(const int8_t* a_ptr, const uint8_t* b_packed, size_t group_size) {
|
|
223
|
-
#if defined(__aarch64__)
|
|
224
|
-
int32x4_t acc = vdupq_n_s32(0);
|
|
225
|
-
|
|
226
|
-
for (size_t k = 0; k < group_size; k += 64) {
|
|
227
|
-
uint8x16_t p0 = vld1q_u8(b_packed + k/2);
|
|
228
|
-
uint8x16_t p1 = vld1q_u8(b_packed + k/2 + 16);
|
|
229
|
-
|
|
230
|
-
int8x16_t a0 = vld1q_s8(a_ptr + k);
|
|
231
|
-
int8x16_t a1 = vld1q_s8(a_ptr + k + 16);
|
|
232
|
-
int8x16_t a2 = vld1q_s8(a_ptr + k + 32);
|
|
233
|
-
int8x16_t a3 = vld1q_s8(a_ptr + k + 48);
|
|
234
|
-
|
|
235
|
-
acc = int4_dot_asm(acc, p0, a0, a1);
|
|
236
|
-
acc = int4_dot_asm(acc, p1, a2, a3);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
return vaddvq_s32(acc);
|
|
240
|
-
#else
|
|
241
|
-
int32x4_t acc = vdupq_n_s32(0);
|
|
242
|
-
for (size_t k = 0; k < group_size; k += 32) {
|
|
243
|
-
uint8x16_t packed = vld1q_u8(b_packed + k/2);
|
|
244
|
-
int8x16_t b_lo, b_hi;
|
|
245
|
-
unpack_int4_to_int8x32(packed, b_lo, b_hi);
|
|
246
|
-
acc = accum_dot(acc, vld1q_s8(a_ptr + k), b_lo);
|
|
247
|
-
acc = accum_dot(acc, vld1q_s8(a_ptr + k + 16), b_hi);
|
|
248
|
-
}
|
|
249
|
-
return vaddvq_s32(acc);
|
|
250
|
-
#endif
|
|
251
|
-
}
|
|
252
|
-
|
|
253
105
|
namespace CactusThreading {
|
|
254
106
|
|
|
255
107
|
class ThreadPool {
|
|
@@ -431,18 +283,32 @@ namespace CactusThreading {
|
|
|
431
283
|
struct GemmThreading {
|
|
432
284
|
#if defined(__ANDROID__)
|
|
433
285
|
static size_t get_num_threads(size_t M, size_t pool_size) {
|
|
434
|
-
if (M <= 1) return 1;
|
|
435
|
-
return pool_size;
|
|
286
|
+
if (M <= 1) return 1;
|
|
287
|
+
return pool_size;
|
|
288
|
+
}
|
|
289
|
+
static size_t get_gemv_threads(size_t /*N_blocks*/, size_t /*pool_size*/) {
|
|
290
|
+
return 1;
|
|
436
291
|
}
|
|
437
292
|
#elif defined(__APPLE__) && TARGET_OS_IPHONE
|
|
293
|
+
static constexpr size_t GEMV_MIN_N_BLOCKS = 512;
|
|
438
294
|
static size_t get_num_threads(size_t M, size_t pool_size) {
|
|
439
|
-
if (M <= 1) return std::min(pool_size, static_cast<size_t>(2));
|
|
440
|
-
return pool_size;
|
|
295
|
+
if (M <= 1) return std::min(pool_size, static_cast<size_t>(2));
|
|
296
|
+
return pool_size;
|
|
297
|
+
}
|
|
298
|
+
static size_t get_gemv_threads(size_t N_blocks, size_t pool_size) {
|
|
299
|
+
if (N_blocks < GEMV_MIN_N_BLOCKS) return 1;
|
|
300
|
+
return std::min(pool_size, static_cast<size_t>(2));
|
|
441
301
|
}
|
|
442
|
-
#else
|
|
302
|
+
#else
|
|
303
|
+
static constexpr size_t GEMV_MIN_N_BLOCKS = 256;
|
|
443
304
|
static size_t get_num_threads(size_t M, size_t pool_size) {
|
|
444
305
|
if (M <= 1) return std::min(pool_size, static_cast<size_t>(4));
|
|
445
|
-
return pool_size;
|
|
306
|
+
return pool_size;
|
|
307
|
+
}
|
|
308
|
+
static size_t get_gemv_threads(size_t N_blocks, size_t pool_size) {
|
|
309
|
+
if (N_blocks < GEMV_MIN_N_BLOCKS) return 1;
|
|
310
|
+
if (N_blocks < 512) return std::min(pool_size, static_cast<size_t>(2));
|
|
311
|
+
return std::min(pool_size, static_cast<size_t>(4));
|
|
446
312
|
}
|
|
447
313
|
#endif
|
|
448
314
|
};
|
|
Binary file
|
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { Cactus, CactusFileSystem } from "../native/index.js";
|
|
4
|
-
import {
|
|
5
|
-
import { CactusConfig } from "../config/CactusConfig.js";
|
|
6
|
-
import { getErrorMessage } from "../utils/error.js";
|
|
7
|
-
import { RemoteLM } from "../api/RemoteLM.js";
|
|
8
|
-
import models from "../models.js";
|
|
4
|
+
import { getRegistry } from "../modelRegistry.js";
|
|
9
5
|
export class CactusLM {
|
|
10
6
|
cactus = new Cactus();
|
|
11
7
|
isDownloading = false;
|
|
12
8
|
isInitialized = false;
|
|
13
9
|
isGenerating = false;
|
|
14
10
|
static defaultModel = 'qwen3-0.6b';
|
|
15
|
-
static defaultContextSize = 2048;
|
|
16
11
|
static defaultOptions = {
|
|
17
|
-
quantization: '
|
|
12
|
+
quantization: 'int8',
|
|
18
13
|
pro: false
|
|
19
14
|
};
|
|
20
15
|
static quantizationExceptions = {
|
|
@@ -24,18 +19,16 @@ export class CactusLM {
|
|
|
24
19
|
static defaultCompleteOptions = {
|
|
25
20
|
maxTokens: 512
|
|
26
21
|
};
|
|
27
|
-
static defaultCompleteMode = 'local';
|
|
28
22
|
static defaultEmbedBufferSize = 2048;
|
|
29
23
|
constructor({
|
|
30
24
|
model,
|
|
31
|
-
contextSize,
|
|
32
25
|
corpusDir,
|
|
26
|
+
cacheIndex,
|
|
33
27
|
options
|
|
34
28
|
} = {}) {
|
|
35
|
-
Telemetry.init(CactusConfig.telemetryToken);
|
|
36
29
|
this.model = model ?? CactusLM.defaultModel;
|
|
37
|
-
this.contextSize = contextSize ?? CactusLM.defaultContextSize;
|
|
38
30
|
this.corpusDir = corpusDir;
|
|
31
|
+
this.cacheIndex = cacheIndex ?? false;
|
|
39
32
|
this.options = {
|
|
40
33
|
quantization: options?.quantization ?? CactusLM.quantizationExceptions[this.model] ?? CactusLM.defaultOptions.quantization,
|
|
41
34
|
pro: options?.pro ?? CactusLM.defaultOptions.pro
|
|
@@ -58,7 +51,8 @@ export class CactusLM {
|
|
|
58
51
|
}
|
|
59
52
|
this.isDownloading = true;
|
|
60
53
|
try {
|
|
61
|
-
const
|
|
54
|
+
const registry = await getRegistry();
|
|
55
|
+
const modelConfig = registry[this.model]?.quantization[this.options.quantization];
|
|
62
56
|
const url = this.options.pro ? modelConfig?.pro?.apple : modelConfig?.url;
|
|
63
57
|
if (!url) {
|
|
64
58
|
throw new Error(`Model ${this.model} with specified options not found`);
|
|
@@ -82,21 +76,16 @@ export class CactusLM {
|
|
|
82
76
|
}
|
|
83
77
|
modelPath = await CactusFileSystem.getModelPath(this.getModelName());
|
|
84
78
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
} catch (error) {
|
|
90
|
-
Telemetry.logInit(this.model, false, getErrorMessage(error));
|
|
91
|
-
throw error;
|
|
92
|
-
}
|
|
79
|
+
const cacheDir = await CactusFileSystem.getCactusDirectory();
|
|
80
|
+
await this.cactus.setTelemetryEnvironment(cacheDir);
|
|
81
|
+
await this.cactus.init(modelPath, this.corpusDir, this.cacheIndex);
|
|
82
|
+
this.isInitialized = true;
|
|
93
83
|
}
|
|
94
84
|
async complete({
|
|
95
85
|
messages,
|
|
96
86
|
options,
|
|
97
87
|
tools,
|
|
98
|
-
onToken
|
|
99
|
-
mode
|
|
88
|
+
onToken
|
|
100
89
|
}) {
|
|
101
90
|
if (this.isGenerating) {
|
|
102
91
|
throw new Error('CactusLM is already generating');
|
|
@@ -109,25 +98,11 @@ export class CactusLM {
|
|
|
109
98
|
type: 'function',
|
|
110
99
|
function: tool
|
|
111
100
|
}));
|
|
112
|
-
mode = mode ?? CactusLM.defaultCompleteMode;
|
|
113
101
|
const responseBufferSize = 8 * (options.maxTokens ?? CactusLM.defaultCompleteOptions.maxTokens) + 256;
|
|
102
|
+
await this.init();
|
|
103
|
+
this.isGenerating = true;
|
|
114
104
|
try {
|
|
115
|
-
await this.
|
|
116
|
-
this.isGenerating = true;
|
|
117
|
-
const result = await this.cactus.complete(messages, responseBufferSize, options, toolsInternal, onToken);
|
|
118
|
-
Telemetry.logCompletion(this.model, result.success, result.success ? undefined : result.response, result);
|
|
119
|
-
return result;
|
|
120
|
-
} catch (localError) {
|
|
121
|
-
if (mode === 'local') {
|
|
122
|
-
Telemetry.logCompletion(this.model, false, getErrorMessage(localError));
|
|
123
|
-
throw localError;
|
|
124
|
-
}
|
|
125
|
-
Telemetry.logCompletion(this.model, false, `Local completion error: ${getErrorMessage(localError)}. Falling back to remote completion.`);
|
|
126
|
-
try {
|
|
127
|
-
return RemoteLM.complete(messages, options, toolsInternal, onToken);
|
|
128
|
-
} catch (remoteError) {
|
|
129
|
-
throw new Error(`Remote completion error: ${getErrorMessage(remoteError)}`);
|
|
130
|
-
}
|
|
105
|
+
return await this.cactus.complete(messages, responseBufferSize, options, toolsInternal, onToken);
|
|
131
106
|
} finally {
|
|
132
107
|
this.isGenerating = false;
|
|
133
108
|
}
|
|
@@ -160,13 +135,9 @@ export class CactusLM {
|
|
|
160
135
|
this.isGenerating = true;
|
|
161
136
|
try {
|
|
162
137
|
const embedding = await this.cactus.embed(text, CactusLM.defaultEmbedBufferSize, normalize);
|
|
163
|
-
Telemetry.logEmbedding(this.model, true);
|
|
164
138
|
return {
|
|
165
139
|
embedding
|
|
166
140
|
};
|
|
167
|
-
} catch (error) {
|
|
168
|
-
Telemetry.logEmbedding(this.model, false, getErrorMessage(error));
|
|
169
|
-
throw error;
|
|
170
141
|
} finally {
|
|
171
142
|
this.isGenerating = false;
|
|
172
143
|
}
|
|
@@ -181,13 +152,9 @@ export class CactusLM {
|
|
|
181
152
|
this.isGenerating = true;
|
|
182
153
|
try {
|
|
183
154
|
const embedding = await this.cactus.imageEmbed(imagePath, CactusLM.defaultEmbedBufferSize);
|
|
184
|
-
Telemetry.logImageEmbedding(this.model, true);
|
|
185
155
|
return {
|
|
186
156
|
embedding
|
|
187
157
|
};
|
|
188
|
-
} catch (error) {
|
|
189
|
-
Telemetry.logImageEmbedding(this.model, false, getErrorMessage(error));
|
|
190
|
-
throw error;
|
|
191
158
|
} finally {
|
|
192
159
|
this.isGenerating = false;
|
|
193
160
|
}
|
|
@@ -207,8 +174,8 @@ export class CactusLM {
|
|
|
207
174
|
await this.cactus.destroy();
|
|
208
175
|
this.isInitialized = false;
|
|
209
176
|
}
|
|
210
|
-
getModels() {
|
|
211
|
-
return Object.values(
|
|
177
|
+
async getModels() {
|
|
178
|
+
return Object.values(await getRegistry());
|
|
212
179
|
}
|
|
213
180
|
isModelPath(model) {
|
|
214
181
|
return model.startsWith('file://') || model.startsWith('/');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Cactus","CactusFileSystem","
|
|
1
|
+
{"version":3,"names":["Cactus","CactusFileSystem","getRegistry","CactusLM","cactus","isDownloading","isInitialized","isGenerating","defaultModel","defaultOptions","quantization","pro","quantizationExceptions","defaultCompleteOptions","maxTokens","defaultEmbedBufferSize","constructor","model","corpusDir","cacheIndex","options","download","onProgress","isModelPath","Error","modelExists","getModelName","console","log","registry","modelConfig","url","apple","downloadModel","init","modelPath","replace","JSON","stringify","getModelPath","cacheDir","getCactusDirectory","setTelemetryEnvironment","complete","messages","tools","onToken","toolsInternal","map","tool","type","function","responseBufferSize","tokenize","text","tokens","scoreWindow","start","end","context","score","embed","normalize","embedding","imageEmbed","imagePath","stop","reset","destroy","getModels","Object","values","startsWith"],"sourceRoot":"../../../src","sources":["classes/CactusLM.ts"],"mappings":";;AAAA,SAASA,MAAM,EAAEC,gBAAgB,QAAQ,oBAAW;AAepD,SAASC,WAAW,QAAQ,qBAAkB;AAG9C,OAAO,MAAMC,QAAQ,CAAC;EACHC,MAAM,GAAG,IAAIJ,MAAM,CAAC,CAAC;EAU9BK,aAAa,GAAG,KAAK;EACrBC,aAAa,GAAG,KAAK;EACrBC,YAAY,GAAG,KAAK;EAE5B,OAAwBC,YAAY,GAAG,YAAY;EACnD,OAAwBC,cAAc,GAAG;IACvCC,YAAY,EAAE,MAAe;IAC7BC,GAAG,EAAE;EACP,CAAC;EACD,OAAwBC,sBAAsB,GAE1C;IACF,iBAAiB,EAAE,MAAe;IAClC,uBAAuB,EAAE;EAC3B,CAAC;EACD,OAAwBC,sBAAsB,GAAG;IAC/CC,SAAS,EAAE;EACb,CAAC;EACD,OAAwBC,sBAAsB,GAAG,IAAI;EAErDC,WAAWA,CAAC;IAAEC,KAAK;IAAEC,SAAS;IAAEC,UAAU;IAAEC;EAAwB,CAAC,GAAG,CAAC,CAAC,EAAE;IAC1E,IAAI,CAACH,KAAK,GAAGA,KAAK,IAAId,QAAQ,CAACK,YAAY;IAC3C,IAAI,CAACU,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAACC,UAAU,GAAGA,UAAU,IAAI,KAAK;IACrC,IAAI,CAACC,OAAO,GAAG;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A,MAAa+D,SAASA,CAAA,EAA2B;IAC/C,OAAOC,MAAM,CAACC,MAAM,CAAC,MAAMrE,WAAW,CAAC,CAAC,CAAC;EAC3C;EAEQqB,WAAWA,CAACN,KAAa,EAAW;IAC1C,OAAOA,KAAK,CAACuD,UAAU,CAAC,SAAS,CAAC,IAAIvD,KAAK,CAACuD,UAAU,CAAC,GAAG,CAAC;EAC7D;EAEO9C,YAAYA,CAAA,EAAW;IAC5B,OAAO,GAAG,IAAI,CAACT,KAAK,IAAI,IAAI,CAACG,OAAO,CAACV,YAAY,GAAG,IAAI,CAACU,OAAO,CAACT,GAAG,GAAG,MAAM,GAAG,EAAE,EAAE;EACtF;AACF","ignoreList":[]}
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { Cactus, CactusFileSystem } from "../native/index.js";
|
|
4
|
-
import {
|
|
5
|
-
import { CactusConfig } from "../config/CactusConfig.js";
|
|
6
|
-
import { getErrorMessage } from "../utils/error.js";
|
|
7
|
-
import models from "../models.js";
|
|
4
|
+
import { getRegistry } from "../modelRegistry.js";
|
|
8
5
|
export class CactusSTT {
|
|
9
6
|
cactus = new Cactus();
|
|
10
7
|
isDownloading = false;
|
|
11
8
|
isInitialized = false;
|
|
12
9
|
isGenerating = false;
|
|
13
|
-
|
|
10
|
+
isStreamTranscribing = false;
|
|
14
11
|
static defaultModel = 'whisper-small';
|
|
15
|
-
static defaultContextSize = 2048;
|
|
16
12
|
static defaultOptions = {
|
|
17
|
-
quantization: '
|
|
13
|
+
quantization: 'int8',
|
|
18
14
|
pro: false
|
|
19
15
|
};
|
|
20
16
|
static defaultPrompt = '<|startoftranscript|><|en|><|transcribe|><|notimestamps|>';
|
|
@@ -24,12 +20,9 @@ export class CactusSTT {
|
|
|
24
20
|
static defaultEmbedBufferSize = 4096;
|
|
25
21
|
constructor({
|
|
26
22
|
model,
|
|
27
|
-
contextSize,
|
|
28
23
|
options
|
|
29
24
|
} = {}) {
|
|
30
|
-
Telemetry.init(CactusConfig.telemetryToken);
|
|
31
25
|
this.model = model ?? CactusSTT.defaultModel;
|
|
32
|
-
this.contextSize = contextSize ?? CactusSTT.defaultContextSize;
|
|
33
26
|
this.options = {
|
|
34
27
|
quantization: options?.quantization ?? CactusSTT.defaultOptions.quantization,
|
|
35
28
|
pro: options?.pro ?? CactusSTT.defaultOptions.pro
|
|
@@ -52,7 +45,8 @@ export class CactusSTT {
|
|
|
52
45
|
}
|
|
53
46
|
this.isDownloading = true;
|
|
54
47
|
try {
|
|
55
|
-
const
|
|
48
|
+
const registry = await getRegistry();
|
|
49
|
+
const modelConfig = registry[this.model]?.quantization[this.options.quantization];
|
|
56
50
|
const url = this.options.pro ? modelConfig?.pro?.apple : modelConfig?.url;
|
|
57
51
|
if (!url) {
|
|
58
52
|
throw new Error(`Model ${this.model} with specified options not found`);
|
|
@@ -76,14 +70,10 @@ export class CactusSTT {
|
|
|
76
70
|
}
|
|
77
71
|
modelPath = await CactusFileSystem.getModelPath(this.getModelName());
|
|
78
72
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
} catch (error) {
|
|
84
|
-
Telemetry.logInit(this.model, false, getErrorMessage(error));
|
|
85
|
-
throw error;
|
|
86
|
-
}
|
|
73
|
+
const cacheDir = await CactusFileSystem.getCactusDirectory();
|
|
74
|
+
await this.cactus.setTelemetryEnvironment(cacheDir);
|
|
75
|
+
await this.cactus.init(modelPath);
|
|
76
|
+
this.isInitialized = true;
|
|
87
77
|
}
|
|
88
78
|
async transcribe({
|
|
89
79
|
audio,
|
|
@@ -103,73 +93,35 @@ export class CactusSTT {
|
|
|
103
93
|
const responseBufferSize = 8 * (options.maxTokens ?? CactusSTT.defaultTranscribeOptions.maxTokens) + 256;
|
|
104
94
|
this.isGenerating = true;
|
|
105
95
|
try {
|
|
106
|
-
|
|
107
|
-
Telemetry.logTranscribe(this.model, result.success, result.success ? undefined : result.response, result);
|
|
108
|
-
return result;
|
|
109
|
-
} catch (error) {
|
|
110
|
-
Telemetry.logTranscribe(this.model, false, getErrorMessage(error));
|
|
111
|
-
throw error;
|
|
96
|
+
return await this.cactus.transcribe(audio, prompt, responseBufferSize, options, onToken);
|
|
112
97
|
} finally {
|
|
113
98
|
this.isGenerating = false;
|
|
114
99
|
}
|
|
115
100
|
}
|
|
116
|
-
async
|
|
117
|
-
if (this.
|
|
101
|
+
async streamTranscribeStart(options) {
|
|
102
|
+
if (this.isStreamTranscribing) {
|
|
118
103
|
return;
|
|
119
104
|
}
|
|
120
105
|
await this.init();
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
this.isStreamTranscribeInitialized = true;
|
|
124
|
-
} catch (error) {
|
|
125
|
-
throw error;
|
|
126
|
-
}
|
|
106
|
+
await this.cactus.streamTranscribeStart(options);
|
|
107
|
+
this.isStreamTranscribing = true;
|
|
127
108
|
}
|
|
128
|
-
async
|
|
109
|
+
async streamTranscribeProcess({
|
|
129
110
|
audio
|
|
130
111
|
}) {
|
|
131
|
-
if (!this.
|
|
132
|
-
throw new Error('CactusSTT stream transcribe is not
|
|
133
|
-
}
|
|
134
|
-
try {
|
|
135
|
-
await this.cactus.streamTranscribeInsert(audio);
|
|
136
|
-
} catch (error) {
|
|
137
|
-
throw error;
|
|
112
|
+
if (!this.isStreamTranscribing) {
|
|
113
|
+
throw new Error('CactusSTT stream transcribe is not started');
|
|
138
114
|
}
|
|
115
|
+
return this.cactus.streamTranscribeProcess(audio);
|
|
139
116
|
}
|
|
140
|
-
async
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (!this.isStreamTranscribeInitialized) {
|
|
144
|
-
throw new Error('CactusSTT stream transcribe is not initialized');
|
|
117
|
+
async streamTranscribeStop() {
|
|
118
|
+
if (!this.isStreamTranscribing) {
|
|
119
|
+
throw new Error('CactusSTT stream transcribe is not started');
|
|
145
120
|
}
|
|
146
121
|
try {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
throw error;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
async streamTranscribeFinalize() {
|
|
154
|
-
if (!this.isStreamTranscribeInitialized) {
|
|
155
|
-
throw new Error('CactusSTT stream transcribe is not initialized');
|
|
156
|
-
}
|
|
157
|
-
try {
|
|
158
|
-
const result = await this.cactus.streamTranscribeFinalize();
|
|
159
|
-
return result;
|
|
160
|
-
} catch (error) {
|
|
161
|
-
throw error;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
async streamTranscribeDestroy() {
|
|
165
|
-
if (!this.isStreamTranscribeInitialized) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
try {
|
|
169
|
-
await this.cactus.streamTranscribeDestroy();
|
|
170
|
-
this.isStreamTranscribeInitialized = false;
|
|
171
|
-
} catch (error) {
|
|
172
|
-
throw error;
|
|
122
|
+
return await this.cactus.streamTranscribeStop();
|
|
123
|
+
} finally {
|
|
124
|
+
this.isStreamTranscribing = false;
|
|
173
125
|
}
|
|
174
126
|
}
|
|
175
127
|
async audioEmbed({
|
|
@@ -182,13 +134,9 @@ export class CactusSTT {
|
|
|
182
134
|
this.isGenerating = true;
|
|
183
135
|
try {
|
|
184
136
|
const embedding = await this.cactus.audioEmbed(audioPath, CactusSTT.defaultEmbedBufferSize);
|
|
185
|
-
Telemetry.logAudioEmbedding(this.model, true);
|
|
186
137
|
return {
|
|
187
138
|
embedding
|
|
188
139
|
};
|
|
189
|
-
} catch (error) {
|
|
190
|
-
Telemetry.logAudioEmbedding(this.model, false, getErrorMessage(error));
|
|
191
|
-
throw error;
|
|
192
140
|
} finally {
|
|
193
141
|
this.isGenerating = false;
|
|
194
142
|
}
|
|
@@ -205,12 +153,15 @@ export class CactusSTT {
|
|
|
205
153
|
return;
|
|
206
154
|
}
|
|
207
155
|
await this.stop();
|
|
208
|
-
|
|
156
|
+
if (this.isStreamTranscribing) {
|
|
157
|
+
await this.cactus.streamTranscribeStop().catch(() => {});
|
|
158
|
+
this.isStreamTranscribing = false;
|
|
159
|
+
}
|
|
209
160
|
await this.cactus.destroy();
|
|
210
161
|
this.isInitialized = false;
|
|
211
162
|
}
|
|
212
|
-
getModels() {
|
|
213
|
-
return Object.values(
|
|
163
|
+
async getModels() {
|
|
164
|
+
return Object.values(await getRegistry());
|
|
214
165
|
}
|
|
215
166
|
isModelPath(model) {
|
|
216
167
|
return model.startsWith('file://') || model.startsWith('/');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Cactus","CactusFileSystem","
|
|
1
|
+
{"version":3,"names":["Cactus","CactusFileSystem","getRegistry","CactusSTT","cactus","isDownloading","isInitialized","isGenerating","isStreamTranscribing","defaultModel","defaultOptions","quantization","pro","defaultPrompt","defaultTranscribeOptions","maxTokens","defaultEmbedBufferSize","constructor","model","options","download","onProgress","isModelPath","Error","modelExists","getModelName","console","log","registry","modelConfig","url","apple","downloadModel","init","modelPath","replace","JSON","stringify","getModelPath","cacheDir","getCactusDirectory","setTelemetryEnvironment","transcribe","audio","prompt","onToken","responseBufferSize","streamTranscribeStart","streamTranscribeProcess","streamTranscribeStop","audioEmbed","audioPath","embedding","stop","reset","destroy","catch","getModels","Object","values","startsWith"],"sourceRoot":"../../../src","sources":["classes/CactusSTT.ts"],"mappings":";;AAAA,SAASA,MAAM,EAAEC,gBAAgB,QAAQ,oBAAW;AAapD,SAASC,WAAW,QAAQ,qBAAkB;AAG9C,OAAO,MAAMC,SAAS,CAAC;EACJC,MAAM,GAAG,IAAIJ,MAAM,CAAC,CAAC;EAQ9BK,aAAa,GAAG,KAAK;EACrBC,aAAa,GAAG,KAAK;EACrBC,YAAY,GAAG,KAAK;EACpBC,oBAAoB,GAAG,KAAK;EAEpC,OAAwBC,YAAY,GAAG,eAAe;EACtD,OAAwBC,cAAc,GAAG;IACvCC,YAAY,EAAE,MAAe;IAC7BC,GAAG,EAAE;EACP,CAAC;EACD,OAAwBC,aAAa,GACnC,2DAA2D;EAC7D,OAAwBC,wBAAwB,GAAG;I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