cactus-react-native 1.2.1 → 1.5.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/README.md +765 -33
- package/android/CMakeLists.txt +4 -3
- package/android/src/main/java/com/margelo/nitro/cactus/HybridCactusFileSystem.kt +20 -1
- package/android/src/main/jniLibs/arm64-v8a/libcactus.a +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libcactus_util.a +0 -0
- package/cpp/HybridCactus.cpp +231 -19
- package/cpp/HybridCactus.hpp +25 -3
- package/cpp/HybridCactusIndex.cpp +325 -0
- package/cpp/HybridCactusIndex.hpp +43 -0
- package/cpp/HybridCactusUtil.cpp +3 -3
- package/cpp/HybridCactusUtil.hpp +2 -1
- package/cpp/cactus_ffi.h +107 -2
- package/cpp/cactus_util.h +1 -1
- package/ios/HybridCactusFileSystem.swift +23 -2
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus.h +2 -0
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_ffi.h +107 -2
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_telemetry.h +656 -0
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/{ffi_utils.h → cactus_utils.h} +145 -18
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/engine.h +135 -7
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/gemma_tools.h +549 -0
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/graph.h +193 -26
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/kernel.h +54 -195
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/kernel_utils.h +399 -140
- 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 +2 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_ffi.h +107 -2
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_telemetry.h +656 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/{ffi_utils.h → cactus_utils.h} +145 -18
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/engine.h +135 -7
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/gemma_tools.h +549 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/graph.h +193 -26
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/kernel.h +54 -195
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/kernel_utils.h +399 -140
- 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/ios/cactus_util.xcframework/Info.plist +4 -4
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/cactus_util.h +1 -1
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/database.h +27 -0
- 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 +1 -1
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/database.h +27 -0
- 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 +3 -3
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/cactus_util +0 -0
- package/lib/module/api/Database.js +12 -95
- package/lib/module/api/Database.js.map +1 -1
- package/lib/module/classes/CactusIndex.js +45 -0
- package/lib/module/classes/CactusIndex.js.map +1 -0
- package/lib/module/classes/CactusLM.js +65 -17
- package/lib/module/classes/CactusLM.js.map +1 -1
- package/lib/module/classes/CactusSTT.js +104 -17
- package/lib/module/classes/CactusSTT.js.map +1 -1
- package/lib/module/config/CactusConfig.js +2 -0
- package/lib/module/config/CactusConfig.js.map +1 -1
- package/lib/module/constants/packageVersion.js +1 -1
- package/lib/module/hooks/useCactusIndex.js +175 -0
- package/lib/module/hooks/useCactusIndex.js.map +1 -0
- package/lib/module/hooks/useCactusLM.js +68 -7
- package/lib/module/hooks/useCactusLM.js.map +1 -1
- package/lib/module/hooks/useCactusSTT.js +102 -6
- package/lib/module/hooks/useCactusSTT.js.map +1 -1
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/models.js +336 -0
- package/lib/module/models.js.map +1 -0
- package/lib/module/native/Cactus.js +61 -13
- package/lib/module/native/Cactus.js.map +1 -1
- package/lib/module/native/CactusFileSystem.js +3 -0
- package/lib/module/native/CactusFileSystem.js.map +1 -1
- package/lib/module/native/CactusIndex.js +32 -0
- package/lib/module/native/CactusIndex.js.map +1 -0
- package/lib/module/native/CactusUtil.js +16 -3
- package/lib/module/native/CactusUtil.js.map +1 -1
- package/lib/module/native/index.js +1 -0
- package/lib/module/native/index.js.map +1 -1
- package/lib/module/specs/CactusIndex.nitro.js +4 -0
- package/lib/module/specs/CactusIndex.nitro.js.map +1 -0
- package/lib/module/telemetry/Telemetry.js +3 -1
- package/lib/module/telemetry/Telemetry.js.map +1 -1
- package/lib/module/types/CactusIndex.js +2 -0
- package/lib/module/types/{CactusModel.js.map → CactusIndex.js.map} +1 -1
- package/lib/module/types/CactusLM.js +2 -0
- package/lib/module/types/CactusSTT.js +2 -0
- package/lib/module/types/common.js +2 -0
- package/lib/module/types/{CactusSTTModel.js.map → common.js.map} +1 -1
- package/lib/typescript/src/api/Database.d.ts +4 -7
- package/lib/typescript/src/api/Database.d.ts.map +1 -1
- package/lib/typescript/src/classes/CactusIndex.d.ts +15 -0
- package/lib/typescript/src/classes/CactusIndex.d.ts.map +1 -0
- package/lib/typescript/src/classes/CactusLM.d.ts +12 -5
- package/lib/typescript/src/classes/CactusLM.d.ts.map +1 -1
- package/lib/typescript/src/classes/CactusSTT.d.ts +15 -5
- package/lib/typescript/src/classes/CactusSTT.d.ts.map +1 -1
- package/lib/typescript/src/config/CactusConfig.d.ts +1 -0
- package/lib/typescript/src/config/CactusConfig.d.ts.map +1 -1
- package/lib/typescript/src/constants/packageVersion.d.ts +1 -1
- package/lib/typescript/src/hooks/useCactusIndex.d.ts +14 -0
- package/lib/typescript/src/hooks/useCactusIndex.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useCactusLM.d.ts +6 -4
- package/lib/typescript/src/hooks/useCactusLM.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useCactusSTT.d.ts +13 -5
- package/lib/typescript/src/hooks/useCactusSTT.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +6 -4
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/models.d.ts +6 -0
- package/lib/typescript/src/models.d.ts.map +1 -0
- package/lib/typescript/src/native/Cactus.d.ts +10 -3
- package/lib/typescript/src/native/Cactus.d.ts.map +1 -1
- package/lib/typescript/src/native/CactusFileSystem.d.ts +1 -0
- package/lib/typescript/src/native/CactusFileSystem.d.ts.map +1 -1
- package/lib/typescript/src/native/CactusIndex.d.ts +12 -0
- package/lib/typescript/src/native/CactusIndex.d.ts.map +1 -0
- package/lib/typescript/src/native/CactusUtil.d.ts.map +1 -1
- package/lib/typescript/src/native/index.d.ts +1 -0
- package/lib/typescript/src/native/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/Cactus.nitro.d.ts +9 -2
- package/lib/typescript/src/specs/Cactus.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/CactusFileSystem.nitro.d.ts +1 -0
- package/lib/typescript/src/specs/CactusFileSystem.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/CactusIndex.nitro.d.ts +24 -0
- package/lib/typescript/src/specs/CactusIndex.nitro.d.ts.map +1 -0
- package/lib/typescript/src/specs/CactusUtil.nitro.d.ts +1 -1
- package/lib/typescript/src/specs/CactusUtil.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types/CactusIndex.d.ts +34 -0
- package/lib/typescript/src/types/CactusIndex.d.ts.map +1 -0
- package/lib/typescript/src/types/CactusLM.d.ts +19 -0
- package/lib/typescript/src/types/CactusLM.d.ts.map +1 -1
- package/lib/typescript/src/types/CactusSTT.d.ts +21 -1
- package/lib/typescript/src/types/CactusSTT.d.ts.map +1 -1
- package/lib/typescript/src/types/common.d.ts +28 -0
- package/lib/typescript/src/types/common.d.ts.map +1 -0
- package/nitro.json +3 -0
- package/nitrogen/generated/android/c++/JDeviceInfo.hpp +1 -1
- package/nitrogen/generated/android/c++/JFunc_void_double.hpp +1 -1
- package/nitrogen/generated/android/c++/JHybridCactusCryptoSpec.cpp +1 -1
- package/nitrogen/generated/android/c++/JHybridCactusCryptoSpec.hpp +1 -1
- package/nitrogen/generated/android/c++/JHybridCactusDeviceInfoSpec.cpp +1 -1
- package/nitrogen/generated/android/c++/JHybridCactusDeviceInfoSpec.hpp +1 -1
- package/nitrogen/generated/android/c++/JHybridCactusFileSystemSpec.cpp +17 -1
- package/nitrogen/generated/android/c++/JHybridCactusFileSystemSpec.hpp +2 -1
- package/nitrogen/generated/android/c++/JHybridCactusImageSpec.cpp +1 -1
- package/nitrogen/generated/android/c++/JHybridCactusImageSpec.hpp +1 -1
- package/nitrogen/generated/android/cactus+autolinking.cmake +2 -1
- package/nitrogen/generated/android/cactus+autolinking.gradle +1 -1
- package/nitrogen/generated/android/cactusOnLoad.cpp +11 -1
- package/nitrogen/generated/android/cactusOnLoad.hpp +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/DeviceInfo.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/Func_void_double.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/HybridCactusCryptoSpec.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/HybridCactusDeviceInfoSpec.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/HybridCactusFileSystemSpec.kt +5 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/HybridCactusImageSpec.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/cactusOnLoad.kt +1 -1
- package/nitrogen/generated/ios/Cactus+autolinking.rb +1 -1
- package/nitrogen/generated/ios/Cactus-Swift-Cxx-Bridge.cpp +1 -1
- package/nitrogen/generated/ios/Cactus-Swift-Cxx-Bridge.hpp +1 -1
- package/nitrogen/generated/ios/Cactus-Swift-Cxx-Umbrella.hpp +1 -1
- package/nitrogen/generated/ios/CactusAutolinking.mm +11 -1
- package/nitrogen/generated/ios/CactusAutolinking.swift +1 -1
- package/nitrogen/generated/ios/c++/HybridCactusCryptoSpecSwift.cpp +1 -1
- package/nitrogen/generated/ios/c++/HybridCactusCryptoSpecSwift.hpp +1 -1
- package/nitrogen/generated/ios/c++/HybridCactusDeviceInfoSpecSwift.cpp +1 -1
- package/nitrogen/generated/ios/c++/HybridCactusDeviceInfoSpecSwift.hpp +1 -1
- package/nitrogen/generated/ios/c++/HybridCactusFileSystemSpecSwift.cpp +1 -1
- package/nitrogen/generated/ios/c++/HybridCactusFileSystemSpecSwift.hpp +9 -1
- package/nitrogen/generated/ios/c++/HybridCactusImageSpecSwift.cpp +1 -1
- package/nitrogen/generated/ios/c++/HybridCactusImageSpecSwift.hpp +1 -1
- package/nitrogen/generated/ios/swift/DeviceInfo.swift +1 -1
- package/nitrogen/generated/ios/swift/Func_void.swift +1 -1
- package/nitrogen/generated/ios/swift/Func_void_DeviceInfo.swift +1 -1
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +1 -1
- package/nitrogen/generated/ios/swift/Func_void_double.swift +1 -1
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +1 -1
- package/nitrogen/generated/ios/swift/Func_void_std__optional_std__string_.swift +1 -1
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +1 -1
- package/nitrogen/generated/ios/swift/HybridCactusCryptoSpec.swift +1 -1
- package/nitrogen/generated/ios/swift/HybridCactusCryptoSpec_cxx.swift +1 -1
- package/nitrogen/generated/ios/swift/HybridCactusDeviceInfoSpec.swift +1 -1
- package/nitrogen/generated/ios/swift/HybridCactusDeviceInfoSpec_cxx.swift +1 -1
- package/nitrogen/generated/ios/swift/HybridCactusFileSystemSpec.swift +2 -1
- package/nitrogen/generated/ios/swift/HybridCactusFileSystemSpec_cxx.swift +20 -1
- package/nitrogen/generated/ios/swift/HybridCactusImageSpec.swift +1 -1
- package/nitrogen/generated/ios/swift/HybridCactusImageSpec_cxx.swift +1 -1
- package/nitrogen/generated/shared/c++/CactusIndexGetResult.hpp +84 -0
- package/nitrogen/generated/shared/c++/CactusIndexQueryResult.hpp +79 -0
- package/nitrogen/generated/shared/c++/DeviceInfo.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridCactusCryptoSpec.cpp +1 -1
- package/nitrogen/generated/shared/c++/HybridCactusCryptoSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridCactusDeviceInfoSpec.cpp +1 -1
- package/nitrogen/generated/shared/c++/HybridCactusDeviceInfoSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridCactusFileSystemSpec.cpp +2 -1
- package/nitrogen/generated/shared/c++/HybridCactusFileSystemSpec.hpp +2 -1
- package/nitrogen/generated/shared/c++/HybridCactusImageSpec.cpp +1 -1
- package/nitrogen/generated/shared/c++/HybridCactusImageSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridCactusIndexSpec.cpp +27 -0
- package/nitrogen/generated/shared/c++/HybridCactusIndexSpec.hpp +76 -0
- package/nitrogen/generated/shared/c++/HybridCactusSpec.cpp +8 -1
- package/nitrogen/generated/shared/c++/HybridCactusSpec.hpp +11 -3
- package/nitrogen/generated/shared/c++/HybridCactusUtilSpec.cpp +1 -1
- package/nitrogen/generated/shared/c++/HybridCactusUtilSpec.hpp +2 -2
- package/package.json +2 -2
- package/src/api/Database.ts +14 -135
- package/src/classes/CactusIndex.ts +58 -0
- package/src/classes/CactusLM.ts +87 -19
- package/src/classes/CactusSTT.ts +134 -20
- package/src/config/CactusConfig.ts +3 -0
- package/src/constants/packageVersion.ts +1 -1
- package/src/hooks/useCactusIndex.ts +195 -0
- package/src/hooks/useCactusLM.ts +88 -8
- package/src/hooks/useCactusSTT.ts +119 -7
- package/src/index.tsx +22 -2
- package/src/models.ts +344 -0
- package/src/native/Cactus.ts +95 -13
- package/src/native/CactusFileSystem.ts +4 -0
- package/src/native/CactusIndex.ts +54 -0
- package/src/native/CactusUtil.ts +19 -3
- package/src/native/index.ts +1 -0
- package/src/specs/Cactus.nitro.ts +18 -2
- package/src/specs/CactusFileSystem.nitro.ts +2 -0
- package/src/specs/CactusIndex.nitro.ts +31 -0
- package/src/specs/CactusUtil.nitro.ts +1 -1
- package/src/telemetry/Telemetry.ts +1 -1
- package/src/types/CactusIndex.ts +40 -0
- package/src/types/CactusLM.ts +24 -0
- package/src/types/CactusSTT.ts +27 -1
- package/src/types/common.ts +28 -0
- package/android/src/main/jniLibs/arm64-v8a/libcactus_util.so +0 -0
- package/lib/module/types/CactusModel.js +0 -2
- package/lib/module/types/CactusSTTModel.js +0 -2
- package/lib/typescript/src/types/CactusModel.d.ts +0 -13
- package/lib/typescript/src/types/CactusModel.d.ts.map +0 -1
- package/lib/typescript/src/types/CactusSTTModel.d.ts +0 -8
- package/lib/typescript/src/types/CactusSTTModel.d.ts.map +0 -1
- package/src/types/CactusModel.ts +0 -15
- package/src/types/CactusSTTModel.ts +0 -10
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<array>
|
|
7
7
|
<dict>
|
|
8
8
|
<key>LibraryIdentifier</key>
|
|
9
|
-
<string>ios-arm64
|
|
9
|
+
<string>ios-arm64</string>
|
|
10
10
|
<key>LibraryPath</key>
|
|
11
11
|
<string>cactus_util.framework</string>
|
|
12
12
|
<key>SupportedArchitectures</key>
|
|
@@ -15,12 +15,10 @@
|
|
|
15
15
|
</array>
|
|
16
16
|
<key>SupportedPlatform</key>
|
|
17
17
|
<string>ios</string>
|
|
18
|
-
<key>SupportedPlatformVariant</key>
|
|
19
|
-
<string>simulator</string>
|
|
20
18
|
</dict>
|
|
21
19
|
<dict>
|
|
22
20
|
<key>LibraryIdentifier</key>
|
|
23
|
-
<string>ios-arm64</string>
|
|
21
|
+
<string>ios-arm64-simulator</string>
|
|
24
22
|
<key>LibraryPath</key>
|
|
25
23
|
<string>cactus_util.framework</string>
|
|
26
24
|
<key>SupportedArchitectures</key>
|
|
@@ -29,6 +27,8 @@
|
|
|
29
27
|
</array>
|
|
30
28
|
<key>SupportedPlatform</key>
|
|
31
29
|
<string>ios</string>
|
|
30
|
+
<key>SupportedPlatformVariant</key>
|
|
31
|
+
<string>simulator</string>
|
|
32
32
|
</dict>
|
|
33
33
|
</array>
|
|
34
34
|
<key>CFBundlePackageType</key>
|
|
@@ -7,7 +7,7 @@ extern "C" {
|
|
|
7
7
|
|
|
8
8
|
const char* register_app(const char* encrypted_data);
|
|
9
9
|
|
|
10
|
-
const char* get_device_id();
|
|
10
|
+
const char* get_device_id(const char* current_token);
|
|
11
11
|
|
|
12
12
|
// Helper function to free memory allocated by register_app
|
|
13
13
|
void free_string(const char* str);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#ifndef DATABASE_H
|
|
2
|
+
#define DATABASE_H
|
|
3
|
+
|
|
4
|
+
#include <string>
|
|
5
|
+
struct sqlite3;
|
|
6
|
+
|
|
7
|
+
class Database {
|
|
8
|
+
private:
|
|
9
|
+
sqlite3* db;
|
|
10
|
+
std::string db_path;
|
|
11
|
+
|
|
12
|
+
bool create_tables();
|
|
13
|
+
|
|
14
|
+
public:
|
|
15
|
+
Database(const std::string& path = "cactus.db");
|
|
16
|
+
~Database();
|
|
17
|
+
|
|
18
|
+
bool initialize();
|
|
19
|
+
bool register_app(const std::string& device_id, const std::string& token_expiry_date, const std::string& token);
|
|
20
|
+
bool get_registration(std::string& device_id, std::string& token_expiry_date, std::string& token);
|
|
21
|
+
const char* get_device_id();
|
|
22
|
+
void close();
|
|
23
|
+
|
|
24
|
+
bool is_open() const;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
#endif // DATABASE_H
|
|
Binary file
|
|
Binary file
|
package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/cactus_util.h
CHANGED
|
@@ -7,7 +7,7 @@ extern "C" {
|
|
|
7
7
|
|
|
8
8
|
const char* register_app(const char* encrypted_data);
|
|
9
9
|
|
|
10
|
-
const char* get_device_id();
|
|
10
|
+
const char* get_device_id(const char* current_token);
|
|
11
11
|
|
|
12
12
|
// Helper function to free memory allocated by register_app
|
|
13
13
|
void free_string(const char* str);
|
package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/database.h
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#ifndef DATABASE_H
|
|
2
|
+
#define DATABASE_H
|
|
3
|
+
|
|
4
|
+
#include <string>
|
|
5
|
+
struct sqlite3;
|
|
6
|
+
|
|
7
|
+
class Database {
|
|
8
|
+
private:
|
|
9
|
+
sqlite3* db;
|
|
10
|
+
std::string db_path;
|
|
11
|
+
|
|
12
|
+
bool create_tables();
|
|
13
|
+
|
|
14
|
+
public:
|
|
15
|
+
Database(const std::string& path = "cactus.db");
|
|
16
|
+
~Database();
|
|
17
|
+
|
|
18
|
+
bool initialize();
|
|
19
|
+
bool register_app(const std::string& device_id, const std::string& token_expiry_date, const std::string& token);
|
|
20
|
+
bool get_registration(std::string& device_id, std::string& token_expiry_date, std::string& token);
|
|
21
|
+
const char* get_device_id();
|
|
22
|
+
void close();
|
|
23
|
+
|
|
24
|
+
bool is_open() const;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
#endif // DATABASE_H
|
|
Binary file
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<dict>
|
|
7
7
|
<key>Headers/cactus_util.h</key>
|
|
8
8
|
<data>
|
|
9
|
-
|
|
9
|
+
5lW8KZ3LQl0aqP6TUxyB+K0vcIE=
|
|
10
10
|
</data>
|
|
11
11
|
<key>Headers/ios_utils.h</key>
|
|
12
12
|
<data>
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
</data>
|
|
19
19
|
<key>Info.plist</key>
|
|
20
20
|
<data>
|
|
21
|
-
|
|
21
|
+
gD92JC49Bf9W6pi0MZWov5LMRb4=
|
|
22
22
|
</data>
|
|
23
23
|
</dict>
|
|
24
24
|
<key>files2</key>
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
<dict>
|
|
28
28
|
<key>hash2</key>
|
|
29
29
|
<data>
|
|
30
|
-
|
|
30
|
+
Q7DuJEU0UWHgQ8cVdAc50lq592AjV42gMHSiDHx4OQk=
|
|
31
31
|
</data>
|
|
32
32
|
</dict>
|
|
33
33
|
<key>Headers/ios_utils.h</key>
|
|
Binary file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { CactusUtil } from "../native/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { CactusConfig } from "../config/CactusConfig.js";
|
|
5
5
|
export class Database {
|
|
6
6
|
static url = 'https://vlqqczxwyaodtcdmdmlw.supabase.co';
|
|
7
7
|
static key = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InZscXFjenh3eWFvZHRjZG1kbWx3Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTE1MTg2MzIsImV4cCI6MjA2NzA5NDYzMn0.nBzqGuK9j6RZ6mOPWU2boAC_5H9XDs-fPpo5P3WZYbI';
|
|
@@ -21,108 +21,25 @@ export class Database {
|
|
|
21
21
|
throw new Error('Sending logs failed');
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
static async registerDevice(
|
|
24
|
+
static async registerDevice({
|
|
25
|
+
deviceData,
|
|
26
|
+
deviceId
|
|
27
|
+
}) {
|
|
25
28
|
const response = await fetch(`${this.url}/functions/v1/device-registration`, {
|
|
26
29
|
method: 'POST',
|
|
27
30
|
body: JSON.stringify({
|
|
28
|
-
device_data
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
throw new Error('Registering device failed');
|
|
33
|
-
}
|
|
34
|
-
return await CactusUtil.registerApp(await response.text());
|
|
35
|
-
}
|
|
36
|
-
static async getModel(slug) {
|
|
37
|
-
const response = await fetch(`${this.url}/functions/v1/get-models?slug=${slug}&sdk_name=react&sdk_version=${packageVersion}`, {
|
|
38
|
-
headers: {
|
|
39
|
-
apikey: this.key,
|
|
40
|
-
Authorization: `Bearer ${this.key}`
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
if (!response.ok) {
|
|
44
|
-
throw new Error('Getting model failed');
|
|
45
|
-
}
|
|
46
|
-
const model = await response.json();
|
|
47
|
-
return {
|
|
48
|
-
name: model.name,
|
|
49
|
-
slug: model.slug,
|
|
50
|
-
quantization: model.quantization,
|
|
51
|
-
sizeMb: model.size_mb,
|
|
52
|
-
downloadUrl: model.download_url,
|
|
53
|
-
supportsToolCalling: model.supports_tool_calling,
|
|
54
|
-
supportsVision: model.supports_vision,
|
|
55
|
-
supportsCompletion: model.supports_completion,
|
|
56
|
-
createdAt: model.created_at,
|
|
57
|
-
isDownloaded: false
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
static async getSTTModel(slug) {
|
|
61
|
-
const response = await fetch(`${this.url}/rest/v1/whisper?slug=eq.${slug}&select=*`, {
|
|
31
|
+
device_data: deviceData,
|
|
32
|
+
device_id: deviceId,
|
|
33
|
+
cactus_pro_key: CactusConfig.cactusProKey
|
|
34
|
+
}),
|
|
62
35
|
headers: {
|
|
63
|
-
'
|
|
64
|
-
'Authorization': `Bearer ${this.key}`,
|
|
65
|
-
'Accept-Profile': 'cactus'
|
|
36
|
+
'Content-Type': 'application/json'
|
|
66
37
|
}
|
|
67
38
|
});
|
|
68
39
|
if (!response.ok) {
|
|
69
|
-
throw new Error('
|
|
70
|
-
}
|
|
71
|
-
const [model] = await response.json();
|
|
72
|
-
if (!model) {
|
|
73
|
-
throw new Error(`STT model with slug "${slug}" not found`);
|
|
74
|
-
}
|
|
75
|
-
return {
|
|
76
|
-
slug: model.slug,
|
|
77
|
-
downloadUrl: model.download_url,
|
|
78
|
-
sizeMb: model.size_mb,
|
|
79
|
-
createdAt: model.created_at,
|
|
80
|
-
isDownloaded: false
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
static async getModels() {
|
|
84
|
-
const response = await fetch(`${this.url}/functions/v1/get-models?sdk_name=react&sdk_version=${packageVersion}`, {
|
|
85
|
-
headers: {
|
|
86
|
-
apikey: this.key,
|
|
87
|
-
Authorization: `Bearer ${this.key}`
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
if (!response.ok) {
|
|
91
|
-
throw new Error('Getting models failed');
|
|
92
|
-
}
|
|
93
|
-
const models = await response.json();
|
|
94
|
-
return models.map(model => ({
|
|
95
|
-
name: model.name,
|
|
96
|
-
slug: model.slug,
|
|
97
|
-
quantization: model.quantization,
|
|
98
|
-
sizeMb: model.size_mb,
|
|
99
|
-
downloadUrl: model.download_url,
|
|
100
|
-
supportsToolCalling: model.supports_tool_calling,
|
|
101
|
-
supportsVision: model.supports_vision,
|
|
102
|
-
supportsCompletion: model.supports_completion,
|
|
103
|
-
createdAt: model.created_at,
|
|
104
|
-
isDownloaded: false
|
|
105
|
-
}));
|
|
106
|
-
}
|
|
107
|
-
static async getSTTModels() {
|
|
108
|
-
const response = await fetch(`${this.url}/rest/v1/whisper?select=*`, {
|
|
109
|
-
headers: {
|
|
110
|
-
'apikey': this.key,
|
|
111
|
-
'Authorization': `Bearer ${this.key}`,
|
|
112
|
-
'Accept-Profile': 'cactus'
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
if (!response.ok) {
|
|
116
|
-
throw new Error('Getting STT models failed');
|
|
40
|
+
throw new Error('Registering device failed');
|
|
117
41
|
}
|
|
118
|
-
|
|
119
|
-
return models.map(model => ({
|
|
120
|
-
slug: model.slug,
|
|
121
|
-
downloadUrl: model.download_url,
|
|
122
|
-
sizeMb: model.size_mb,
|
|
123
|
-
createdAt: model.created_at,
|
|
124
|
-
isDownloaded: false
|
|
125
|
-
}));
|
|
42
|
+
return await CactusUtil.registerApp(await response.text());
|
|
126
43
|
}
|
|
127
44
|
}
|
|
128
45
|
//# sourceMappingURL=Database.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CactusUtil","
|
|
1
|
+
{"version":3,"names":["CactusUtil","CactusConfig","Database","url","key","sendLogRecords","records","response","fetch","method","headers","body","JSON","stringify","ok","Error","registerDevice","deviceData","deviceId","device_data","device_id","cactus_pro_key","cactusProKey","registerApp","text"],"sourceRoot":"../../../src","sources":["api/Database.ts"],"mappings":";;AAAA,SAASA,UAAU,QAAQ,oBAAW;AAGtC,SAASC,YAAY,QAAQ,2BAAwB;AAErD,OAAO,MAAMC,QAAQ,CAAC;EACpB,OAAwBC,GAAG,GAAG,0CAA0C;EACxE,OAAwBC,GAAG,GACzB,kNAAkN;EAEpN,aAAoBC,cAAcA,CAACC,OAAoB,EAAiB;IACtE,MAAMC,QAAQ,GAAG,MAAMC,KAAK,CAAC,GAAG,IAAI,CAACL,GAAG,eAAe,EAAE;MACvDM,MAAM,EAAE,MAAM;MACdC,OAAO,EAAE;QACP,QAAQ,EAAE,IAAI,CAACN,GAAG;QAClB,eAAe,EAAE,UAAU,IAAI,CAACA,GAAG,EAAE;QACrC,cAAc,EAAE,kBAAkB;QAClC,iBAAiB,EAAE,QAAQ;QAC3B,QAAQ,EAAE;MACZ,CAAC;MACDO,IAAI,EAAEC,IAAI,CAACC,SAAS,CAACP,OAAO;IAC9B,CAAC,CAAC;IAEF,IAAI,CAACC,QAAQ,CAACO,EAAE,EAAE;MAChB,MAAM,IAAIC,KAAK,CAAC,qBAAqB,CAAC;IACxC;EACF;EAEA,aAAoBC,cAAcA,CAAC;IACjCC,UAAU;IACVC;EAIF,CAAC,EAAmB;IAClB,MAAMX,QAAQ,GAAG,MAAMC,KAAK,CAC1B,GAAG,IAAI,CAACL,GAAG,mCAAmC,EAC9C;MACEM,MAAM,EAAE,MAAM;MACdE,IAAI,EAAEC,IAAI,CAACC,SAAS,CAAC;QACnBM,WAAW,EAAEF,UAAU;QACvBG,SAAS,EAAEF,QAAQ;QACnBG,cAAc,EAAEpB,YAAY,CAACqB;MAC/B,CAAC,CAAC;MACFZ,OAAO,EAAE;QAAE,cAAc,EAAE;MAAmB;IAChD,CACF,CAAC;IAED,IAAI,CAACH,QAAQ,CAACO,EAAE,EAAE;MAChB,MAAM,IAAIC,KAAK,CAAC,2BAA2B,CAAC;IAC9C;IAEA,OAAO,MAAMf,UAAU,CAACuB,WAAW,CAAC,MAAMhB,QAAQ,CAACiB,IAAI,CAAC,CAAC,CAAC;EAC5D;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { CactusIndex as NativeCactusIndex, CactusFileSystem } from "../native/index.js";
|
|
4
|
+
export class CactusIndex {
|
|
5
|
+
cactusIndex = new NativeCactusIndex();
|
|
6
|
+
constructor(name, embeddingDim) {
|
|
7
|
+
this.name = name;
|
|
8
|
+
this.embeddingDim = embeddingDim;
|
|
9
|
+
}
|
|
10
|
+
async init() {
|
|
11
|
+
const indexPath = await CactusFileSystem.getIndexPath(this.name);
|
|
12
|
+
return this.cactusIndex.init(indexPath, this.embeddingDim);
|
|
13
|
+
}
|
|
14
|
+
add({
|
|
15
|
+
ids,
|
|
16
|
+
documents,
|
|
17
|
+
embeddings,
|
|
18
|
+
metadatas
|
|
19
|
+
}) {
|
|
20
|
+
return this.cactusIndex.add(ids, documents, embeddings, metadatas);
|
|
21
|
+
}
|
|
22
|
+
delete({
|
|
23
|
+
ids
|
|
24
|
+
}) {
|
|
25
|
+
return this.cactusIndex.delete(ids);
|
|
26
|
+
}
|
|
27
|
+
get({
|
|
28
|
+
ids
|
|
29
|
+
}) {
|
|
30
|
+
return this.cactusIndex.get(ids);
|
|
31
|
+
}
|
|
32
|
+
query({
|
|
33
|
+
embeddings,
|
|
34
|
+
options
|
|
35
|
+
}) {
|
|
36
|
+
return this.cactusIndex.query(embeddings, options);
|
|
37
|
+
}
|
|
38
|
+
compact() {
|
|
39
|
+
return this.cactusIndex.compact();
|
|
40
|
+
}
|
|
41
|
+
destroy() {
|
|
42
|
+
return this.cactusIndex.destroy();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=CactusIndex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CactusIndex","NativeCactusIndex","CactusFileSystem","cactusIndex","constructor","name","embeddingDim","init","indexPath","getIndexPath","add","ids","documents","embeddings","metadatas","delete","get","query","options","compact","destroy"],"sourceRoot":"../../../src","sources":["classes/CactusIndex.ts"],"mappings":";;AAAA,SAASA,WAAW,IAAIC,iBAAiB,EAAEC,gBAAgB,QAAQ,oBAAW;AAU9E,OAAO,MAAMF,WAAW,CAAC;EACNG,WAAW,GAAG,IAAIF,iBAAiB,CAAC,CAAC;EAKtDG,WAAWA,CAACC,IAAY,EAAEC,YAAoB,EAAE;IAC9C,IAAI,CAACD,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,YAAY,GAAGA,YAAY;EAClC;EAEA,MAAaC,IAAIA,CAAA,EAAkB;IACjC,MAAMC,SAAS,GAAG,MAAMN,gBAAgB,CAACO,YAAY,CAAC,IAAI,CAACJ,IAAI,CAAC;IAChE,OAAO,IAAI,CAACF,WAAW,CAACI,IAAI,CAACC,SAAS,EAAE,IAAI,CAACF,YAAY,CAAC;EAC5D;EAEOI,GAAGA,CAAC;IACTC,GAAG;IACHC,SAAS;IACTC,UAAU;IACVC;EACoB,CAAC,EAAiB;IACtC,OAAO,IAAI,CAACX,WAAW,CAACO,GAAG,CAACC,GAAG,EAAEC,SAAS,EAAEC,UAAU,EAAEC,SAAS,CAAC;EACpE;EAEOC,MAAMA,CAAC;IAAEJ;EAA6B,CAAC,EAAiB;IAC7D,OAAO,IAAI,CAACR,WAAW,CAACY,MAAM,CAACJ,GAAG,CAAC;EACrC;EAEOK,GAAGA,CAAC;IAAEL;EAA0B,CAAC,EAAiC;IACvE,OAAO,IAAI,CAACR,WAAW,CAACa,GAAG,CAACL,GAAG,CAAC;EAClC;EAEOM,KAAKA,CAAC;IACXJ,UAAU;IACVK;EACsB,CAAC,EAAmC;IAC1D,OAAO,IAAI,CAACf,WAAW,CAACc,KAAK,CAACJ,UAAU,EAAEK,OAAO,CAAC;EACpD;EAEOC,OAAOA,CAAA,EAAkB;IAC9B,OAAO,IAAI,CAAChB,WAAW,CAACgB,OAAO,CAAC,CAAC;EACnC;EAEOC,OAAOA,CAAA,EAAkB;IAC9B,OAAO,IAAI,CAACjB,WAAW,CAACiB,OAAO,CAAC,CAAC;EACnC;AACF","ignoreList":[]}
|
|
@@ -3,16 +3,24 @@
|
|
|
3
3
|
import { Cactus, CactusFileSystem } from "../native/index.js";
|
|
4
4
|
import { Telemetry } from "../telemetry/Telemetry.js";
|
|
5
5
|
import { CactusConfig } from "../config/CactusConfig.js";
|
|
6
|
-
import { Database } from "../api/Database.js";
|
|
7
6
|
import { getErrorMessage } from "../utils/error.js";
|
|
8
7
|
import { RemoteLM } from "../api/RemoteLM.js";
|
|
8
|
+
import models from "../models.js";
|
|
9
9
|
export class CactusLM {
|
|
10
10
|
cactus = new Cactus();
|
|
11
11
|
isDownloading = false;
|
|
12
12
|
isInitialized = false;
|
|
13
13
|
isGenerating = false;
|
|
14
|
-
static defaultModel = 'qwen3-0.
|
|
14
|
+
static defaultModel = 'qwen3-0.6b';
|
|
15
15
|
static defaultContextSize = 2048;
|
|
16
|
+
static defaultOptions = {
|
|
17
|
+
quantization: 'int4',
|
|
18
|
+
pro: false
|
|
19
|
+
};
|
|
20
|
+
static quantizationExceptions = {
|
|
21
|
+
'gemma-3-270m-it': 'int8',
|
|
22
|
+
'functiongemma-270m-it': 'int8'
|
|
23
|
+
};
|
|
16
24
|
static defaultCompleteOptions = {
|
|
17
25
|
maxTokens: 512
|
|
18
26
|
};
|
|
@@ -21,27 +29,41 @@ export class CactusLM {
|
|
|
21
29
|
constructor({
|
|
22
30
|
model,
|
|
23
31
|
contextSize,
|
|
24
|
-
corpusDir
|
|
32
|
+
corpusDir,
|
|
33
|
+
options
|
|
25
34
|
} = {}) {
|
|
26
35
|
Telemetry.init(CactusConfig.telemetryToken);
|
|
27
36
|
this.model = model ?? CactusLM.defaultModel;
|
|
28
37
|
this.contextSize = contextSize ?? CactusLM.defaultContextSize;
|
|
29
38
|
this.corpusDir = corpusDir;
|
|
39
|
+
this.options = {
|
|
40
|
+
quantization: options?.quantization ?? CactusLM.quantizationExceptions[this.model] ?? CactusLM.defaultOptions.quantization,
|
|
41
|
+
pro: options?.pro ?? CactusLM.defaultOptions.pro
|
|
42
|
+
};
|
|
30
43
|
}
|
|
31
44
|
async download({
|
|
32
45
|
onProgress
|
|
33
46
|
} = {}) {
|
|
47
|
+
if (this.isModelPath(this.model)) {
|
|
48
|
+
onProgress?.(1.0);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
34
51
|
if (this.isDownloading) {
|
|
35
52
|
throw new Error('CactusLM is already downloading');
|
|
36
53
|
}
|
|
37
|
-
if (await CactusFileSystem.modelExists(this.
|
|
54
|
+
if (await CactusFileSystem.modelExists(this.getModelName())) {
|
|
55
|
+
console.log('Model already exists', this.getModelName());
|
|
38
56
|
onProgress?.(1.0);
|
|
39
57
|
return;
|
|
40
58
|
}
|
|
41
59
|
this.isDownloading = true;
|
|
42
60
|
try {
|
|
43
|
-
const
|
|
44
|
-
|
|
61
|
+
const modelConfig = models[this.model]?.quantization[this.options.quantization];
|
|
62
|
+
const url = this.options.pro ? modelConfig?.pro?.apple : modelConfig?.url;
|
|
63
|
+
if (!url) {
|
|
64
|
+
throw new Error(`Model ${this.model} with specified options not found`);
|
|
65
|
+
}
|
|
66
|
+
await CactusFileSystem.downloadModel(this.getModelName(), url, onProgress);
|
|
45
67
|
} finally {
|
|
46
68
|
this.isDownloading = false;
|
|
47
69
|
}
|
|
@@ -50,10 +72,16 @@ export class CactusLM {
|
|
|
50
72
|
if (this.isInitialized) {
|
|
51
73
|
return;
|
|
52
74
|
}
|
|
53
|
-
|
|
54
|
-
|
|
75
|
+
let modelPath;
|
|
76
|
+
if (this.isModelPath(this.model)) {
|
|
77
|
+
modelPath = this.model.replace('file://', '');
|
|
78
|
+
} else {
|
|
79
|
+
if (!(await CactusFileSystem.modelExists(this.getModelName()))) {
|
|
80
|
+
console.log('Model not found:', this.getModelName());
|
|
81
|
+
throw new Error(`Model "${this.model}" with options ${JSON.stringify(this.options)} is not downloaded`);
|
|
82
|
+
}
|
|
83
|
+
modelPath = await CactusFileSystem.getModelPath(this.getModelName());
|
|
55
84
|
}
|
|
56
|
-
const modelPath = await CactusFileSystem.getModelPath(this.model);
|
|
57
85
|
try {
|
|
58
86
|
await this.cactus.init(modelPath, this.contextSize, this.corpusDir);
|
|
59
87
|
Telemetry.logInit(this.model, true);
|
|
@@ -104,8 +132,26 @@ export class CactusLM {
|
|
|
104
132
|
this.isGenerating = false;
|
|
105
133
|
}
|
|
106
134
|
}
|
|
107
|
-
async
|
|
135
|
+
async tokenize({
|
|
108
136
|
text
|
|
137
|
+
}) {
|
|
138
|
+
return {
|
|
139
|
+
tokens: await this.cactus.tokenize(text)
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
async scoreWindow({
|
|
143
|
+
tokens,
|
|
144
|
+
start,
|
|
145
|
+
end,
|
|
146
|
+
context
|
|
147
|
+
}) {
|
|
148
|
+
return {
|
|
149
|
+
score: await this.cactus.scoreWindow(tokens, start, end, context)
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
async embed({
|
|
153
|
+
text,
|
|
154
|
+
normalize = false
|
|
109
155
|
}) {
|
|
110
156
|
if (this.isGenerating) {
|
|
111
157
|
throw new Error('CactusLM is already generating');
|
|
@@ -113,7 +159,7 @@ export class CactusLM {
|
|
|
113
159
|
await this.init();
|
|
114
160
|
this.isGenerating = true;
|
|
115
161
|
try {
|
|
116
|
-
const embedding = await this.cactus.embed(text, CactusLM.defaultEmbedBufferSize);
|
|
162
|
+
const embedding = await this.cactus.embed(text, CactusLM.defaultEmbedBufferSize, normalize);
|
|
117
163
|
Telemetry.logEmbedding(this.model, true);
|
|
118
164
|
return {
|
|
119
165
|
embedding
|
|
@@ -161,12 +207,14 @@ export class CactusLM {
|
|
|
161
207
|
await this.cactus.destroy();
|
|
162
208
|
this.isInitialized = false;
|
|
163
209
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
210
|
+
getModels() {
|
|
211
|
+
return Object.values(models).filter(model => model.completion);
|
|
212
|
+
}
|
|
213
|
+
isModelPath(model) {
|
|
214
|
+
return model.startsWith('file://') || model.startsWith('/');
|
|
215
|
+
}
|
|
216
|
+
getModelName() {
|
|
217
|
+
return `${this.model}-${this.options.quantization}${this.options.pro ? '-pro' : ''}`;
|
|
170
218
|
}
|
|
171
219
|
}
|
|
172
220
|
//# sourceMappingURL=CactusLM.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Cactus","CactusFileSystem","Telemetry","CactusConfig","
|
|
1
|
+
{"version":3,"names":["Cactus","CactusFileSystem","Telemetry","CactusConfig","getErrorMessage","RemoteLM","models","CactusLM","cactus","isDownloading","isInitialized","isGenerating","defaultModel","defaultContextSize","defaultOptions","quantization","pro","quantizationExceptions","defaultCompleteOptions","maxTokens","defaultCompleteMode","defaultEmbedBufferSize","constructor","model","contextSize","corpusDir","options","init","telemetryToken","download","onProgress","isModelPath","Error","modelExists","getModelName","console","log","modelConfig","url","apple","downloadModel","modelPath","replace","JSON","stringify","getModelPath","logInit","error","complete","messages","tools","onToken","mode","toolsInternal","map","tool","type","function","responseBufferSize","result","logCompletion","success","undefined","response","localError","remoteError","tokenize","text","tokens","scoreWindow","start","end","context","score","embed","normalize","embedding","logEmbedding","imageEmbed","imagePath","logImageEmbedding","stop","reset","destroy","getModels","Object","values","filter","completion","startsWith"],"sourceRoot":"../../../src","sources":["classes/CactusLM.ts"],"mappings":";;AAAA,SAASA,MAAM,EAAEC,gBAAgB,QAAQ,oBAAW;AAepD,SAASC,SAAS,QAAQ,2BAAwB;AAClD,SAASC,YAAY,QAAQ,2BAAwB;AACrD,SAASC,eAAe,QAAQ,mBAAgB;AAChD,SAASC,QAAQ,QAAQ,oBAAiB;AAC1C,OAAOC,MAAM,MAAM,cAAW;AAG9B,OAAO,MAAMC,QAAQ,CAAC;EACHC,MAAM,GAAG,IAAIR,MAAM,CAAC,CAAC;EAU9BS,aAAa,GAAG,KAAK;EACrBC,aAAa,GAAG,KAAK;EACrBC,YAAY,GAAG,KAAK;EAE5B,OAAwBC,YAAY,GAAG,YAAY;EACnD,OAAwBC,kBAAkB,GAAG,IAAI;EACjD,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,mBAAmB,GAAG,OAAO;EACrD,OAAwBC,sBAAsB,GAAG,IAAI;EAErDC,WAAWA,CAAC;IAAEC,KAAK;IAAEC,WAAW;IAAEC,SAAS;IA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