cactus-react-native 1.5.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cactus.podspec +1 -1
- package/README.md +347 -241
- package/android/CMakeLists.txt +24 -5
- package/android/src/main/jniLibs/arm64-v8a/libcactus.a +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libcurl.a +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libmbedcrypto.a +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libmbedtls.a +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libmbedx509.a +0 -0
- package/cpp/HybridCactus.cpp +197 -117
- package/cpp/HybridCactus.hpp +18 -9
- package/cpp/cactus_ffi.h +66 -42
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus.h +0 -1
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_cloud.h +48 -0
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_ffi.h +66 -42
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_utils.h +568 -135
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/engine.h +148 -17
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/graph.h +145 -36
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/kernel.h +187 -6
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/kernel_utils.h +49 -149
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Info.plist +0 -0
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/cactus +0 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus.h +0 -1
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_cloud.h +48 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_ffi.h +66 -42
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_utils.h +568 -135
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/engine.h +148 -17
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/graph.h +145 -36
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/kernel.h +187 -6
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/kernel_utils.h +49 -149
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Info.plist +0 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/_CodeSignature/CodeResources +1 -1
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/cactus +0 -0
- package/lib/module/classes/CactusLM.js +16 -49
- package/lib/module/classes/CactusLM.js.map +1 -1
- package/lib/module/classes/CactusSTT.js +41 -75
- package/lib/module/classes/CactusSTT.js.map +1 -1
- package/lib/module/classes/CactusVAD.js +95 -0
- package/lib/module/classes/CactusVAD.js.map +1 -0
- package/lib/module/hooks/useCactusLM.js +10 -11
- package/lib/module/hooks/useCactusLM.js.map +1 -1
- package/lib/module/hooks/useCactusSTT.js +23 -62
- package/lib/module/hooks/useCactusSTT.js.map +1 -1
- package/lib/module/hooks/useCactusVAD.js +171 -0
- package/lib/module/hooks/useCactusVAD.js.map +1 -0
- package/lib/module/index.js +2 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/modelRegistry.js +52 -0
- package/lib/module/modelRegistry.js.map +1 -0
- package/lib/module/native/Cactus.js +103 -23
- package/lib/module/native/Cactus.js.map +1 -1
- package/lib/module/native/CactusIndex.js.map +1 -1
- package/lib/module/native/index.js +0 -3
- package/lib/module/native/index.js.map +1 -1
- package/lib/module/types/CactusVAD.js +4 -0
- package/lib/module/{specs/CactusUtil.nitro.js.map → types/CactusVAD.js.map} +1 -1
- package/lib/typescript/src/classes/CactusLM.d.ts +5 -7
- package/lib/typescript/src/classes/CactusLM.d.ts.map +1 -1
- package/lib/typescript/src/classes/CactusSTT.d.ts +9 -12
- package/lib/typescript/src/classes/CactusSTT.d.ts.map +1 -1
- package/lib/typescript/src/classes/CactusVAD.d.ts +20 -0
- package/lib/typescript/src/classes/CactusVAD.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useCactusLM.d.ts +2 -2
- package/lib/typescript/src/hooks/useCactusLM.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useCactusSTT.d.ts +6 -8
- package/lib/typescript/src/hooks/useCactusSTT.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useCactusVAD.d.ts +15 -0
- package/lib/typescript/src/hooks/useCactusVAD.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +7 -5
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/modelRegistry.d.ts +5 -0
- package/lib/typescript/src/modelRegistry.d.ts.map +1 -0
- package/lib/typescript/src/native/Cactus.d.ts +13 -11
- package/lib/typescript/src/native/Cactus.d.ts.map +1 -1
- package/lib/typescript/src/native/CactusIndex.d.ts +2 -2
- package/lib/typescript/src/native/CactusIndex.d.ts.map +1 -1
- package/lib/typescript/src/native/index.d.ts +0 -3
- package/lib/typescript/src/native/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/Cactus.nitro.d.ts +7 -6
- package/lib/typescript/src/specs/Cactus.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types/CactusIndex.d.ts +2 -2
- package/lib/typescript/src/types/CactusIndex.d.ts.map +1 -1
- package/lib/typescript/src/types/CactusLM.d.ts +19 -11
- package/lib/typescript/src/types/CactusLM.d.ts.map +1 -1
- package/lib/typescript/src/types/CactusSTT.d.ts +44 -12
- package/lib/typescript/src/types/CactusSTT.d.ts.map +1 -1
- package/lib/typescript/src/types/CactusVAD.d.ts +34 -0
- package/lib/typescript/src/types/CactusVAD.d.ts.map +1 -0
- package/lib/typescript/src/types/common.d.ts +1 -6
- package/lib/typescript/src/types/common.d.ts.map +1 -1
- package/nitro.json +0 -11
- package/nitrogen/generated/android/cactus+autolinking.cmake +0 -5
- package/nitrogen/generated/android/cactusOnLoad.cpp +0 -30
- package/nitrogen/generated/ios/Cactus-Swift-Cxx-Bridge.cpp +0 -50
- package/nitrogen/generated/ios/Cactus-Swift-Cxx-Bridge.hpp +9 -147
- package/nitrogen/generated/ios/Cactus-Swift-Cxx-Umbrella.hpp +0 -13
- package/nitrogen/generated/ios/CactusAutolinking.mm +0 -26
- package/nitrogen/generated/ios/CactusAutolinking.swift +0 -30
- package/nitrogen/generated/shared/c++/HybridCactusSpec.cpp +5 -4
- package/nitrogen/generated/shared/c++/HybridCactusSpec.hpp +7 -6
- package/package.json +3 -3
- package/src/classes/CactusLM.ts +18 -65
- package/src/classes/CactusSTT.ts +52 -90
- package/src/classes/CactusVAD.ts +129 -0
- package/src/hooks/useCactusLM.ts +14 -17
- package/src/hooks/useCactusSTT.ts +47 -98
- package/src/hooks/useCactusVAD.ts +215 -0
- package/src/index.tsx +21 -12
- package/src/modelRegistry.ts +65 -0
- package/src/native/Cactus.ts +131 -38
- package/src/native/CactusIndex.ts +2 -2
- package/src/native/index.ts +0 -3
- package/src/specs/Cactus.nitro.ts +16 -7
- package/src/types/CactusIndex.ts +2 -2
- package/src/types/CactusLM.ts +19 -11
- package/src/types/CactusSTT.ts +47 -13
- package/src/types/CactusVAD.ts +39 -0
- package/src/types/common.ts +1 -6
- package/android/src/main/java/com/margelo/nitro/cactus/HybridCactusCrypto.kt +0 -46
- package/android/src/main/java/com/margelo/nitro/cactus/HybridCactusDeviceInfo.kt +0 -27
- package/android/src/main/jniLibs/arm64-v8a/libcactus_util.a +0 -0
- package/cpp/HybridCactusUtil.cpp +0 -47
- package/cpp/HybridCactusUtil.hpp +0 -27
- package/cpp/cactus_util.h +0 -25
- package/ios/HybridCactusCrypto.swift +0 -37
- package/ios/HybridCactusDeviceInfo.swift +0 -32
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_telemetry.h +0 -656
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_telemetry.h +0 -656
- package/ios/cactus_util.xcframework/Info.plist +0 -39
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/cactus_util.h +0 -25
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/database.h +0 -27
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/ios_utils.h +0 -10
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/logging.h +0 -25
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Info.plist +0 -0
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/cactus_util +0 -0
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/cactus_util.h +0 -25
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/database.h +0 -27
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/ios_utils.h +0 -10
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/logging.h +0 -25
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Info.plist +0 -0
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/_CodeSignature/CodeResources +0 -135
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/cactus_util +0 -0
- package/lib/module/api/Database.js +0 -45
- package/lib/module/api/Database.js.map +0 -1
- package/lib/module/api/RemoteLM.js +0 -201
- package/lib/module/api/RemoteLM.js.map +0 -1
- package/lib/module/config/CactusConfig.js +0 -12
- package/lib/module/config/CactusConfig.js.map +0 -1
- package/lib/module/models.js +0 -336
- package/lib/module/models.js.map +0 -1
- package/lib/module/native/CactusCrypto.js +0 -10
- package/lib/module/native/CactusCrypto.js.map +0 -1
- package/lib/module/native/CactusDeviceInfo.js +0 -13
- package/lib/module/native/CactusDeviceInfo.js.map +0 -1
- package/lib/module/native/CactusUtil.js +0 -36
- package/lib/module/native/CactusUtil.js.map +0 -1
- package/lib/module/specs/CactusCrypto.nitro.js +0 -4
- package/lib/module/specs/CactusCrypto.nitro.js.map +0 -1
- package/lib/module/specs/CactusDeviceInfo.nitro.js +0 -4
- package/lib/module/specs/CactusDeviceInfo.nitro.js.map +0 -1
- package/lib/module/specs/CactusUtil.nitro.js +0 -4
- package/lib/module/telemetry/Telemetry.js +0 -154
- package/lib/module/telemetry/Telemetry.js.map +0 -1
- package/lib/typescript/src/api/Database.d.ts +0 -12
- package/lib/typescript/src/api/Database.d.ts.map +0 -1
- package/lib/typescript/src/api/RemoteLM.d.ts +0 -14
- package/lib/typescript/src/api/RemoteLM.d.ts.map +0 -1
- package/lib/typescript/src/config/CactusConfig.d.ts +0 -7
- package/lib/typescript/src/config/CactusConfig.d.ts.map +0 -1
- package/lib/typescript/src/models.d.ts +0 -6
- package/lib/typescript/src/models.d.ts.map +0 -1
- package/lib/typescript/src/native/CactusCrypto.d.ts +0 -5
- package/lib/typescript/src/native/CactusCrypto.d.ts.map +0 -1
- package/lib/typescript/src/native/CactusDeviceInfo.d.ts +0 -7
- package/lib/typescript/src/native/CactusDeviceInfo.d.ts.map +0 -1
- package/lib/typescript/src/native/CactusUtil.d.ts +0 -6
- package/lib/typescript/src/native/CactusUtil.d.ts.map +0 -1
- package/lib/typescript/src/specs/CactusCrypto.nitro.d.ts +0 -8
- package/lib/typescript/src/specs/CactusCrypto.nitro.d.ts.map +0 -1
- package/lib/typescript/src/specs/CactusDeviceInfo.nitro.d.ts +0 -16
- package/lib/typescript/src/specs/CactusDeviceInfo.nitro.d.ts.map +0 -1
- package/lib/typescript/src/specs/CactusUtil.nitro.d.ts +0 -10
- package/lib/typescript/src/specs/CactusUtil.nitro.d.ts.map +0 -1
- package/lib/typescript/src/telemetry/Telemetry.d.ts +0 -34
- package/lib/typescript/src/telemetry/Telemetry.d.ts.map +0 -1
- package/nitrogen/generated/android/c++/JDeviceInfo.hpp +0 -74
- package/nitrogen/generated/android/c++/JHybridCactusCryptoSpec.cpp +0 -65
- package/nitrogen/generated/android/c++/JHybridCactusCryptoSpec.hpp +0 -65
- package/nitrogen/generated/android/c++/JHybridCactusDeviceInfoSpec.cpp +0 -85
- package/nitrogen/generated/android/c++/JHybridCactusDeviceInfoSpec.hpp +0 -66
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/DeviceInfo.kt +0 -50
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/HybridCactusCryptoSpec.kt +0 -58
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/HybridCactusDeviceInfoSpec.kt +0 -62
- package/nitrogen/generated/ios/c++/HybridCactusCryptoSpecSwift.cpp +0 -11
- package/nitrogen/generated/ios/c++/HybridCactusCryptoSpecSwift.hpp +0 -77
- package/nitrogen/generated/ios/c++/HybridCactusDeviceInfoSpecSwift.cpp +0 -11
- package/nitrogen/generated/ios/c++/HybridCactusDeviceInfoSpecSwift.hpp +0 -88
- package/nitrogen/generated/ios/swift/DeviceInfo.swift +0 -98
- package/nitrogen/generated/ios/swift/Func_void_DeviceInfo.swift +0 -47
- package/nitrogen/generated/ios/swift/Func_void_std__optional_std__string_.swift +0 -54
- package/nitrogen/generated/ios/swift/HybridCactusCryptoSpec.swift +0 -57
- package/nitrogen/generated/ios/swift/HybridCactusCryptoSpec_cxx.swift +0 -139
- package/nitrogen/generated/ios/swift/HybridCactusDeviceInfoSpec.swift +0 -58
- package/nitrogen/generated/ios/swift/HybridCactusDeviceInfoSpec_cxx.swift +0 -164
- package/nitrogen/generated/shared/c++/DeviceInfo.hpp +0 -92
- package/nitrogen/generated/shared/c++/HybridCactusCryptoSpec.cpp +0 -21
- package/nitrogen/generated/shared/c++/HybridCactusCryptoSpec.hpp +0 -63
- package/nitrogen/generated/shared/c++/HybridCactusDeviceInfoSpec.cpp +0 -22
- package/nitrogen/generated/shared/c++/HybridCactusDeviceInfoSpec.hpp +0 -67
- package/nitrogen/generated/shared/c++/HybridCactusUtilSpec.cpp +0 -23
- package/nitrogen/generated/shared/c++/HybridCactusUtilSpec.hpp +0 -66
- package/src/api/Database.ts +0 -55
- package/src/api/RemoteLM.ts +0 -273
- package/src/config/CactusConfig.ts +0 -11
- package/src/models.ts +0 -344
- package/src/native/CactusCrypto.ts +0 -11
- package/src/native/CactusDeviceInfo.ts +0 -18
- package/src/native/CactusUtil.ts +0 -43
- package/src/specs/CactusCrypto.nitro.ts +0 -6
- package/src/specs/CactusDeviceInfo.nitro.ts +0 -15
- package/src/specs/CactusUtil.nitro.ts +0 -8
- package/src/telemetry/Telemetry.ts +0 -236
package/src/api/RemoteLM.ts
DELETED
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
import { CactusConfig } from '../config/CactusConfig';
|
|
2
|
-
import { CactusImage } from '../native/CactusImage';
|
|
3
|
-
import type {
|
|
4
|
-
CactusLMCompleteResult,
|
|
5
|
-
Message,
|
|
6
|
-
CompleteOptions,
|
|
7
|
-
Tool,
|
|
8
|
-
} from '../types/CactusLM';
|
|
9
|
-
|
|
10
|
-
export class RemoteLM {
|
|
11
|
-
private static readonly completionsUrl =
|
|
12
|
-
'https://openrouter.ai/api/v1/chat/completions';
|
|
13
|
-
|
|
14
|
-
private static readonly defaultModel = 'google/gemini-2.5-flash-lite';
|
|
15
|
-
|
|
16
|
-
public static async complete(
|
|
17
|
-
messages: Message[],
|
|
18
|
-
options?: CompleteOptions,
|
|
19
|
-
tools?: { type: 'function'; function: Tool }[],
|
|
20
|
-
callback?: (token: string) => void
|
|
21
|
-
): Promise<CactusLMCompleteResult> {
|
|
22
|
-
if (!CactusConfig.cactusToken) {
|
|
23
|
-
throw new Error('cactusToken is required for hybrid completions');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const payload = JSON.stringify({
|
|
27
|
-
model: this.defaultModel,
|
|
28
|
-
messages: await this.transformMessages(messages),
|
|
29
|
-
tools,
|
|
30
|
-
temperature: options?.temperature,
|
|
31
|
-
top_p: options?.topP,
|
|
32
|
-
top_k: options?.topK,
|
|
33
|
-
max_tokens: options?.maxTokens,
|
|
34
|
-
stop: options?.stopSequences,
|
|
35
|
-
stream: !!callback,
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
return callback
|
|
39
|
-
? await this.streamXHR(payload, callback)
|
|
40
|
-
: await this.nonStreamFetch(payload);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
private static getMimeType(filePath: string): string {
|
|
44
|
-
const extension = filePath.toLowerCase().split('.').pop();
|
|
45
|
-
switch (extension) {
|
|
46
|
-
case 'jpg':
|
|
47
|
-
case 'jpeg':
|
|
48
|
-
return 'image/jpeg';
|
|
49
|
-
case 'png':
|
|
50
|
-
return 'image/png';
|
|
51
|
-
case 'gif':
|
|
52
|
-
return 'image/gif';
|
|
53
|
-
case 'webp':
|
|
54
|
-
return 'image/webp';
|
|
55
|
-
default:
|
|
56
|
-
throw new Error(`Unsupported image format: .${extension}`);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
private static async transformMessages(messages: Message[]) {
|
|
61
|
-
const transformedMessages = [];
|
|
62
|
-
|
|
63
|
-
for (const message of messages) {
|
|
64
|
-
const content: {
|
|
65
|
-
type: string;
|
|
66
|
-
text?: string;
|
|
67
|
-
image_url?: { url: string };
|
|
68
|
-
}[] = [];
|
|
69
|
-
|
|
70
|
-
if (message.content) {
|
|
71
|
-
content.push({
|
|
72
|
-
type: 'text',
|
|
73
|
-
text: message.content,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (message.images) {
|
|
78
|
-
for (const image of message.images) {
|
|
79
|
-
const imagePath = image.replace('file://', '');
|
|
80
|
-
const mimeType = this.getMimeType(imagePath);
|
|
81
|
-
const base64Data = await CactusImage.base64(imagePath);
|
|
82
|
-
|
|
83
|
-
content.push({
|
|
84
|
-
type: 'image_url',
|
|
85
|
-
image_url: {
|
|
86
|
-
url: `data:${mimeType};base64,${base64Data}`,
|
|
87
|
-
},
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
transformedMessages.push({ role: message.role, content });
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return transformedMessages;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
private static streamXHR(
|
|
99
|
-
payload: string,
|
|
100
|
-
callback: (token: string) => void
|
|
101
|
-
): Promise<CactusLMCompleteResult> {
|
|
102
|
-
return new Promise((resolve, reject) => {
|
|
103
|
-
const xhr = new XMLHttpRequest();
|
|
104
|
-
|
|
105
|
-
xhr.timeout = 3 * 60 * 1000; // 3 minutes
|
|
106
|
-
xhr.ontimeout = () =>
|
|
107
|
-
reject(new Error('Remote streaming completion timed out'));
|
|
108
|
-
|
|
109
|
-
xhr.open('POST', this.completionsUrl);
|
|
110
|
-
xhr.setRequestHeader(
|
|
111
|
-
'Authorization',
|
|
112
|
-
`Bearer ${CactusConfig.cactusToken}`
|
|
113
|
-
);
|
|
114
|
-
xhr.setRequestHeader('HTTP-Referer', 'https://cactuscompute.com');
|
|
115
|
-
xhr.setRequestHeader('X-Title', 'Cactus React Native SDK');
|
|
116
|
-
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
117
|
-
|
|
118
|
-
const startTime = performance.now();
|
|
119
|
-
let lastIndex = 0;
|
|
120
|
-
let buffer = '';
|
|
121
|
-
let response = '';
|
|
122
|
-
let toolCalls: { name: string; arguments: string }[] | undefined;
|
|
123
|
-
let timeToFirstTokenMs = 0;
|
|
124
|
-
let prefillTokens = 0;
|
|
125
|
-
let decodeTokens = 0;
|
|
126
|
-
let totalTokens = 0;
|
|
127
|
-
|
|
128
|
-
xhr.onprogress = () => {
|
|
129
|
-
const chunk = xhr.responseText.substring(lastIndex);
|
|
130
|
-
lastIndex = xhr.responseText.length;
|
|
131
|
-
|
|
132
|
-
buffer += chunk;
|
|
133
|
-
|
|
134
|
-
const lines = buffer.split('\n');
|
|
135
|
-
buffer = lines.pop() || '';
|
|
136
|
-
|
|
137
|
-
for (const line of lines) {
|
|
138
|
-
if (!line.startsWith('data: ')) {
|
|
139
|
-
continue;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const jsonStr = line.slice(6).trim();
|
|
143
|
-
if (jsonStr === '[DONE]') {
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
try {
|
|
148
|
-
const data = JSON.parse(jsonStr);
|
|
149
|
-
|
|
150
|
-
if (timeToFirstTokenMs === 0) {
|
|
151
|
-
timeToFirstTokenMs = performance.now() - startTime;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
const toolCallChunks = data?.choices?.[0]?.delta?.tool_calls;
|
|
155
|
-
if (toolCallChunks) {
|
|
156
|
-
if (!toolCalls) {
|
|
157
|
-
toolCalls = [];
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
for (const toolCallChunk of toolCallChunks) {
|
|
161
|
-
const index = toolCallChunk.index;
|
|
162
|
-
|
|
163
|
-
if (!toolCalls[index]) {
|
|
164
|
-
toolCalls[index] = { name: '', arguments: '' };
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if (toolCallChunk.function?.name) {
|
|
168
|
-
toolCalls[index].name = toolCallChunk.function.name;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (toolCallChunk.function?.arguments) {
|
|
172
|
-
toolCalls[index].arguments +=
|
|
173
|
-
toolCallChunk.function.arguments;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
const content = data?.choices?.[0]?.delta?.content;
|
|
179
|
-
if (content) {
|
|
180
|
-
response += content;
|
|
181
|
-
callback(content);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (data?.usage) {
|
|
185
|
-
prefillTokens = data.usage.prompt_tokens;
|
|
186
|
-
decodeTokens = data.usage.completion_tokens;
|
|
187
|
-
totalTokens = data.usage.total_tokens;
|
|
188
|
-
}
|
|
189
|
-
} catch {}
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
xhr.onload = () => {
|
|
194
|
-
const totalTimeMs = performance.now() - startTime;
|
|
195
|
-
const functionCalls = toolCalls?.map((toolCall) => ({
|
|
196
|
-
name: toolCall.name,
|
|
197
|
-
arguments: JSON.parse(toolCall.arguments) as { [key: string]: any },
|
|
198
|
-
}));
|
|
199
|
-
|
|
200
|
-
resolve({
|
|
201
|
-
success: true,
|
|
202
|
-
response,
|
|
203
|
-
functionCalls,
|
|
204
|
-
timeToFirstTokenMs,
|
|
205
|
-
totalTimeMs,
|
|
206
|
-
tokensPerSecond: (decodeTokens * 1000) / totalTimeMs,
|
|
207
|
-
prefillTokens,
|
|
208
|
-
decodeTokens,
|
|
209
|
-
totalTokens,
|
|
210
|
-
});
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
xhr.onerror = () =>
|
|
214
|
-
reject(new Error('Remote streaming completion failed'));
|
|
215
|
-
|
|
216
|
-
xhr.send(payload);
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
private static async nonStreamFetch(
|
|
221
|
-
payload: string
|
|
222
|
-
): Promise<CactusLMCompleteResult> {
|
|
223
|
-
const startTime = performance.now();
|
|
224
|
-
|
|
225
|
-
const request = await fetch(this.completionsUrl, {
|
|
226
|
-
method: 'POST',
|
|
227
|
-
headers: {
|
|
228
|
-
'Authorization': `Bearer ${CactusConfig.cactusToken}`,
|
|
229
|
-
'HTTP-Referer': 'https://cactuscompute.com',
|
|
230
|
-
'X-Title': 'Cactus React Native SDK',
|
|
231
|
-
'Content-Type': 'application/json',
|
|
232
|
-
},
|
|
233
|
-
body: payload,
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
if (!request.ok) {
|
|
237
|
-
throw new Error('Remote completion failed');
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
const data = await request.json();
|
|
241
|
-
|
|
242
|
-
const totalTimeMs = performance.now() - startTime;
|
|
243
|
-
const decodeTokens = data.usage.completion_tokens;
|
|
244
|
-
|
|
245
|
-
const toolCalls:
|
|
246
|
-
| {
|
|
247
|
-
function: {
|
|
248
|
-
name: string;
|
|
249
|
-
arguments: {
|
|
250
|
-
[key: string]: any;
|
|
251
|
-
};
|
|
252
|
-
};
|
|
253
|
-
}[]
|
|
254
|
-
| undefined = data.choices[0].message.tool_calls;
|
|
255
|
-
|
|
256
|
-
const functionCalls = toolCalls?.map((toolCall) => ({
|
|
257
|
-
name: toolCall.function.name,
|
|
258
|
-
arguments: toolCall.function.arguments,
|
|
259
|
-
}));
|
|
260
|
-
|
|
261
|
-
return {
|
|
262
|
-
success: true,
|
|
263
|
-
response: data.choices[0].message.content,
|
|
264
|
-
functionCalls,
|
|
265
|
-
timeToFirstTokenMs: totalTimeMs,
|
|
266
|
-
totalTimeMs,
|
|
267
|
-
tokensPerSecond: (decodeTokens * 1000) / totalTimeMs,
|
|
268
|
-
prefillTokens: data.usage.prompt_tokens,
|
|
269
|
-
decodeTokens,
|
|
270
|
-
totalTokens: data.usage.total_tokens,
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
}
|
package/src/models.ts
DELETED
|
@@ -1,344 +0,0 @@
|
|
|
1
|
-
import type { CactusModel } from './types/common';
|
|
2
|
-
|
|
3
|
-
const models: { [key: string]: CactusModel } = {
|
|
4
|
-
'gemma-3-270m-it': {
|
|
5
|
-
completion: true,
|
|
6
|
-
tools: false,
|
|
7
|
-
vision: false,
|
|
8
|
-
embed: true,
|
|
9
|
-
speech: false,
|
|
10
|
-
quantization: {
|
|
11
|
-
int4: {
|
|
12
|
-
sizeMb: 115,
|
|
13
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int4/gemma-3-270m-it.zip',
|
|
14
|
-
},
|
|
15
|
-
int8: {
|
|
16
|
-
sizeMb: 172,
|
|
17
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int8/gemma-3-270m-it.zip',
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
'functiongemma-270m-it': {
|
|
22
|
-
completion: true,
|
|
23
|
-
tools: true,
|
|
24
|
-
vision: false,
|
|
25
|
-
embed: true,
|
|
26
|
-
speech: false,
|
|
27
|
-
quantization: {
|
|
28
|
-
int4: {
|
|
29
|
-
sizeMb: 115,
|
|
30
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int4/functiongemma-270m-it.zip',
|
|
31
|
-
},
|
|
32
|
-
int8: {
|
|
33
|
-
sizeMb: 172,
|
|
34
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int8/functiongemma-270m-it.zip',
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
'whisper-small': {
|
|
39
|
-
completion: false,
|
|
40
|
-
tools: false,
|
|
41
|
-
vision: false,
|
|
42
|
-
embed: true,
|
|
43
|
-
speech: true,
|
|
44
|
-
quantization: {
|
|
45
|
-
int4: {
|
|
46
|
-
sizeMb: 104,
|
|
47
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int4/whisper-small.zip',
|
|
48
|
-
pro: {
|
|
49
|
-
apple:
|
|
50
|
-
'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int4/pro/apple/whisper-small.zip',
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
int8: {
|
|
54
|
-
sizeMb: 282,
|
|
55
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int8/whisper-small.zip',
|
|
56
|
-
pro: {
|
|
57
|
-
apple:
|
|
58
|
-
'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int8/pro/apple/whisper-small.zip',
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
'lfm2-350m': {
|
|
64
|
-
completion: true,
|
|
65
|
-
tools: true,
|
|
66
|
-
vision: false,
|
|
67
|
-
embed: true,
|
|
68
|
-
speech: false,
|
|
69
|
-
quantization: {
|
|
70
|
-
int4: {
|
|
71
|
-
sizeMb: 153,
|
|
72
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int4/lfm2-350m.zip',
|
|
73
|
-
},
|
|
74
|
-
int8: {
|
|
75
|
-
sizeMb: 233,
|
|
76
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int8/lfm2-350m.zip',
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
'smollm2-360m-instruct': {
|
|
81
|
-
completion: true,
|
|
82
|
-
tools: false,
|
|
83
|
-
vision: false,
|
|
84
|
-
embed: true,
|
|
85
|
-
speech: false,
|
|
86
|
-
quantization: {
|
|
87
|
-
int4: {
|
|
88
|
-
sizeMb: 140,
|
|
89
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int4/smollm2-360m-instruct.zip',
|
|
90
|
-
},
|
|
91
|
-
int8: {
|
|
92
|
-
sizeMb: 227,
|
|
93
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int8/smollm2-360m-instruct.zip',
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
'lfm2-vl-450m': {
|
|
98
|
-
completion: true,
|
|
99
|
-
tools: false,
|
|
100
|
-
vision: true,
|
|
101
|
-
embed: true,
|
|
102
|
-
speech: false,
|
|
103
|
-
quantization: {
|
|
104
|
-
int4: {
|
|
105
|
-
sizeMb: 318,
|
|
106
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int4/lfm2-vl-450m.zip',
|
|
107
|
-
pro: {
|
|
108
|
-
apple:
|
|
109
|
-
'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int4/pro/apple/lfm2-vl-450m.zip',
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
int8: {
|
|
113
|
-
sizeMb: 480,
|
|
114
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int8/lfm2-vl-450m.zip',
|
|
115
|
-
pro: {
|
|
116
|
-
apple:
|
|
117
|
-
'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int8/pro/apple/lfm2-vl-450m.zip',
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
'nomic-embed-text-v2-moe': {
|
|
123
|
-
completion: false,
|
|
124
|
-
tools: false,
|
|
125
|
-
vision: false,
|
|
126
|
-
embed: true,
|
|
127
|
-
speech: false,
|
|
128
|
-
quantization: {
|
|
129
|
-
int4: {
|
|
130
|
-
sizeMb: 211,
|
|
131
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int4/nomic-embed-text-v2-moe.zip',
|
|
132
|
-
},
|
|
133
|
-
int8: {
|
|
134
|
-
sizeMb: 456,
|
|
135
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int8/nomic-embed-text-v2-moe.zip',
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
'qwen3-0.6b': {
|
|
140
|
-
completion: true,
|
|
141
|
-
tools: true,
|
|
142
|
-
vision: false,
|
|
143
|
-
embed: true,
|
|
144
|
-
speech: false,
|
|
145
|
-
quantization: {
|
|
146
|
-
int4: {
|
|
147
|
-
sizeMb: 234,
|
|
148
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int4/qwen3-0.6b.zip',
|
|
149
|
-
},
|
|
150
|
-
int8: {
|
|
151
|
-
sizeMb: 394,
|
|
152
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int8/qwen3-0.6b.zip',
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
'qwen3-embedding-0.6b': {
|
|
157
|
-
completion: false,
|
|
158
|
-
tools: false,
|
|
159
|
-
vision: false,
|
|
160
|
-
embed: true,
|
|
161
|
-
speech: false,
|
|
162
|
-
quantization: {
|
|
163
|
-
int4: {
|
|
164
|
-
sizeMb: 234,
|
|
165
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int4/qwen3-embedding-0.6b.zip',
|
|
166
|
-
},
|
|
167
|
-
int8: {
|
|
168
|
-
sizeMb: 394,
|
|
169
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int8/qwen3-embedding-0.6b.zip',
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
},
|
|
173
|
-
'lfm2-700m': {
|
|
174
|
-
completion: true,
|
|
175
|
-
tools: true,
|
|
176
|
-
vision: false,
|
|
177
|
-
embed: true,
|
|
178
|
-
speech: false,
|
|
179
|
-
quantization: {
|
|
180
|
-
int4: {
|
|
181
|
-
sizeMb: 300,
|
|
182
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int4/lfm2-700m.zip',
|
|
183
|
-
},
|
|
184
|
-
int8: {
|
|
185
|
-
sizeMb: 467,
|
|
186
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int8/lfm2-700m.zip',
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
'gemma-3-1b-it': {
|
|
191
|
-
completion: true,
|
|
192
|
-
tools: false,
|
|
193
|
-
vision: false,
|
|
194
|
-
embed: false,
|
|
195
|
-
speech: false,
|
|
196
|
-
quantization: {
|
|
197
|
-
int4: {
|
|
198
|
-
sizeMb: 320,
|
|
199
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int4/gemma-3-1b-it.zip',
|
|
200
|
-
},
|
|
201
|
-
int8: {
|
|
202
|
-
sizeMb: 642,
|
|
203
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int8/gemma-3-1b-it.zip',
|
|
204
|
-
},
|
|
205
|
-
},
|
|
206
|
-
},
|
|
207
|
-
'whisper-medium': {
|
|
208
|
-
completion: false,
|
|
209
|
-
tools: false,
|
|
210
|
-
vision: false,
|
|
211
|
-
embed: true,
|
|
212
|
-
speech: true,
|
|
213
|
-
quantization: {
|
|
214
|
-
int4: {
|
|
215
|
-
sizeMb: 320,
|
|
216
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int4/whisper-medium.zip',
|
|
217
|
-
pro: {
|
|
218
|
-
apple:
|
|
219
|
-
'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int4/pro/apple/whisper-medium.zip',
|
|
220
|
-
},
|
|
221
|
-
},
|
|
222
|
-
int8: {
|
|
223
|
-
sizeMb: 646,
|
|
224
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int8/whisper-medium.zip',
|
|
225
|
-
pro: {
|
|
226
|
-
apple:
|
|
227
|
-
'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int8/pro/apple/whisper-medium.zip',
|
|
228
|
-
},
|
|
229
|
-
},
|
|
230
|
-
},
|
|
231
|
-
},
|
|
232
|
-
'lfm2.5-1.2b-instruct': {
|
|
233
|
-
completion: true,
|
|
234
|
-
tools: true,
|
|
235
|
-
vision: false,
|
|
236
|
-
embed: true,
|
|
237
|
-
speech: false,
|
|
238
|
-
quantization: {
|
|
239
|
-
int4: {
|
|
240
|
-
sizeMb: 474,
|
|
241
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int4/lfm2.5-1.2b-instruct.zip',
|
|
242
|
-
},
|
|
243
|
-
int8: {
|
|
244
|
-
sizeMb: 722,
|
|
245
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int8/lfm2.5-1.2b-instruct.zip',
|
|
246
|
-
},
|
|
247
|
-
},
|
|
248
|
-
},
|
|
249
|
-
'lfm2-1.2b-rag': {
|
|
250
|
-
completion: true,
|
|
251
|
-
tools: true,
|
|
252
|
-
vision: false,
|
|
253
|
-
embed: true,
|
|
254
|
-
speech: false,
|
|
255
|
-
quantization: {
|
|
256
|
-
int4: {
|
|
257
|
-
sizeMb: 474,
|
|
258
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int4/lfm2-1.2b-rag.zip',
|
|
259
|
-
},
|
|
260
|
-
int8: {
|
|
261
|
-
sizeMb: 722,
|
|
262
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int8/lfm2-1.2b-rag.zip',
|
|
263
|
-
},
|
|
264
|
-
},
|
|
265
|
-
},
|
|
266
|
-
'lfm2-1.2b-tool': {
|
|
267
|
-
completion: true,
|
|
268
|
-
tools: true,
|
|
269
|
-
vision: false,
|
|
270
|
-
embed: true,
|
|
271
|
-
speech: false,
|
|
272
|
-
quantization: {
|
|
273
|
-
int4: {
|
|
274
|
-
sizeMb: 474,
|
|
275
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int4/lfm2-1.2b-tool.zip',
|
|
276
|
-
},
|
|
277
|
-
int8: {
|
|
278
|
-
sizeMb: 722,
|
|
279
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int8/lfm2-1.2b-tool.zip',
|
|
280
|
-
},
|
|
281
|
-
},
|
|
282
|
-
},
|
|
283
|
-
'lfm2-vl-1.6b': {
|
|
284
|
-
completion: true,
|
|
285
|
-
tools: false,
|
|
286
|
-
vision: true,
|
|
287
|
-
embed: true,
|
|
288
|
-
speech: false,
|
|
289
|
-
quantization: {
|
|
290
|
-
int4: {
|
|
291
|
-
sizeMb: 954,
|
|
292
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int4/lfm2-vl-1.6b.zip',
|
|
293
|
-
pro: {
|
|
294
|
-
apple:
|
|
295
|
-
'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int4/pro/apple/lfm2-vl-1.6b.zip',
|
|
296
|
-
},
|
|
297
|
-
},
|
|
298
|
-
int8: {
|
|
299
|
-
sizeMb: 1440,
|
|
300
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int8/lfm2-vl-1.6b.zip',
|
|
301
|
-
pro: {
|
|
302
|
-
apple:
|
|
303
|
-
'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int8/pro/apple/lfm2-vl-1.6b.zip',
|
|
304
|
-
},
|
|
305
|
-
},
|
|
306
|
-
},
|
|
307
|
-
},
|
|
308
|
-
'qwen3-1.7b': {
|
|
309
|
-
completion: true,
|
|
310
|
-
tools: true,
|
|
311
|
-
vision: false,
|
|
312
|
-
embed: true,
|
|
313
|
-
speech: false,
|
|
314
|
-
quantization: {
|
|
315
|
-
int4: {
|
|
316
|
-
sizeMb: 749,
|
|
317
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int4/qwen3-1.7b.zip',
|
|
318
|
-
},
|
|
319
|
-
int8: {
|
|
320
|
-
sizeMb: 1161,
|
|
321
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int8/qwen3-1.7b.zip',
|
|
322
|
-
},
|
|
323
|
-
},
|
|
324
|
-
},
|
|
325
|
-
'smollm2-1.7b-instruct': {
|
|
326
|
-
completion: true,
|
|
327
|
-
tools: false,
|
|
328
|
-
vision: false,
|
|
329
|
-
embed: true,
|
|
330
|
-
speech: false,
|
|
331
|
-
quantization: {
|
|
332
|
-
int4: {
|
|
333
|
-
sizeMb: 801,
|
|
334
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int4/smollm2-1.7b-instruct.zip',
|
|
335
|
-
},
|
|
336
|
-
int8: {
|
|
337
|
-
sizeMb: 1161,
|
|
338
|
-
url: 'https://vlqqczxwyaodtcdmdmlw.supabase.co/storage/v1/object/public/cactus-models/v1.5/int8/smollm2-1.7b-instruct.zip',
|
|
339
|
-
},
|
|
340
|
-
},
|
|
341
|
-
},
|
|
342
|
-
};
|
|
343
|
-
|
|
344
|
-
export default models;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { NitroModules } from 'react-native-nitro-modules';
|
|
2
|
-
import type { CactusCrypto as CactusCryptoSpec } from '../specs/CactusCrypto.nitro';
|
|
3
|
-
|
|
4
|
-
export class CactusCrypto {
|
|
5
|
-
private static readonly hybridCactusCrypto =
|
|
6
|
-
NitroModules.createHybridObject<CactusCryptoSpec>('CactusCrypto');
|
|
7
|
-
|
|
8
|
-
public static uuidv5(namespaceUuid: string, name: string): Promise<string> {
|
|
9
|
-
return this.hybridCactusCrypto.uuidv5(namespaceUuid, name);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { NitroModules } from 'react-native-nitro-modules';
|
|
2
|
-
import type {
|
|
3
|
-
CactusDeviceInfo as CactusDeviceInfoSpec,
|
|
4
|
-
DeviceInfo,
|
|
5
|
-
} from '../specs/CactusDeviceInfo.nitro';
|
|
6
|
-
|
|
7
|
-
export class CactusDeviceInfo {
|
|
8
|
-
private static readonly hybridCactusDeviceInfo =
|
|
9
|
-
NitroModules.createHybridObject<CactusDeviceInfoSpec>('CactusDeviceInfo');
|
|
10
|
-
|
|
11
|
-
public static getAppIdentifier(): Promise<string | undefined> {
|
|
12
|
-
return this.hybridCactusDeviceInfo.getAppIdentifier();
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
public static getDeviceInfo(): Promise<DeviceInfo> {
|
|
16
|
-
return this.hybridCactusDeviceInfo.getDeviceInfo();
|
|
17
|
-
}
|
|
18
|
-
}
|
package/src/native/CactusUtil.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { NitroModules } from 'react-native-nitro-modules';
|
|
2
|
-
import type { CactusUtil as CactusUtilSpec } from '../specs/CactusUtil.nitro';
|
|
3
|
-
import { Platform } from 'react-native';
|
|
4
|
-
import { CactusFileSystem } from './CactusFileSystem';
|
|
5
|
-
import { CactusConfig } from '../config/CactusConfig';
|
|
6
|
-
import { Database } from '../api/Database';
|
|
7
|
-
|
|
8
|
-
export class CactusUtil {
|
|
9
|
-
private static readonly hybridCactusUtil =
|
|
10
|
-
NitroModules.createHybridObject<CactusUtilSpec>('CactusUtil');
|
|
11
|
-
|
|
12
|
-
public static async registerApp(encryptedData: string): Promise<string> {
|
|
13
|
-
if (Platform.OS === 'android') {
|
|
14
|
-
const cactusDirectory = await CactusFileSystem.getCactusDirectory();
|
|
15
|
-
await this.hybridCactusUtil.setAndroidDataDirectory(cactusDirectory);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return this.hybridCactusUtil.registerApp(encryptedData);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
public static async getDeviceId(): Promise<string | null> {
|
|
22
|
-
if (Platform.OS === 'android') {
|
|
23
|
-
const cactusDirectory = await CactusFileSystem.getCactusDirectory();
|
|
24
|
-
await this.hybridCactusUtil.setAndroidDataDirectory(cactusDirectory);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const deviceId = await this.hybridCactusUtil.getDeviceId(
|
|
28
|
-
CactusConfig.cactusProKey
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
if (!deviceId) {
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (deviceId?.indexOf('|') !== -1) {
|
|
36
|
-
const parts = deviceId.split('|');
|
|
37
|
-
CactusConfig.cactusProKey = parts[1];
|
|
38
|
-
return await Database.registerDevice({ deviceId: parts[0] });
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return deviceId;
|
|
42
|
-
}
|
|
43
|
-
}
|