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.
Files changed (221) hide show
  1. package/Cactus.podspec +1 -1
  2. package/README.md +347 -241
  3. package/android/CMakeLists.txt +24 -5
  4. package/android/src/main/jniLibs/arm64-v8a/libcactus.a +0 -0
  5. package/android/src/main/jniLibs/arm64-v8a/libcurl.a +0 -0
  6. package/android/src/main/jniLibs/arm64-v8a/libmbedcrypto.a +0 -0
  7. package/android/src/main/jniLibs/arm64-v8a/libmbedtls.a +0 -0
  8. package/android/src/main/jniLibs/arm64-v8a/libmbedx509.a +0 -0
  9. package/cpp/HybridCactus.cpp +197 -117
  10. package/cpp/HybridCactus.hpp +18 -9
  11. package/cpp/cactus_ffi.h +66 -42
  12. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus.h +0 -1
  13. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_cloud.h +48 -0
  14. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_ffi.h +66 -42
  15. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_utils.h +568 -135
  16. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/engine.h +148 -17
  17. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/graph.h +145 -36
  18. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/kernel.h +187 -6
  19. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/kernel_utils.h +49 -149
  20. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Info.plist +0 -0
  21. package/ios/cactus.xcframework/ios-arm64/cactus.framework/cactus +0 -0
  22. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus.h +0 -1
  23. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_cloud.h +48 -0
  24. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_ffi.h +66 -42
  25. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_utils.h +568 -135
  26. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/engine.h +148 -17
  27. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/graph.h +145 -36
  28. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/kernel.h +187 -6
  29. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/kernel_utils.h +49 -149
  30. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Info.plist +0 -0
  31. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/_CodeSignature/CodeResources +1 -1
  32. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/cactus +0 -0
  33. package/lib/module/classes/CactusLM.js +16 -49
  34. package/lib/module/classes/CactusLM.js.map +1 -1
  35. package/lib/module/classes/CactusSTT.js +41 -75
  36. package/lib/module/classes/CactusSTT.js.map +1 -1
  37. package/lib/module/classes/CactusVAD.js +95 -0
  38. package/lib/module/classes/CactusVAD.js.map +1 -0
  39. package/lib/module/hooks/useCactusLM.js +10 -11
  40. package/lib/module/hooks/useCactusLM.js.map +1 -1
  41. package/lib/module/hooks/useCactusSTT.js +23 -62
  42. package/lib/module/hooks/useCactusSTT.js.map +1 -1
  43. package/lib/module/hooks/useCactusVAD.js +171 -0
  44. package/lib/module/hooks/useCactusVAD.js.map +1 -0
  45. package/lib/module/index.js +2 -3
  46. package/lib/module/index.js.map +1 -1
  47. package/lib/module/modelRegistry.js +52 -0
  48. package/lib/module/modelRegistry.js.map +1 -0
  49. package/lib/module/native/Cactus.js +103 -23
  50. package/lib/module/native/Cactus.js.map +1 -1
  51. package/lib/module/native/CactusIndex.js.map +1 -1
  52. package/lib/module/native/index.js +0 -3
  53. package/lib/module/native/index.js.map +1 -1
  54. package/lib/module/types/CactusVAD.js +4 -0
  55. package/lib/module/{specs/CactusUtil.nitro.js.map → types/CactusVAD.js.map} +1 -1
  56. package/lib/typescript/src/classes/CactusLM.d.ts +5 -7
  57. package/lib/typescript/src/classes/CactusLM.d.ts.map +1 -1
  58. package/lib/typescript/src/classes/CactusSTT.d.ts +9 -12
  59. package/lib/typescript/src/classes/CactusSTT.d.ts.map +1 -1
  60. package/lib/typescript/src/classes/CactusVAD.d.ts +20 -0
  61. package/lib/typescript/src/classes/CactusVAD.d.ts.map +1 -0
  62. package/lib/typescript/src/hooks/useCactusLM.d.ts +2 -2
  63. package/lib/typescript/src/hooks/useCactusLM.d.ts.map +1 -1
  64. package/lib/typescript/src/hooks/useCactusSTT.d.ts +6 -8
  65. package/lib/typescript/src/hooks/useCactusSTT.d.ts.map +1 -1
  66. package/lib/typescript/src/hooks/useCactusVAD.d.ts +15 -0
  67. package/lib/typescript/src/hooks/useCactusVAD.d.ts.map +1 -0
  68. package/lib/typescript/src/index.d.ts +7 -5
  69. package/lib/typescript/src/index.d.ts.map +1 -1
  70. package/lib/typescript/src/modelRegistry.d.ts +5 -0
  71. package/lib/typescript/src/modelRegistry.d.ts.map +1 -0
  72. package/lib/typescript/src/native/Cactus.d.ts +13 -11
  73. package/lib/typescript/src/native/Cactus.d.ts.map +1 -1
  74. package/lib/typescript/src/native/CactusIndex.d.ts +2 -2
  75. package/lib/typescript/src/native/CactusIndex.d.ts.map +1 -1
  76. package/lib/typescript/src/native/index.d.ts +0 -3
  77. package/lib/typescript/src/native/index.d.ts.map +1 -1
  78. package/lib/typescript/src/specs/Cactus.nitro.d.ts +7 -6
  79. package/lib/typescript/src/specs/Cactus.nitro.d.ts.map +1 -1
  80. package/lib/typescript/src/types/CactusIndex.d.ts +2 -2
  81. package/lib/typescript/src/types/CactusIndex.d.ts.map +1 -1
  82. package/lib/typescript/src/types/CactusLM.d.ts +19 -11
  83. package/lib/typescript/src/types/CactusLM.d.ts.map +1 -1
  84. package/lib/typescript/src/types/CactusSTT.d.ts +44 -12
  85. package/lib/typescript/src/types/CactusSTT.d.ts.map +1 -1
  86. package/lib/typescript/src/types/CactusVAD.d.ts +34 -0
  87. package/lib/typescript/src/types/CactusVAD.d.ts.map +1 -0
  88. package/lib/typescript/src/types/common.d.ts +1 -6
  89. package/lib/typescript/src/types/common.d.ts.map +1 -1
  90. package/nitro.json +0 -11
  91. package/nitrogen/generated/android/cactus+autolinking.cmake +0 -5
  92. package/nitrogen/generated/android/cactusOnLoad.cpp +0 -30
  93. package/nitrogen/generated/ios/Cactus-Swift-Cxx-Bridge.cpp +0 -50
  94. package/nitrogen/generated/ios/Cactus-Swift-Cxx-Bridge.hpp +9 -147
  95. package/nitrogen/generated/ios/Cactus-Swift-Cxx-Umbrella.hpp +0 -13
  96. package/nitrogen/generated/ios/CactusAutolinking.mm +0 -26
  97. package/nitrogen/generated/ios/CactusAutolinking.swift +0 -30
  98. package/nitrogen/generated/shared/c++/HybridCactusSpec.cpp +5 -4
  99. package/nitrogen/generated/shared/c++/HybridCactusSpec.hpp +7 -6
  100. package/package.json +3 -3
  101. package/src/classes/CactusLM.ts +18 -65
  102. package/src/classes/CactusSTT.ts +52 -90
  103. package/src/classes/CactusVAD.ts +129 -0
  104. package/src/hooks/useCactusLM.ts +14 -17
  105. package/src/hooks/useCactusSTT.ts +47 -98
  106. package/src/hooks/useCactusVAD.ts +215 -0
  107. package/src/index.tsx +21 -12
  108. package/src/modelRegistry.ts +65 -0
  109. package/src/native/Cactus.ts +131 -38
  110. package/src/native/CactusIndex.ts +2 -2
  111. package/src/native/index.ts +0 -3
  112. package/src/specs/Cactus.nitro.ts +16 -7
  113. package/src/types/CactusIndex.ts +2 -2
  114. package/src/types/CactusLM.ts +19 -11
  115. package/src/types/CactusSTT.ts +47 -13
  116. package/src/types/CactusVAD.ts +39 -0
  117. package/src/types/common.ts +1 -6
  118. package/android/src/main/java/com/margelo/nitro/cactus/HybridCactusCrypto.kt +0 -46
  119. package/android/src/main/java/com/margelo/nitro/cactus/HybridCactusDeviceInfo.kt +0 -27
  120. package/android/src/main/jniLibs/arm64-v8a/libcactus_util.a +0 -0
  121. package/cpp/HybridCactusUtil.cpp +0 -47
  122. package/cpp/HybridCactusUtil.hpp +0 -27
  123. package/cpp/cactus_util.h +0 -25
  124. package/ios/HybridCactusCrypto.swift +0 -37
  125. package/ios/HybridCactusDeviceInfo.swift +0 -32
  126. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_telemetry.h +0 -656
  127. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_telemetry.h +0 -656
  128. package/ios/cactus_util.xcframework/Info.plist +0 -39
  129. package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/cactus_util.h +0 -25
  130. package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/database.h +0 -27
  131. package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/ios_utils.h +0 -10
  132. package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/logging.h +0 -25
  133. package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Info.plist +0 -0
  134. package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/cactus_util +0 -0
  135. package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/cactus_util.h +0 -25
  136. package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/database.h +0 -27
  137. package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/ios_utils.h +0 -10
  138. package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/logging.h +0 -25
  139. package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Info.plist +0 -0
  140. package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/_CodeSignature/CodeResources +0 -135
  141. package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/cactus_util +0 -0
  142. package/lib/module/api/Database.js +0 -45
  143. package/lib/module/api/Database.js.map +0 -1
  144. package/lib/module/api/RemoteLM.js +0 -201
  145. package/lib/module/api/RemoteLM.js.map +0 -1
  146. package/lib/module/config/CactusConfig.js +0 -12
  147. package/lib/module/config/CactusConfig.js.map +0 -1
  148. package/lib/module/models.js +0 -336
  149. package/lib/module/models.js.map +0 -1
  150. package/lib/module/native/CactusCrypto.js +0 -10
  151. package/lib/module/native/CactusCrypto.js.map +0 -1
  152. package/lib/module/native/CactusDeviceInfo.js +0 -13
  153. package/lib/module/native/CactusDeviceInfo.js.map +0 -1
  154. package/lib/module/native/CactusUtil.js +0 -36
  155. package/lib/module/native/CactusUtil.js.map +0 -1
  156. package/lib/module/specs/CactusCrypto.nitro.js +0 -4
  157. package/lib/module/specs/CactusCrypto.nitro.js.map +0 -1
  158. package/lib/module/specs/CactusDeviceInfo.nitro.js +0 -4
  159. package/lib/module/specs/CactusDeviceInfo.nitro.js.map +0 -1
  160. package/lib/module/specs/CactusUtil.nitro.js +0 -4
  161. package/lib/module/telemetry/Telemetry.js +0 -154
  162. package/lib/module/telemetry/Telemetry.js.map +0 -1
  163. package/lib/typescript/src/api/Database.d.ts +0 -12
  164. package/lib/typescript/src/api/Database.d.ts.map +0 -1
  165. package/lib/typescript/src/api/RemoteLM.d.ts +0 -14
  166. package/lib/typescript/src/api/RemoteLM.d.ts.map +0 -1
  167. package/lib/typescript/src/config/CactusConfig.d.ts +0 -7
  168. package/lib/typescript/src/config/CactusConfig.d.ts.map +0 -1
  169. package/lib/typescript/src/models.d.ts +0 -6
  170. package/lib/typescript/src/models.d.ts.map +0 -1
  171. package/lib/typescript/src/native/CactusCrypto.d.ts +0 -5
  172. package/lib/typescript/src/native/CactusCrypto.d.ts.map +0 -1
  173. package/lib/typescript/src/native/CactusDeviceInfo.d.ts +0 -7
  174. package/lib/typescript/src/native/CactusDeviceInfo.d.ts.map +0 -1
  175. package/lib/typescript/src/native/CactusUtil.d.ts +0 -6
  176. package/lib/typescript/src/native/CactusUtil.d.ts.map +0 -1
  177. package/lib/typescript/src/specs/CactusCrypto.nitro.d.ts +0 -8
  178. package/lib/typescript/src/specs/CactusCrypto.nitro.d.ts.map +0 -1
  179. package/lib/typescript/src/specs/CactusDeviceInfo.nitro.d.ts +0 -16
  180. package/lib/typescript/src/specs/CactusDeviceInfo.nitro.d.ts.map +0 -1
  181. package/lib/typescript/src/specs/CactusUtil.nitro.d.ts +0 -10
  182. package/lib/typescript/src/specs/CactusUtil.nitro.d.ts.map +0 -1
  183. package/lib/typescript/src/telemetry/Telemetry.d.ts +0 -34
  184. package/lib/typescript/src/telemetry/Telemetry.d.ts.map +0 -1
  185. package/nitrogen/generated/android/c++/JDeviceInfo.hpp +0 -74
  186. package/nitrogen/generated/android/c++/JHybridCactusCryptoSpec.cpp +0 -65
  187. package/nitrogen/generated/android/c++/JHybridCactusCryptoSpec.hpp +0 -65
  188. package/nitrogen/generated/android/c++/JHybridCactusDeviceInfoSpec.cpp +0 -85
  189. package/nitrogen/generated/android/c++/JHybridCactusDeviceInfoSpec.hpp +0 -66
  190. package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/DeviceInfo.kt +0 -50
  191. package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/HybridCactusCryptoSpec.kt +0 -58
  192. package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/HybridCactusDeviceInfoSpec.kt +0 -62
  193. package/nitrogen/generated/ios/c++/HybridCactusCryptoSpecSwift.cpp +0 -11
  194. package/nitrogen/generated/ios/c++/HybridCactusCryptoSpecSwift.hpp +0 -77
  195. package/nitrogen/generated/ios/c++/HybridCactusDeviceInfoSpecSwift.cpp +0 -11
  196. package/nitrogen/generated/ios/c++/HybridCactusDeviceInfoSpecSwift.hpp +0 -88
  197. package/nitrogen/generated/ios/swift/DeviceInfo.swift +0 -98
  198. package/nitrogen/generated/ios/swift/Func_void_DeviceInfo.swift +0 -47
  199. package/nitrogen/generated/ios/swift/Func_void_std__optional_std__string_.swift +0 -54
  200. package/nitrogen/generated/ios/swift/HybridCactusCryptoSpec.swift +0 -57
  201. package/nitrogen/generated/ios/swift/HybridCactusCryptoSpec_cxx.swift +0 -139
  202. package/nitrogen/generated/ios/swift/HybridCactusDeviceInfoSpec.swift +0 -58
  203. package/nitrogen/generated/ios/swift/HybridCactusDeviceInfoSpec_cxx.swift +0 -164
  204. package/nitrogen/generated/shared/c++/DeviceInfo.hpp +0 -92
  205. package/nitrogen/generated/shared/c++/HybridCactusCryptoSpec.cpp +0 -21
  206. package/nitrogen/generated/shared/c++/HybridCactusCryptoSpec.hpp +0 -63
  207. package/nitrogen/generated/shared/c++/HybridCactusDeviceInfoSpec.cpp +0 -22
  208. package/nitrogen/generated/shared/c++/HybridCactusDeviceInfoSpec.hpp +0 -67
  209. package/nitrogen/generated/shared/c++/HybridCactusUtilSpec.cpp +0 -23
  210. package/nitrogen/generated/shared/c++/HybridCactusUtilSpec.hpp +0 -66
  211. package/src/api/Database.ts +0 -55
  212. package/src/api/RemoteLM.ts +0 -273
  213. package/src/config/CactusConfig.ts +0 -11
  214. package/src/models.ts +0 -344
  215. package/src/native/CactusCrypto.ts +0 -11
  216. package/src/native/CactusDeviceInfo.ts +0 -18
  217. package/src/native/CactusUtil.ts +0 -43
  218. package/src/specs/CactusCrypto.nitro.ts +0 -6
  219. package/src/specs/CactusDeviceInfo.nitro.ts +0 -15
  220. package/src/specs/CactusUtil.nitro.ts +0 -8
  221. package/src/telemetry/Telemetry.ts +0 -236
@@ -1,6 +0,0 @@
1
- import type { HybridObject } from 'react-native-nitro-modules';
2
-
3
- export interface CactusCrypto
4
- extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
5
- uuidv5(namespaceUuid: string, name: string): Promise<string>;
6
- }
@@ -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
- }