cactus-react-native 1.4.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 +465 -174
- 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 +157 -6
- package/cpp/HybridCactus.hpp +20 -3
- package/cpp/cactus_ffi.h +65 -30
- 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 +65 -30
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_utils.h +357 -122
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/engine.h +184 -63
- 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 +153 -27
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/kernel.h +90 -178
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/kernel_utils.h +276 -151
- 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 +65 -30
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_utils.h +357 -122
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/engine.h +184 -63
- 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 +153 -27
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/kernel.h +90 -178
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/kernel_utils.h +276 -151
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/cactus +0 -0
- package/lib/module/classes/CactusLM.js +43 -58
- package/lib/module/classes/CactusLM.js.map +1 -1
- package/lib/module/classes/CactusSTT.js +64 -38
- 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 +23 -15
- package/lib/module/hooks/useCactusLM.js.map +1 -1
- package/lib/module/hooks/useCactusSTT.js +85 -28
- 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 +107 -8
- 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/CactusLM.js +2 -0
- package/lib/module/types/CactusSTT.js +2 -0
- package/lib/module/types/CactusVAD.js +4 -0
- package/lib/module/types/{CactusModel.js.map → CactusVAD.js.map} +1 -1
- package/lib/module/types/common.js +2 -0
- package/lib/module/types/{CactusSTTModel.js.map → common.js.map} +1 -1
- package/lib/typescript/src/classes/CactusLM.d.ts +8 -6
- package/lib/typescript/src/classes/CactusLM.d.ts.map +1 -1
- package/lib/typescript/src/classes/CactusSTT.d.ts +11 -6
- 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 +3 -3
- package/lib/typescript/src/hooks/useCactusLM.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useCactusSTT.d.ts +11 -5
- 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 -6
- 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 -6
- 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 -1
- 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 -9
- package/lib/typescript/src/types/CactusLM.d.ts.map +1 -1
- package/lib/typescript/src/types/CactusSTT.d.ts +45 -4
- 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 +23 -0
- package/lib/typescript/src/types/common.d.ts.map +1 -0
- 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 -0
- package/nitrogen/generated/shared/c++/HybridCactusSpec.hpp +6 -1
- package/package.json +3 -3
- package/src/classes/CactusLM.ts +59 -74
- package/src/classes/CactusSTT.ts +92 -49
- package/src/classes/CactusVAD.ts +129 -0
- package/src/hooks/useCactusLM.ts +26 -9
- package/src/hooks/useCactusSTT.ts +105 -44
- package/src/hooks/useCactusVAD.ts +215 -0
- package/src/index.tsx +20 -10
- package/src/modelRegistry.ts +65 -0
- package/src/native/Cactus.ts +130 -14
- package/src/native/CactusIndex.ts +2 -2
- package/src/native/index.ts +0 -3
- package/src/specs/Cactus.nitro.ts +11 -2
- package/src/types/CactusIndex.ts +2 -2
- package/src/types/CactusLM.ts +20 -9
- package/src/types/CactusSTT.ts +50 -4
- package/src/types/CactusVAD.ts +39 -0
- package/src/types/common.ts +23 -0
- 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 -137
- 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/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/specs/CactusUtil.nitro.js.map +0 -1
- package/lib/module/telemetry/Telemetry.js +0 -154
- package/lib/module/telemetry/Telemetry.js.map +0 -1
- package/lib/module/types/CactusModel.js +0 -2
- package/lib/module/types/CactusSTTModel.js +0 -2
- package/lib/typescript/src/api/Database.d.ts +0 -18
- 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/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/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/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 -188
- package/src/api/RemoteLM.ts +0 -273
- package/src/config/CactusConfig.ts +0 -11
- 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
- package/src/types/CactusModel.ts +0 -15
- package/src/types/CactusSTTModel.ts +0 -10
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
#ifndef cactus_util_H
|
|
2
|
-
#define cactus_util_H
|
|
3
|
-
|
|
4
|
-
#ifdef __cplusplus
|
|
5
|
-
extern "C" {
|
|
6
|
-
#endif
|
|
7
|
-
|
|
8
|
-
const char* register_app(const char* encrypted_data);
|
|
9
|
-
|
|
10
|
-
const char* get_device_id(const char* current_token);
|
|
11
|
-
|
|
12
|
-
// Helper function to free memory allocated by register_app
|
|
13
|
-
void free_string(const char* str);
|
|
14
|
-
|
|
15
|
-
#ifdef __ANDROID__
|
|
16
|
-
// Function to set the Android app data directory
|
|
17
|
-
// This should be called from Flutter/Java side before any other functions
|
|
18
|
-
void set_android_data_directory(const char* data_dir);
|
|
19
|
-
#endif
|
|
20
|
-
|
|
21
|
-
#ifdef __cplusplus
|
|
22
|
-
}
|
|
23
|
-
#endif
|
|
24
|
-
|
|
25
|
-
#endif
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
#ifndef LOGGING_H
|
|
2
|
-
#define LOGGING_H
|
|
3
|
-
|
|
4
|
-
#include <string>
|
|
5
|
-
|
|
6
|
-
// Log levels
|
|
7
|
-
enum LogLevel {
|
|
8
|
-
LOG_DEBUG = 0,
|
|
9
|
-
LOG_INFO = 1,
|
|
10
|
-
LOG_WARNING = 2,
|
|
11
|
-
LOG_ERROR = 3
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
// Cross-platform logging function
|
|
15
|
-
void cactus_log(LogLevel level, const char* tag, const char* message);
|
|
16
|
-
void cactus_log(LogLevel level, const char* tag, const std::string& message);
|
|
17
|
-
|
|
18
|
-
// Convenience macros
|
|
19
|
-
#define LOG_TAG "CactusUtil"
|
|
20
|
-
#define CACTUS_LOG_DEBUG(msg) cactus_log(LOG_DEBUG, LOG_TAG, msg)
|
|
21
|
-
#define CACTUS_LOG_INFO(msg) cactus_log(LOG_INFO, LOG_TAG, msg)
|
|
22
|
-
#define CACTUS_LOG_WARNING(msg) cactus_log(LOG_WARNING, LOG_TAG, msg)
|
|
23
|
-
#define CACTUS_LOG_ERROR(msg) cactus_log(LOG_ERROR, LOG_TAG, msg)
|
|
24
|
-
|
|
25
|
-
#endif
|
|
Binary file
|
|
Binary file
|
package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/cactus_util.h
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
#ifndef cactus_util_H
|
|
2
|
-
#define cactus_util_H
|
|
3
|
-
|
|
4
|
-
#ifdef __cplusplus
|
|
5
|
-
extern "C" {
|
|
6
|
-
#endif
|
|
7
|
-
|
|
8
|
-
const char* register_app(const char* encrypted_data);
|
|
9
|
-
|
|
10
|
-
const char* get_device_id(const char* current_token);
|
|
11
|
-
|
|
12
|
-
// Helper function to free memory allocated by register_app
|
|
13
|
-
void free_string(const char* str);
|
|
14
|
-
|
|
15
|
-
#ifdef __ANDROID__
|
|
16
|
-
// Function to set the Android app data directory
|
|
17
|
-
// This should be called from Flutter/Java side before any other functions
|
|
18
|
-
void set_android_data_directory(const char* data_dir);
|
|
19
|
-
#endif
|
|
20
|
-
|
|
21
|
-
#ifdef __cplusplus
|
|
22
|
-
}
|
|
23
|
-
#endif
|
|
24
|
-
|
|
25
|
-
#endif
|
package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/database.h
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
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
|
package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/logging.h
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
#ifndef LOGGING_H
|
|
2
|
-
#define LOGGING_H
|
|
3
|
-
|
|
4
|
-
#include <string>
|
|
5
|
-
|
|
6
|
-
// Log levels
|
|
7
|
-
enum LogLevel {
|
|
8
|
-
LOG_DEBUG = 0,
|
|
9
|
-
LOG_INFO = 1,
|
|
10
|
-
LOG_WARNING = 2,
|
|
11
|
-
LOG_ERROR = 3
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
// Cross-platform logging function
|
|
15
|
-
void cactus_log(LogLevel level, const char* tag, const char* message);
|
|
16
|
-
void cactus_log(LogLevel level, const char* tag, const std::string& message);
|
|
17
|
-
|
|
18
|
-
// Convenience macros
|
|
19
|
-
#define LOG_TAG "CactusUtil"
|
|
20
|
-
#define CACTUS_LOG_DEBUG(msg) cactus_log(LOG_DEBUG, LOG_TAG, msg)
|
|
21
|
-
#define CACTUS_LOG_INFO(msg) cactus_log(LOG_INFO, LOG_TAG, msg)
|
|
22
|
-
#define CACTUS_LOG_WARNING(msg) cactus_log(LOG_WARNING, LOG_TAG, msg)
|
|
23
|
-
#define CACTUS_LOG_ERROR(msg) cactus_log(LOG_ERROR, LOG_TAG, msg)
|
|
24
|
-
|
|
25
|
-
#endif
|
|
Binary file
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
-
<plist version="1.0">
|
|
4
|
-
<dict>
|
|
5
|
-
<key>files</key>
|
|
6
|
-
<dict>
|
|
7
|
-
<key>Headers/cactus_util.h</key>
|
|
8
|
-
<data>
|
|
9
|
-
5lW8KZ3LQl0aqP6TUxyB+K0vcIE=
|
|
10
|
-
</data>
|
|
11
|
-
<key>Headers/ios_utils.h</key>
|
|
12
|
-
<data>
|
|
13
|
-
DxZ6AL6QIFsgYUKBGkaAndkY1Ew=
|
|
14
|
-
</data>
|
|
15
|
-
<key>Headers/logging.h</key>
|
|
16
|
-
<data>
|
|
17
|
-
m5MdwrQVZglUAv3NSffShqQTwqE=
|
|
18
|
-
</data>
|
|
19
|
-
<key>Info.plist</key>
|
|
20
|
-
<data>
|
|
21
|
-
gD92JC49Bf9W6pi0MZWov5LMRb4=
|
|
22
|
-
</data>
|
|
23
|
-
</dict>
|
|
24
|
-
<key>files2</key>
|
|
25
|
-
<dict>
|
|
26
|
-
<key>Headers/cactus_util.h</key>
|
|
27
|
-
<dict>
|
|
28
|
-
<key>hash2</key>
|
|
29
|
-
<data>
|
|
30
|
-
Q7DuJEU0UWHgQ8cVdAc50lq592AjV42gMHSiDHx4OQk=
|
|
31
|
-
</data>
|
|
32
|
-
</dict>
|
|
33
|
-
<key>Headers/ios_utils.h</key>
|
|
34
|
-
<dict>
|
|
35
|
-
<key>hash2</key>
|
|
36
|
-
<data>
|
|
37
|
-
edmm6ZYsnfjlwb1IJ40iJ7zwVnZZrO91p++TgoSO9ig=
|
|
38
|
-
</data>
|
|
39
|
-
</dict>
|
|
40
|
-
<key>Headers/logging.h</key>
|
|
41
|
-
<dict>
|
|
42
|
-
<key>hash2</key>
|
|
43
|
-
<data>
|
|
44
|
-
YpnrA639xaUs3HHamW6aBrNfc58sEqAIKKxdkgsn7Kk=
|
|
45
|
-
</data>
|
|
46
|
-
</dict>
|
|
47
|
-
</dict>
|
|
48
|
-
<key>rules</key>
|
|
49
|
-
<dict>
|
|
50
|
-
<key>^.*</key>
|
|
51
|
-
<true/>
|
|
52
|
-
<key>^.*\.lproj/</key>
|
|
53
|
-
<dict>
|
|
54
|
-
<key>optional</key>
|
|
55
|
-
<true/>
|
|
56
|
-
<key>weight</key>
|
|
57
|
-
<real>1000</real>
|
|
58
|
-
</dict>
|
|
59
|
-
<key>^.*\.lproj/locversion.plist$</key>
|
|
60
|
-
<dict>
|
|
61
|
-
<key>omit</key>
|
|
62
|
-
<true/>
|
|
63
|
-
<key>weight</key>
|
|
64
|
-
<real>1100</real>
|
|
65
|
-
</dict>
|
|
66
|
-
<key>^Base\.lproj/</key>
|
|
67
|
-
<dict>
|
|
68
|
-
<key>weight</key>
|
|
69
|
-
<real>1010</real>
|
|
70
|
-
</dict>
|
|
71
|
-
<key>^version.plist$</key>
|
|
72
|
-
<true/>
|
|
73
|
-
</dict>
|
|
74
|
-
<key>rules2</key>
|
|
75
|
-
<dict>
|
|
76
|
-
<key>.*\.dSYM($|/)</key>
|
|
77
|
-
<dict>
|
|
78
|
-
<key>weight</key>
|
|
79
|
-
<real>11</real>
|
|
80
|
-
</dict>
|
|
81
|
-
<key>^(.*/)?\.DS_Store$</key>
|
|
82
|
-
<dict>
|
|
83
|
-
<key>omit</key>
|
|
84
|
-
<true/>
|
|
85
|
-
<key>weight</key>
|
|
86
|
-
<real>2000</real>
|
|
87
|
-
</dict>
|
|
88
|
-
<key>^.*</key>
|
|
89
|
-
<true/>
|
|
90
|
-
<key>^.*\.lproj/</key>
|
|
91
|
-
<dict>
|
|
92
|
-
<key>optional</key>
|
|
93
|
-
<true/>
|
|
94
|
-
<key>weight</key>
|
|
95
|
-
<real>1000</real>
|
|
96
|
-
</dict>
|
|
97
|
-
<key>^.*\.lproj/locversion.plist$</key>
|
|
98
|
-
<dict>
|
|
99
|
-
<key>omit</key>
|
|
100
|
-
<true/>
|
|
101
|
-
<key>weight</key>
|
|
102
|
-
<real>1100</real>
|
|
103
|
-
</dict>
|
|
104
|
-
<key>^Base\.lproj/</key>
|
|
105
|
-
<dict>
|
|
106
|
-
<key>weight</key>
|
|
107
|
-
<real>1010</real>
|
|
108
|
-
</dict>
|
|
109
|
-
<key>^Info\.plist$</key>
|
|
110
|
-
<dict>
|
|
111
|
-
<key>omit</key>
|
|
112
|
-
<true/>
|
|
113
|
-
<key>weight</key>
|
|
114
|
-
<real>20</real>
|
|
115
|
-
</dict>
|
|
116
|
-
<key>^PkgInfo$</key>
|
|
117
|
-
<dict>
|
|
118
|
-
<key>omit</key>
|
|
119
|
-
<true/>
|
|
120
|
-
<key>weight</key>
|
|
121
|
-
<real>20</real>
|
|
122
|
-
</dict>
|
|
123
|
-
<key>^embedded\.provisionprofile$</key>
|
|
124
|
-
<dict>
|
|
125
|
-
<key>weight</key>
|
|
126
|
-
<real>20</real>
|
|
127
|
-
</dict>
|
|
128
|
-
<key>^version\.plist$</key>
|
|
129
|
-
<dict>
|
|
130
|
-
<key>weight</key>
|
|
131
|
-
<real>20</real>
|
|
132
|
-
</dict>
|
|
133
|
-
</dict>
|
|
134
|
-
</dict>
|
|
135
|
-
</plist>
|
|
Binary file
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { CactusUtil } from "../native/index.js";
|
|
4
|
-
import { packageVersion } from "../constants/packageVersion.js";
|
|
5
|
-
import { CactusConfig } from "../config/CactusConfig.js";
|
|
6
|
-
export class Database {
|
|
7
|
-
static url = 'https://vlqqczxwyaodtcdmdmlw.supabase.co';
|
|
8
|
-
static key = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InZscXFjenh3eWFvZHRjZG1kbWx3Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTE1MTg2MzIsImV4cCI6MjA2NzA5NDYzMn0.nBzqGuK9j6RZ6mOPWU2boAC_5H9XDs-fPpo5P3WZYbI';
|
|
9
|
-
static async sendLogRecords(records) {
|
|
10
|
-
const response = await fetch(`${this.url}/rest/v1/logs`, {
|
|
11
|
-
method: 'POST',
|
|
12
|
-
headers: {
|
|
13
|
-
'apikey': this.key,
|
|
14
|
-
'Authorization': `Bearer ${this.key}`,
|
|
15
|
-
'Content-Type': 'application/json',
|
|
16
|
-
'Content-Profile': 'cactus',
|
|
17
|
-
'Prefer': 'return=minimal'
|
|
18
|
-
},
|
|
19
|
-
body: JSON.stringify(records)
|
|
20
|
-
});
|
|
21
|
-
if (!response.ok) {
|
|
22
|
-
throw new Error('Sending logs failed');
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
static async registerDevice({
|
|
26
|
-
deviceData,
|
|
27
|
-
deviceId
|
|
28
|
-
}) {
|
|
29
|
-
const response = await fetch(`${this.url}/functions/v1/device-registration`, {
|
|
30
|
-
method: 'POST',
|
|
31
|
-
body: JSON.stringify({
|
|
32
|
-
device_data: deviceData,
|
|
33
|
-
device_id: deviceId,
|
|
34
|
-
cactus_pro_key: CactusConfig.cactusProKey
|
|
35
|
-
}),
|
|
36
|
-
headers: {
|
|
37
|
-
'Content-Type': 'application/json'
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
if (!response.ok) {
|
|
41
|
-
throw new Error('Registering device failed');
|
|
42
|
-
}
|
|
43
|
-
return await CactusUtil.registerApp(await response.text());
|
|
44
|
-
}
|
|
45
|
-
static async getModel(slug) {
|
|
46
|
-
const response = await fetch(`${this.url}/functions/v1/get-models?slug=${slug}&sdk_name=react&sdk_version=${packageVersion}`, {
|
|
47
|
-
headers: {
|
|
48
|
-
apikey: this.key,
|
|
49
|
-
Authorization: `Bearer ${this.key}`
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
if (!response.ok) {
|
|
53
|
-
throw new Error('Getting model failed');
|
|
54
|
-
}
|
|
55
|
-
const model = await response.json();
|
|
56
|
-
return {
|
|
57
|
-
name: model.name,
|
|
58
|
-
slug: model.slug,
|
|
59
|
-
quantization: model.quantization,
|
|
60
|
-
sizeMb: model.size_mb,
|
|
61
|
-
downloadUrl: model.download_url,
|
|
62
|
-
supportsToolCalling: model.supports_tool_calling,
|
|
63
|
-
supportsVision: model.supports_vision,
|
|
64
|
-
supportsCompletion: model.supports_completion,
|
|
65
|
-
createdAt: model.created_at,
|
|
66
|
-
isDownloaded: false
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
static async getSTTModel(slug) {
|
|
70
|
-
const response = await fetch(`${this.url}/rest/v1/whisper?slug=eq.${slug}&select=*`, {
|
|
71
|
-
headers: {
|
|
72
|
-
'apikey': this.key,
|
|
73
|
-
'Authorization': `Bearer ${this.key}`,
|
|
74
|
-
'Accept-Profile': 'cactus'
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
if (!response.ok) {
|
|
78
|
-
throw new Error('Getting STT model failed');
|
|
79
|
-
}
|
|
80
|
-
const [model] = await response.json();
|
|
81
|
-
if (!model) {
|
|
82
|
-
throw new Error(`STT model with slug "${slug}" not found`);
|
|
83
|
-
}
|
|
84
|
-
return {
|
|
85
|
-
slug: model.slug,
|
|
86
|
-
downloadUrl: model.download_url,
|
|
87
|
-
sizeMb: model.size_mb,
|
|
88
|
-
createdAt: model.created_at,
|
|
89
|
-
isDownloaded: false
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
static async getModels() {
|
|
93
|
-
const response = await fetch(`${this.url}/functions/v1/get-models?sdk_name=react&sdk_version=${packageVersion}`, {
|
|
94
|
-
headers: {
|
|
95
|
-
apikey: this.key,
|
|
96
|
-
Authorization: `Bearer ${this.key}`
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
if (!response.ok) {
|
|
100
|
-
throw new Error('Getting models failed');
|
|
101
|
-
}
|
|
102
|
-
const models = await response.json();
|
|
103
|
-
return models.map(model => ({
|
|
104
|
-
name: model.name,
|
|
105
|
-
slug: model.slug,
|
|
106
|
-
quantization: model.quantization,
|
|
107
|
-
sizeMb: model.size_mb,
|
|
108
|
-
downloadUrl: model.download_url,
|
|
109
|
-
supportsToolCalling: model.supports_tool_calling,
|
|
110
|
-
supportsVision: model.supports_vision,
|
|
111
|
-
supportsCompletion: model.supports_completion,
|
|
112
|
-
createdAt: model.created_at,
|
|
113
|
-
isDownloaded: false
|
|
114
|
-
}));
|
|
115
|
-
}
|
|
116
|
-
static async getSTTModels() {
|
|
117
|
-
const response = await fetch(`${this.url}/rest/v1/whisper?select=*`, {
|
|
118
|
-
headers: {
|
|
119
|
-
'apikey': this.key,
|
|
120
|
-
'Authorization': `Bearer ${this.key}`,
|
|
121
|
-
'Accept-Profile': 'cactus'
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
if (!response.ok) {
|
|
125
|
-
throw new Error('Getting STT models failed');
|
|
126
|
-
}
|
|
127
|
-
const models = await response.json();
|
|
128
|
-
return models.map(model => ({
|
|
129
|
-
slug: model.slug,
|
|
130
|
-
downloadUrl: model.download_url,
|
|
131
|
-
sizeMb: model.size_mb,
|
|
132
|
-
createdAt: model.created_at,
|
|
133
|
-
isDownloaded: false
|
|
134
|
-
}));
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
//# sourceMappingURL=Database.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["CactusUtil","packageVersion","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","getModel","slug","apikey","Authorization","model","json","name","quantization","sizeMb","size_mb","downloadUrl","download_url","supportsToolCalling","supports_tool_calling","supportsVision","supports_vision","supportsCompletion","supports_completion","createdAt","created_at","isDownloaded","getSTTModel","getModels","models","map","getSTTModels"],"sourceRoot":"../../../src","sources":["api/Database.ts"],"mappings":";;AAAA,SAASA,UAAU,QAAQ,oBAAW;AAGtC,SAASC,cAAc,QAAQ,gCAA6B;AAG5D,SAASC,YAAY,QAAQ,2BAAwB;AAqBrD,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;M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E;QACrC,gBAAgB,EAAE;MACpB;IACF,CAAC,CAAC;IAEF,IAAI,CAACG,QAAQ,CAACO,EAAE,EAAE;MAChB,MAAM,IAAIC,KAAK,CAAC,2BAA2B,CAAC;IAC9C;IAEA,MAAMiC,MAAM,GAAI,MAAMzC,QAAQ,CAACuB,IAAI,CAAC,CAA8B;IAElE,OAAOkB,MAAM,CAACC,GAAG,CAAEpB,KAAK,KAAM;MAC5BH,IAAI,EAAEG,KAAK,CAACH,IAAI;MAChBS,WAAW,EAAEN,KAAK,CAACO,YAAY;MAC/BH,MAAM,EAAEJ,KAAK,CAACK,OAAO;MACrBS,SAAS,EAAEd,KAAK,CAACe,UAAU;MAC3BC,YAAY,EAAE;IAChB,CAAC,CAAC,CAAC;EACL;AACF","ignoreList":[]}
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { CactusConfig } from "../config/CactusConfig.js";
|
|
4
|
-
import { CactusImage } from "../native/CactusImage.js";
|
|
5
|
-
export class RemoteLM {
|
|
6
|
-
static completionsUrl = 'https://openrouter.ai/api/v1/chat/completions';
|
|
7
|
-
static defaultModel = 'google/gemini-2.5-flash-lite';
|
|
8
|
-
static async complete(messages, options, tools, callback) {
|
|
9
|
-
if (!CactusConfig.cactusToken) {
|
|
10
|
-
throw new Error('cactusToken is required for hybrid completions');
|
|
11
|
-
}
|
|
12
|
-
const payload = JSON.stringify({
|
|
13
|
-
model: this.defaultModel,
|
|
14
|
-
messages: await this.transformMessages(messages),
|
|
15
|
-
tools,
|
|
16
|
-
temperature: options?.temperature,
|
|
17
|
-
top_p: options?.topP,
|
|
18
|
-
top_k: options?.topK,
|
|
19
|
-
max_tokens: options?.maxTokens,
|
|
20
|
-
stop: options?.stopSequences,
|
|
21
|
-
stream: !!callback
|
|
22
|
-
});
|
|
23
|
-
return callback ? await this.streamXHR(payload, callback) : await this.nonStreamFetch(payload);
|
|
24
|
-
}
|
|
25
|
-
static getMimeType(filePath) {
|
|
26
|
-
const extension = filePath.toLowerCase().split('.').pop();
|
|
27
|
-
switch (extension) {
|
|
28
|
-
case 'jpg':
|
|
29
|
-
case 'jpeg':
|
|
30
|
-
return 'image/jpeg';
|
|
31
|
-
case 'png':
|
|
32
|
-
return 'image/png';
|
|
33
|
-
case 'gif':
|
|
34
|
-
return 'image/gif';
|
|
35
|
-
case 'webp':
|
|
36
|
-
return 'image/webp';
|
|
37
|
-
default:
|
|
38
|
-
throw new Error(`Unsupported image format: .${extension}`);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
static async transformMessages(messages) {
|
|
42
|
-
const transformedMessages = [];
|
|
43
|
-
for (const message of messages) {
|
|
44
|
-
const content = [];
|
|
45
|
-
if (message.content) {
|
|
46
|
-
content.push({
|
|
47
|
-
type: 'text',
|
|
48
|
-
text: message.content
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
if (message.images) {
|
|
52
|
-
for (const image of message.images) {
|
|
53
|
-
const imagePath = image.replace('file://', '');
|
|
54
|
-
const mimeType = this.getMimeType(imagePath);
|
|
55
|
-
const base64Data = await CactusImage.base64(imagePath);
|
|
56
|
-
content.push({
|
|
57
|
-
type: 'image_url',
|
|
58
|
-
image_url: {
|
|
59
|
-
url: `data:${mimeType};base64,${base64Data}`
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
transformedMessages.push({
|
|
65
|
-
role: message.role,
|
|
66
|
-
content
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
return transformedMessages;
|
|
70
|
-
}
|
|
71
|
-
static streamXHR(payload, callback) {
|
|
72
|
-
return new Promise((resolve, reject) => {
|
|
73
|
-
const xhr = new XMLHttpRequest();
|
|
74
|
-
xhr.timeout = 3 * 60 * 1000; // 3 minutes
|
|
75
|
-
xhr.ontimeout = () => reject(new Error('Remote streaming completion timed out'));
|
|
76
|
-
xhr.open('POST', this.completionsUrl);
|
|
77
|
-
xhr.setRequestHeader('Authorization', `Bearer ${CactusConfig.cactusToken}`);
|
|
78
|
-
xhr.setRequestHeader('HTTP-Referer', 'https://cactuscompute.com');
|
|
79
|
-
xhr.setRequestHeader('X-Title', 'Cactus React Native SDK');
|
|
80
|
-
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
81
|
-
const startTime = performance.now();
|
|
82
|
-
let lastIndex = 0;
|
|
83
|
-
let buffer = '';
|
|
84
|
-
let response = '';
|
|
85
|
-
let toolCalls;
|
|
86
|
-
let timeToFirstTokenMs = 0;
|
|
87
|
-
let prefillTokens = 0;
|
|
88
|
-
let decodeTokens = 0;
|
|
89
|
-
let totalTokens = 0;
|
|
90
|
-
xhr.onprogress = () => {
|
|
91
|
-
const chunk = xhr.responseText.substring(lastIndex);
|
|
92
|
-
lastIndex = xhr.responseText.length;
|
|
93
|
-
buffer += chunk;
|
|
94
|
-
const lines = buffer.split('\n');
|
|
95
|
-
buffer = lines.pop() || '';
|
|
96
|
-
for (const line of lines) {
|
|
97
|
-
if (!line.startsWith('data: ')) {
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
const jsonStr = line.slice(6).trim();
|
|
101
|
-
if (jsonStr === '[DONE]') {
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
try {
|
|
105
|
-
const data = JSON.parse(jsonStr);
|
|
106
|
-
if (timeToFirstTokenMs === 0) {
|
|
107
|
-
timeToFirstTokenMs = performance.now() - startTime;
|
|
108
|
-
}
|
|
109
|
-
const toolCallChunks = data?.choices?.[0]?.delta?.tool_calls;
|
|
110
|
-
if (toolCallChunks) {
|
|
111
|
-
if (!toolCalls) {
|
|
112
|
-
toolCalls = [];
|
|
113
|
-
}
|
|
114
|
-
for (const toolCallChunk of toolCallChunks) {
|
|
115
|
-
const index = toolCallChunk.index;
|
|
116
|
-
if (!toolCalls[index]) {
|
|
117
|
-
toolCalls[index] = {
|
|
118
|
-
name: '',
|
|
119
|
-
arguments: ''
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
if (toolCallChunk.function?.name) {
|
|
123
|
-
toolCalls[index].name = toolCallChunk.function.name;
|
|
124
|
-
}
|
|
125
|
-
if (toolCallChunk.function?.arguments) {
|
|
126
|
-
toolCalls[index].arguments += toolCallChunk.function.arguments;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
const content = data?.choices?.[0]?.delta?.content;
|
|
131
|
-
if (content) {
|
|
132
|
-
response += content;
|
|
133
|
-
callback(content);
|
|
134
|
-
}
|
|
135
|
-
if (data?.usage) {
|
|
136
|
-
prefillTokens = data.usage.prompt_tokens;
|
|
137
|
-
decodeTokens = data.usage.completion_tokens;
|
|
138
|
-
totalTokens = data.usage.total_tokens;
|
|
139
|
-
}
|
|
140
|
-
} catch {}
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
xhr.onload = () => {
|
|
144
|
-
const totalTimeMs = performance.now() - startTime;
|
|
145
|
-
const functionCalls = toolCalls?.map(toolCall => ({
|
|
146
|
-
name: toolCall.name,
|
|
147
|
-
arguments: JSON.parse(toolCall.arguments)
|
|
148
|
-
}));
|
|
149
|
-
resolve({
|
|
150
|
-
success: true,
|
|
151
|
-
response,
|
|
152
|
-
functionCalls,
|
|
153
|
-
timeToFirstTokenMs,
|
|
154
|
-
totalTimeMs,
|
|
155
|
-
tokensPerSecond: decodeTokens * 1000 / totalTimeMs,
|
|
156
|
-
prefillTokens,
|
|
157
|
-
decodeTokens,
|
|
158
|
-
totalTokens
|
|
159
|
-
});
|
|
160
|
-
};
|
|
161
|
-
xhr.onerror = () => reject(new Error('Remote streaming completion failed'));
|
|
162
|
-
xhr.send(payload);
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
static async nonStreamFetch(payload) {
|
|
166
|
-
const startTime = performance.now();
|
|
167
|
-
const request = await fetch(this.completionsUrl, {
|
|
168
|
-
method: 'POST',
|
|
169
|
-
headers: {
|
|
170
|
-
'Authorization': `Bearer ${CactusConfig.cactusToken}`,
|
|
171
|
-
'HTTP-Referer': 'https://cactuscompute.com',
|
|
172
|
-
'X-Title': 'Cactus React Native SDK',
|
|
173
|
-
'Content-Type': 'application/json'
|
|
174
|
-
},
|
|
175
|
-
body: payload
|
|
176
|
-
});
|
|
177
|
-
if (!request.ok) {
|
|
178
|
-
throw new Error('Remote completion failed');
|
|
179
|
-
}
|
|
180
|
-
const data = await request.json();
|
|
181
|
-
const totalTimeMs = performance.now() - startTime;
|
|
182
|
-
const decodeTokens = data.usage.completion_tokens;
|
|
183
|
-
const toolCalls = data.choices[0].message.tool_calls;
|
|
184
|
-
const functionCalls = toolCalls?.map(toolCall => ({
|
|
185
|
-
name: toolCall.function.name,
|
|
186
|
-
arguments: toolCall.function.arguments
|
|
187
|
-
}));
|
|
188
|
-
return {
|
|
189
|
-
success: true,
|
|
190
|
-
response: data.choices[0].message.content,
|
|
191
|
-
functionCalls,
|
|
192
|
-
timeToFirstTokenMs: totalTimeMs,
|
|
193
|
-
totalTimeMs,
|
|
194
|
-
tokensPerSecond: decodeTokens * 1000 / totalTimeMs,
|
|
195
|
-
prefillTokens: data.usage.prompt_tokens,
|
|
196
|
-
decodeTokens,
|
|
197
|
-
totalTokens: data.usage.total_tokens
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
//# sourceMappingURL=RemoteLM.js.map
|