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
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
-
|
|
3
|
-
export interface DeviceInfo {
|
|
4
|
-
brand: string;
|
|
5
|
-
model: string;
|
|
6
|
-
device_id?: string;
|
|
7
|
-
os: string;
|
|
8
|
-
os_version: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface CactusDeviceInfo
|
|
12
|
-
extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
|
|
13
|
-
getAppIdentifier(): Promise<string | undefined>;
|
|
14
|
-
getDeviceInfo(): Promise<DeviceInfo>;
|
|
15
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
-
|
|
3
|
-
export interface CactusUtil
|
|
4
|
-
extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
|
|
5
|
-
registerApp(encryptedData: string): Promise<string>;
|
|
6
|
-
getDeviceId(token?: string): Promise<string | null>;
|
|
7
|
-
setAndroidDataDirectory(dataDir: string): Promise<void>;
|
|
8
|
-
}
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import { Database } from '../api/Database';
|
|
2
|
-
import {
|
|
3
|
-
CactusCrypto,
|
|
4
|
-
CactusDeviceInfo,
|
|
5
|
-
CactusFileSystem,
|
|
6
|
-
CactusUtil,
|
|
7
|
-
} from '../native';
|
|
8
|
-
import { CactusConfig } from '../config/CactusConfig';
|
|
9
|
-
import { packageVersion } from '../constants/packageVersion';
|
|
10
|
-
import type { CactusLMCompleteResult } from '../types/CactusLM';
|
|
11
|
-
import type { CactusSTTTranscribeResult } from '../types/CactusSTT';
|
|
12
|
-
|
|
13
|
-
export interface LogRecord {
|
|
14
|
-
// Framework
|
|
15
|
-
framework: 'react-native';
|
|
16
|
-
framework_version: string;
|
|
17
|
-
|
|
18
|
-
// Event
|
|
19
|
-
event_type:
|
|
20
|
-
| 'init'
|
|
21
|
-
| 'completion'
|
|
22
|
-
| 'transcription'
|
|
23
|
-
| 'embedding'
|
|
24
|
-
| 'image_embedding'
|
|
25
|
-
| 'audio_embedding';
|
|
26
|
-
model: string;
|
|
27
|
-
success: boolean;
|
|
28
|
-
message?: string;
|
|
29
|
-
|
|
30
|
-
// Telemetry
|
|
31
|
-
telemetry_token?: string;
|
|
32
|
-
project_id?: string;
|
|
33
|
-
device_id?: string;
|
|
34
|
-
|
|
35
|
-
// LM
|
|
36
|
-
tokens?: number;
|
|
37
|
-
response_time?: number;
|
|
38
|
-
ttft?: number;
|
|
39
|
-
tps?: number;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export class Telemetry {
|
|
43
|
-
private static cactusTelemetryToken?: string;
|
|
44
|
-
private static projectId?: string;
|
|
45
|
-
private static deviceId?: string;
|
|
46
|
-
|
|
47
|
-
private static readonly namespaceUrl = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
|
|
48
|
-
private static readonly logBufferPaths = {
|
|
49
|
-
init: 'logs/init.json',
|
|
50
|
-
completion: 'logs/completion.json',
|
|
51
|
-
transcription: 'logs/transcription.json',
|
|
52
|
-
embedding: 'logs/embedding.json',
|
|
53
|
-
image_embedding: 'logs/image_embedding.json',
|
|
54
|
-
audio_embedding: 'logs/audio_embedding.json',
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
private static async handleLog(logRecord: LogRecord) {
|
|
58
|
-
if (!this.isInitialized()) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (!CactusConfig.isTelemetryEnabled) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const logBufferPath = this.logBufferPaths[logRecord.event_type];
|
|
67
|
-
|
|
68
|
-
let logs = [];
|
|
69
|
-
if (await CactusFileSystem.fileExists(logBufferPath)) {
|
|
70
|
-
try {
|
|
71
|
-
logs = JSON.parse(await CactusFileSystem.readFile(logBufferPath));
|
|
72
|
-
} catch {
|
|
73
|
-
// Delete corrupted log buffer
|
|
74
|
-
await CactusFileSystem.deleteFile(logBufferPath);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
logs.push(logRecord);
|
|
78
|
-
|
|
79
|
-
try {
|
|
80
|
-
await Database.sendLogRecords(logs);
|
|
81
|
-
|
|
82
|
-
if (await CactusFileSystem.fileExists(logBufferPath)) {
|
|
83
|
-
await CactusFileSystem.deleteFile(logBufferPath);
|
|
84
|
-
}
|
|
85
|
-
} catch {
|
|
86
|
-
await CactusFileSystem.writeFile(logBufferPath, JSON.stringify(logs));
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
public static isInitialized(): boolean {
|
|
91
|
-
return !!(this.projectId && this.deviceId);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
public static async init(cactusTelemetryToken?: string): Promise<void> {
|
|
95
|
-
if (this.isInitialized()) {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (!CactusConfig.isTelemetryEnabled) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
this.cactusTelemetryToken = cactusTelemetryToken;
|
|
104
|
-
|
|
105
|
-
const appIdentifier = await CactusDeviceInfo.getAppIdentifier();
|
|
106
|
-
const name = `https://cactus-react-native/${appIdentifier}/v1`;
|
|
107
|
-
this.projectId = await CactusCrypto.uuidv5(this.namespaceUrl, name);
|
|
108
|
-
|
|
109
|
-
const deviceInfo = await CactusDeviceInfo.getDeviceInfo();
|
|
110
|
-
try {
|
|
111
|
-
this.deviceId =
|
|
112
|
-
(await CactusUtil.getDeviceId()) ??
|
|
113
|
-
(await Database.registerDevice({ deviceData: deviceInfo }));
|
|
114
|
-
} catch (error) {
|
|
115
|
-
console.log(error);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
public static logInit(
|
|
120
|
-
model: string,
|
|
121
|
-
success: boolean,
|
|
122
|
-
message?: string
|
|
123
|
-
): Promise<void> {
|
|
124
|
-
return this.handleLog({
|
|
125
|
-
framework: 'react-native',
|
|
126
|
-
framework_version: packageVersion,
|
|
127
|
-
event_type: 'init',
|
|
128
|
-
model,
|
|
129
|
-
success,
|
|
130
|
-
message,
|
|
131
|
-
telemetry_token: this.cactusTelemetryToken,
|
|
132
|
-
project_id: this.projectId,
|
|
133
|
-
device_id: this.deviceId,
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
public static logCompletion(
|
|
138
|
-
model: string,
|
|
139
|
-
success: boolean,
|
|
140
|
-
message?: string,
|
|
141
|
-
result?: CactusLMCompleteResult
|
|
142
|
-
): Promise<void> {
|
|
143
|
-
return this.handleLog({
|
|
144
|
-
framework: 'react-native',
|
|
145
|
-
framework_version: packageVersion,
|
|
146
|
-
event_type: 'completion',
|
|
147
|
-
model,
|
|
148
|
-
success,
|
|
149
|
-
message,
|
|
150
|
-
telemetry_token: this.cactusTelemetryToken,
|
|
151
|
-
project_id: this.projectId,
|
|
152
|
-
device_id: this.deviceId,
|
|
153
|
-
tokens: result?.totalTokens,
|
|
154
|
-
response_time: result?.totalTimeMs,
|
|
155
|
-
ttft: result?.timeToFirstTokenMs,
|
|
156
|
-
tps: result?.tokensPerSecond,
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
public static logTranscribe(
|
|
161
|
-
model: string,
|
|
162
|
-
success: boolean,
|
|
163
|
-
message?: string,
|
|
164
|
-
result?: CactusSTTTranscribeResult
|
|
165
|
-
): Promise<void> {
|
|
166
|
-
return this.handleLog({
|
|
167
|
-
framework: 'react-native',
|
|
168
|
-
framework_version: packageVersion,
|
|
169
|
-
event_type: 'transcription',
|
|
170
|
-
model,
|
|
171
|
-
success,
|
|
172
|
-
message,
|
|
173
|
-
telemetry_token: this.cactusTelemetryToken,
|
|
174
|
-
project_id: this.projectId,
|
|
175
|
-
device_id: this.deviceId,
|
|
176
|
-
tokens: result?.totalTokens,
|
|
177
|
-
response_time: result?.totalTimeMs,
|
|
178
|
-
ttft: result?.timeToFirstTokenMs,
|
|
179
|
-
tps: result?.tokensPerSecond,
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
public static logEmbedding(
|
|
184
|
-
model: string,
|
|
185
|
-
success: boolean,
|
|
186
|
-
message?: string
|
|
187
|
-
): Promise<void> {
|
|
188
|
-
return this.handleLog({
|
|
189
|
-
framework: 'react-native',
|
|
190
|
-
framework_version: packageVersion,
|
|
191
|
-
event_type: 'embedding',
|
|
192
|
-
model,
|
|
193
|
-
success,
|
|
194
|
-
message,
|
|
195
|
-
telemetry_token: this.cactusTelemetryToken,
|
|
196
|
-
project_id: this.projectId,
|
|
197
|
-
device_id: this.deviceId,
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
public static logImageEmbedding(
|
|
202
|
-
model: string,
|
|
203
|
-
success: boolean,
|
|
204
|
-
message?: string
|
|
205
|
-
): Promise<void> {
|
|
206
|
-
return this.handleLog({
|
|
207
|
-
framework: 'react-native',
|
|
208
|
-
framework_version: packageVersion,
|
|
209
|
-
event_type: 'image_embedding',
|
|
210
|
-
model,
|
|
211
|
-
success,
|
|
212
|
-
message,
|
|
213
|
-
telemetry_token: this.cactusTelemetryToken,
|
|
214
|
-
project_id: this.projectId,
|
|
215
|
-
device_id: this.deviceId,
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
public static logAudioEmbedding(
|
|
220
|
-
model: string,
|
|
221
|
-
success: boolean,
|
|
222
|
-
message?: string
|
|
223
|
-
): Promise<void> {
|
|
224
|
-
return this.handleLog({
|
|
225
|
-
framework: 'react-native',
|
|
226
|
-
framework_version: packageVersion,
|
|
227
|
-
event_type: 'audio_embedding',
|
|
228
|
-
model,
|
|
229
|
-
success,
|
|
230
|
-
message,
|
|
231
|
-
telemetry_token: this.cactusTelemetryToken,
|
|
232
|
-
project_id: this.projectId,
|
|
233
|
-
device_id: this.deviceId,
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
}
|