react-native-litert-lm 0.3.7 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +153 -135
- package/android/build.gradle +12 -0
- package/android/src/main/AndroidManifest.xml +5 -0
- package/android/src/main/java/com/margelo/nitro/dev/litert/litertlm/HybridLiteRTLM.kt +159 -62
- package/android/src/main/java/dev/litert/litertlm/LiteRTLMPackage.kt +19 -2
- package/android/src/test/java/com/margelo/nitro/core/Promise.kt +46 -0
- package/android/src/test/java/com/margelo/nitro/dev/litert/litertlm/HybridLiteRTLMTest.kt +83 -0
- package/ios/HybridLiteRTLM.swift +1058 -0
- package/ios/Tests/HybridLiteRTLMTests.swift +67 -0
- package/lib/__mocks__/react-native-nitro-modules.d.ts +61 -0
- package/lib/__mocks__/react-native-nitro-modules.js +50 -0
- package/lib/__tests__/hooks.test.d.ts +1 -0
- package/lib/__tests__/hooks.test.js +124 -0
- package/lib/__tests__/memoryTracker.test.d.ts +1 -0
- package/lib/__tests__/memoryTracker.test.js +74 -0
- package/lib/__tests__/modelFactory.test.d.ts +1 -0
- package/lib/__tests__/modelFactory.test.js +52 -0
- package/lib/hooks.js +1 -1
- package/lib/index.d.ts +0 -2
- package/lib/index.js +1 -5
- package/lib/modelFactory.js +62 -63
- package/lib/specs/LiteRTLM.nitro.d.ts +71 -2
- package/nitrogen/generated/android/c++/JHybridLiteRTLMSpec.cpp +62 -7
- package/nitrogen/generated/android/c++/JHybridLiteRTLMSpec.hpp +3 -1
- package/nitrogen/generated/android/c++/JLLMConfig.hpp +40 -3
- package/nitrogen/generated/android/c++/JMultimodalPart.hpp +74 -0
- package/nitrogen/generated/android/c++/JPartType.hpp +61 -0
- package/nitrogen/generated/android/c++/JToolDefinition.hpp +65 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dev/litert/litertlm/GenerationStats.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dev/litert/litertlm/HybridLiteRTLMSpec.kt +10 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dev/litert/litertlm/LLMConfig.kt +46 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dev/litert/litertlm/MemoryUsage.kt +19 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dev/litert/litertlm/Message.kt +15 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dev/litert/litertlm/MultimodalPart.kt +66 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dev/litert/litertlm/PartType.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dev/litert/litertlm/ToolDefinition.kt +61 -0
- package/nitrogen/generated/ios/LiteRTLM-Swift-Cxx-Bridge.cpp +57 -1
- package/nitrogen/generated/ios/LiteRTLM-Swift-Cxx-Bridge.hpp +414 -3
- package/nitrogen/generated/ios/LiteRTLM-Swift-Cxx-Umbrella.hpp +41 -3
- package/nitrogen/generated/ios/LiteRTLMAutolinking.mm +4 -6
- package/nitrogen/generated/ios/LiteRTLMAutolinking.swift +10 -0
- package/nitrogen/generated/ios/c++/HybridLiteRTLMSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridLiteRTLMSpecSwift.hpp +224 -0
- package/nitrogen/generated/ios/swift/Backend.swift +44 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_double.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string_bool.swift +46 -0
- package/nitrogen/generated/ios/swift/GenerationStats.swift +54 -0
- package/nitrogen/generated/ios/swift/HybridLiteRTLMSpec.swift +69 -0
- package/nitrogen/generated/ios/swift/HybridLiteRTLMSpec_cxx.swift +383 -0
- package/nitrogen/generated/ios/swift/LLMConfig.swift +203 -0
- package/nitrogen/generated/ios/swift/MemoryUsage.swift +44 -0
- package/nitrogen/generated/ios/swift/Message.swift +34 -0
- package/nitrogen/generated/ios/swift/MultimodalPart.swift +83 -0
- package/nitrogen/generated/ios/swift/PartType.swift +44 -0
- package/nitrogen/generated/ios/swift/Role.swift +44 -0
- package/nitrogen/generated/ios/swift/ToolDefinition.swift +39 -0
- package/nitrogen/generated/shared/c++/HybridLiteRTLMSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridLiteRTLMSpec.hpp +7 -2
- package/nitrogen/generated/shared/c++/LLMConfig.hpp +22 -2
- package/nitrogen/generated/shared/c++/MultimodalPart.hpp +99 -0
- package/nitrogen/generated/shared/c++/PartType.hpp +80 -0
- package/nitrogen/generated/shared/c++/ToolDefinition.hpp +91 -0
- package/package.json +16 -8
- package/react-native-litert-lm.podspec +15 -19
- package/scripts/download-ios-frameworks.sh +14 -48
- package/scripts/postinstall.js +1 -2
- package/src/__mocks__/react-native-nitro-modules.ts +48 -0
- package/src/__tests__/hooks.test.ts +153 -0
- package/src/__tests__/memoryTracker.test.ts +87 -0
- package/src/__tests__/modelFactory.test.ts +68 -0
- package/src/hooks.ts +1 -1
- package/src/index.ts +0 -7
- package/src/modelFactory.ts +82 -80
- package/src/specs/LiteRTLM.nitro.ts +80 -2
- package/cpp/HybridLiteRTLM.cpp +0 -939
- package/cpp/HybridLiteRTLM.hpp +0 -169
- package/cpp/IOSDownloadHelper.h +0 -24
- package/ios/IOSDownloadHelper.mm +0 -129
- package/scripts/build-ios-engine.sh +0 -302
- package/scripts/stubs/cxx_bridge_stubs.cc +0 -224
- package/scripts/stubs/gemma_model_constraint_provider.cc +0 -46
- package/scripts/stubs/llguidance_stubs.c +0 -101
- package/src/templates.ts +0 -105
|
@@ -8,13 +8,55 @@
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
10
|
// Forward declarations of C++ defined types
|
|
11
|
-
|
|
11
|
+
// Forward declaration of `ArrayBufferHolder` to properly resolve imports.
|
|
12
|
+
namespace NitroModules { class ArrayBufferHolder; }
|
|
13
|
+
// Forward declaration of `Backend` to properly resolve imports.
|
|
14
|
+
namespace margelo::nitro::litertlm { enum class Backend; }
|
|
15
|
+
// Forward declaration of `GenerationStats` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::litertlm { struct GenerationStats; }
|
|
17
|
+
// Forward declaration of `HybridLiteRTLMSpec` to properly resolve imports.
|
|
18
|
+
namespace margelo::nitro::litertlm { class HybridLiteRTLMSpec; }
|
|
19
|
+
// Forward declaration of `LLMConfig` to properly resolve imports.
|
|
20
|
+
namespace margelo::nitro::litertlm { struct LLMConfig; }
|
|
21
|
+
// Forward declaration of `MemoryUsage` to properly resolve imports.
|
|
22
|
+
namespace margelo::nitro::litertlm { struct MemoryUsage; }
|
|
23
|
+
// Forward declaration of `Message` to properly resolve imports.
|
|
24
|
+
namespace margelo::nitro::litertlm { struct Message; }
|
|
25
|
+
// Forward declaration of `MultimodalPart` to properly resolve imports.
|
|
26
|
+
namespace margelo::nitro::litertlm { struct MultimodalPart; }
|
|
27
|
+
// Forward declaration of `PartType` to properly resolve imports.
|
|
28
|
+
namespace margelo::nitro::litertlm { enum class PartType; }
|
|
29
|
+
// Forward declaration of `Role` to properly resolve imports.
|
|
30
|
+
namespace margelo::nitro::litertlm { enum class Role; }
|
|
31
|
+
// Forward declaration of `ToolDefinition` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::litertlm { struct ToolDefinition; }
|
|
12
33
|
|
|
13
34
|
// Forward declarations of Swift defined types
|
|
14
|
-
|
|
35
|
+
// Forward declaration of `HybridLiteRTLMSpec_cxx` to properly resolve imports.
|
|
36
|
+
namespace LiteRTLM { class HybridLiteRTLMSpec_cxx; }
|
|
15
37
|
|
|
16
38
|
// Include C++ defined types
|
|
17
|
-
|
|
39
|
+
#include "Backend.hpp"
|
|
40
|
+
#include "GenerationStats.hpp"
|
|
41
|
+
#include "HybridLiteRTLMSpec.hpp"
|
|
42
|
+
#include "LLMConfig.hpp"
|
|
43
|
+
#include "MemoryUsage.hpp"
|
|
44
|
+
#include "Message.hpp"
|
|
45
|
+
#include "MultimodalPart.hpp"
|
|
46
|
+
#include "PartType.hpp"
|
|
47
|
+
#include "Role.hpp"
|
|
48
|
+
#include "ToolDefinition.hpp"
|
|
49
|
+
#include <NitroModules/ArrayBuffer.hpp>
|
|
50
|
+
#include <NitroModules/ArrayBufferHolder.hpp>
|
|
51
|
+
#include <NitroModules/Promise.hpp>
|
|
52
|
+
#include <NitroModules/PromiseHolder.hpp>
|
|
53
|
+
#include <NitroModules/Result.hpp>
|
|
54
|
+
#include <exception>
|
|
55
|
+
#include <functional>
|
|
56
|
+
#include <memory>
|
|
57
|
+
#include <optional>
|
|
58
|
+
#include <string>
|
|
59
|
+
#include <vector>
|
|
18
60
|
|
|
19
61
|
/**
|
|
20
62
|
* Contains specialized versions of C++ templated types so they can be accessed from Swift,
|
|
@@ -22,6 +64,375 @@
|
|
|
22
64
|
*/
|
|
23
65
|
namespace margelo::nitro::litertlm::bridge::swift {
|
|
24
66
|
|
|
67
|
+
// pragma MARK: std::shared_ptr<Promise<void>>
|
|
68
|
+
/**
|
|
69
|
+
* Specialized version of `std::shared_ptr<Promise<void>>`.
|
|
70
|
+
*/
|
|
71
|
+
using std__shared_ptr_Promise_void__ = std::shared_ptr<Promise<void>>;
|
|
72
|
+
inline std::shared_ptr<Promise<void>> create_std__shared_ptr_Promise_void__() noexcept {
|
|
73
|
+
return Promise<void>::create();
|
|
74
|
+
}
|
|
75
|
+
inline PromiseHolder<void> wrap_std__shared_ptr_Promise_void__(std::shared_ptr<Promise<void>> promise) noexcept {
|
|
76
|
+
return PromiseHolder<void>(std::move(promise));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// pragma MARK: std::function<void()>
|
|
80
|
+
/**
|
|
81
|
+
* Specialized version of `std::function<void()>`.
|
|
82
|
+
*/
|
|
83
|
+
using Func_void = std::function<void()>;
|
|
84
|
+
/**
|
|
85
|
+
* Wrapper class for a `std::function<void()>`, this can be used from Swift.
|
|
86
|
+
*/
|
|
87
|
+
class Func_void_Wrapper final {
|
|
88
|
+
public:
|
|
89
|
+
explicit Func_void_Wrapper(std::function<void()>&& func): _function(std::make_unique<std::function<void()>>(std::move(func))) {}
|
|
90
|
+
inline void call() const noexcept {
|
|
91
|
+
_function->operator()();
|
|
92
|
+
}
|
|
93
|
+
private:
|
|
94
|
+
std::unique_ptr<std::function<void()>> _function;
|
|
95
|
+
} SWIFT_NONCOPYABLE;
|
|
96
|
+
Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept;
|
|
97
|
+
inline Func_void_Wrapper wrap_Func_void(Func_void value) noexcept {
|
|
98
|
+
return Func_void_Wrapper(std::move(value));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
|
|
102
|
+
/**
|
|
103
|
+
* Specialized version of `std::function<void(const std::exception_ptr&)>`.
|
|
104
|
+
*/
|
|
105
|
+
using Func_void_std__exception_ptr = std::function<void(const std::exception_ptr& /* error */)>;
|
|
106
|
+
/**
|
|
107
|
+
* Wrapper class for a `std::function<void(const std::exception_ptr& / * error * /)>`, this can be used from Swift.
|
|
108
|
+
*/
|
|
109
|
+
class Func_void_std__exception_ptr_Wrapper final {
|
|
110
|
+
public:
|
|
111
|
+
explicit Func_void_std__exception_ptr_Wrapper(std::function<void(const std::exception_ptr& /* error */)>&& func): _function(std::make_unique<std::function<void(const std::exception_ptr& /* error */)>>(std::move(func))) {}
|
|
112
|
+
inline void call(std::exception_ptr error) const noexcept {
|
|
113
|
+
_function->operator()(error);
|
|
114
|
+
}
|
|
115
|
+
private:
|
|
116
|
+
std::unique_ptr<std::function<void(const std::exception_ptr& /* error */)>> _function;
|
|
117
|
+
} SWIFT_NONCOPYABLE;
|
|
118
|
+
Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept;
|
|
119
|
+
inline Func_void_std__exception_ptr_Wrapper wrap_Func_void_std__exception_ptr(Func_void_std__exception_ptr value) noexcept {
|
|
120
|
+
return Func_void_std__exception_ptr_Wrapper(std::move(value));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// pragma MARK: std::optional<std::string>
|
|
124
|
+
/**
|
|
125
|
+
* Specialized version of `std::optional<std::string>`.
|
|
126
|
+
*/
|
|
127
|
+
using std__optional_std__string_ = std::optional<std::string>;
|
|
128
|
+
inline std::optional<std::string> create_std__optional_std__string_(const std::string& value) noexcept {
|
|
129
|
+
return std::optional<std::string>(value);
|
|
130
|
+
}
|
|
131
|
+
inline bool has_value_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
|
|
132
|
+
return optional.has_value();
|
|
133
|
+
}
|
|
134
|
+
inline std::string get_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
|
|
135
|
+
return optional.value();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// pragma MARK: std::optional<Backend>
|
|
139
|
+
/**
|
|
140
|
+
* Specialized version of `std::optional<Backend>`.
|
|
141
|
+
*/
|
|
142
|
+
using std__optional_Backend_ = std::optional<Backend>;
|
|
143
|
+
inline std::optional<Backend> create_std__optional_Backend_(const Backend& value) noexcept {
|
|
144
|
+
return std::optional<Backend>(value);
|
|
145
|
+
}
|
|
146
|
+
inline bool has_value_std__optional_Backend_(const std::optional<Backend>& optional) noexcept {
|
|
147
|
+
return optional.has_value();
|
|
148
|
+
}
|
|
149
|
+
inline Backend get_std__optional_Backend_(const std::optional<Backend>& optional) noexcept {
|
|
150
|
+
return optional.value();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// pragma MARK: std::optional<double>
|
|
154
|
+
/**
|
|
155
|
+
* Specialized version of `std::optional<double>`.
|
|
156
|
+
*/
|
|
157
|
+
using std__optional_double_ = std::optional<double>;
|
|
158
|
+
inline std::optional<double> create_std__optional_double_(const double& value) noexcept {
|
|
159
|
+
return std::optional<double>(value);
|
|
160
|
+
}
|
|
161
|
+
inline bool has_value_std__optional_double_(const std::optional<double>& optional) noexcept {
|
|
162
|
+
return optional.has_value();
|
|
163
|
+
}
|
|
164
|
+
inline double get_std__optional_double_(const std::optional<double>& optional) noexcept {
|
|
165
|
+
return optional.value();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// pragma MARK: std::optional<bool>
|
|
169
|
+
/**
|
|
170
|
+
* Specialized version of `std::optional<bool>`.
|
|
171
|
+
*/
|
|
172
|
+
using std__optional_bool_ = std::optional<bool>;
|
|
173
|
+
inline std::optional<bool> create_std__optional_bool_(const bool& value) noexcept {
|
|
174
|
+
return std::optional<bool>(value);
|
|
175
|
+
}
|
|
176
|
+
inline bool has_value_std__optional_bool_(const std::optional<bool>& optional) noexcept {
|
|
177
|
+
return optional.has_value();
|
|
178
|
+
}
|
|
179
|
+
inline bool get_std__optional_bool_(const std::optional<bool>& optional) noexcept {
|
|
180
|
+
return optional.value();
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// pragma MARK: std::vector<ToolDefinition>
|
|
184
|
+
/**
|
|
185
|
+
* Specialized version of `std::vector<ToolDefinition>`.
|
|
186
|
+
*/
|
|
187
|
+
using std__vector_ToolDefinition_ = std::vector<ToolDefinition>;
|
|
188
|
+
inline std::vector<ToolDefinition> create_std__vector_ToolDefinition_(size_t size) noexcept {
|
|
189
|
+
std::vector<ToolDefinition> vector;
|
|
190
|
+
vector.reserve(size);
|
|
191
|
+
return vector;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// pragma MARK: std::optional<std::vector<ToolDefinition>>
|
|
195
|
+
/**
|
|
196
|
+
* Specialized version of `std::optional<std::vector<ToolDefinition>>`.
|
|
197
|
+
*/
|
|
198
|
+
using std__optional_std__vector_ToolDefinition__ = std::optional<std::vector<ToolDefinition>>;
|
|
199
|
+
inline std::optional<std::vector<ToolDefinition>> create_std__optional_std__vector_ToolDefinition__(const std::vector<ToolDefinition>& value) noexcept {
|
|
200
|
+
return std::optional<std::vector<ToolDefinition>>(value);
|
|
201
|
+
}
|
|
202
|
+
inline bool has_value_std__optional_std__vector_ToolDefinition__(const std::optional<std::vector<ToolDefinition>>& optional) noexcept {
|
|
203
|
+
return optional.has_value();
|
|
204
|
+
}
|
|
205
|
+
inline std::vector<ToolDefinition> get_std__optional_std__vector_ToolDefinition__(const std::optional<std::vector<ToolDefinition>>& optional) noexcept {
|
|
206
|
+
return optional.value();
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// pragma MARK: std::optional<LLMConfig>
|
|
210
|
+
/**
|
|
211
|
+
* Specialized version of `std::optional<LLMConfig>`.
|
|
212
|
+
*/
|
|
213
|
+
using std__optional_LLMConfig_ = std::optional<LLMConfig>;
|
|
214
|
+
inline std::optional<LLMConfig> create_std__optional_LLMConfig_(const LLMConfig& value) noexcept {
|
|
215
|
+
return std::optional<LLMConfig>(value);
|
|
216
|
+
}
|
|
217
|
+
inline bool has_value_std__optional_LLMConfig_(const std::optional<LLMConfig>& optional) noexcept {
|
|
218
|
+
return optional.has_value();
|
|
219
|
+
}
|
|
220
|
+
inline LLMConfig get_std__optional_LLMConfig_(const std::optional<LLMConfig>& optional) noexcept {
|
|
221
|
+
return optional.value();
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// pragma MARK: std::shared_ptr<Promise<std::string>>
|
|
225
|
+
/**
|
|
226
|
+
* Specialized version of `std::shared_ptr<Promise<std::string>>`.
|
|
227
|
+
*/
|
|
228
|
+
using std__shared_ptr_Promise_std__string__ = std::shared_ptr<Promise<std::string>>;
|
|
229
|
+
inline std::shared_ptr<Promise<std::string>> create_std__shared_ptr_Promise_std__string__() noexcept {
|
|
230
|
+
return Promise<std::string>::create();
|
|
231
|
+
}
|
|
232
|
+
inline PromiseHolder<std::string> wrap_std__shared_ptr_Promise_std__string__(std::shared_ptr<Promise<std::string>> promise) noexcept {
|
|
233
|
+
return PromiseHolder<std::string>(std::move(promise));
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// pragma MARK: std::function<void(const std::string& /* result */)>
|
|
237
|
+
/**
|
|
238
|
+
* Specialized version of `std::function<void(const std::string&)>`.
|
|
239
|
+
*/
|
|
240
|
+
using Func_void_std__string = std::function<void(const std::string& /* result */)>;
|
|
241
|
+
/**
|
|
242
|
+
* Wrapper class for a `std::function<void(const std::string& / * result * /)>`, this can be used from Swift.
|
|
243
|
+
*/
|
|
244
|
+
class Func_void_std__string_Wrapper final {
|
|
245
|
+
public:
|
|
246
|
+
explicit Func_void_std__string_Wrapper(std::function<void(const std::string& /* result */)>&& func): _function(std::make_unique<std::function<void(const std::string& /* result */)>>(std::move(func))) {}
|
|
247
|
+
inline void call(std::string result) const noexcept {
|
|
248
|
+
_function->operator()(result);
|
|
249
|
+
}
|
|
250
|
+
private:
|
|
251
|
+
std::unique_ptr<std::function<void(const std::string& /* result */)>> _function;
|
|
252
|
+
} SWIFT_NONCOPYABLE;
|
|
253
|
+
Func_void_std__string create_Func_void_std__string(void* NON_NULL swiftClosureWrapper) noexcept;
|
|
254
|
+
inline Func_void_std__string_Wrapper wrap_Func_void_std__string(Func_void_std__string value) noexcept {
|
|
255
|
+
return Func_void_std__string_Wrapper(std::move(value));
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// pragma MARK: std::function<void(double /* progress */)>
|
|
259
|
+
/**
|
|
260
|
+
* Specialized version of `std::function<void(double)>`.
|
|
261
|
+
*/
|
|
262
|
+
using Func_void_double = std::function<void(double /* progress */)>;
|
|
263
|
+
/**
|
|
264
|
+
* Wrapper class for a `std::function<void(double / * progress * /)>`, this can be used from Swift.
|
|
265
|
+
*/
|
|
266
|
+
class Func_void_double_Wrapper final {
|
|
267
|
+
public:
|
|
268
|
+
explicit Func_void_double_Wrapper(std::function<void(double /* progress */)>&& func): _function(std::make_unique<std::function<void(double /* progress */)>>(std::move(func))) {}
|
|
269
|
+
inline void call(double progress) const noexcept {
|
|
270
|
+
_function->operator()(progress);
|
|
271
|
+
}
|
|
272
|
+
private:
|
|
273
|
+
std::unique_ptr<std::function<void(double /* progress */)>> _function;
|
|
274
|
+
} SWIFT_NONCOPYABLE;
|
|
275
|
+
Func_void_double create_Func_void_double(void* NON_NULL swiftClosureWrapper) noexcept;
|
|
276
|
+
inline Func_void_double_Wrapper wrap_Func_void_double(Func_void_double value) noexcept {
|
|
277
|
+
return Func_void_double_Wrapper(std::move(value));
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// pragma MARK: std::optional<std::function<void(double /* progress */)>>
|
|
281
|
+
/**
|
|
282
|
+
* Specialized version of `std::optional<std::function<void(double / * progress * /)>>`.
|
|
283
|
+
*/
|
|
284
|
+
using std__optional_std__function_void_double____progress______ = std::optional<std::function<void(double /* progress */)>>;
|
|
285
|
+
inline std::optional<std::function<void(double /* progress */)>> create_std__optional_std__function_void_double____progress______(const std::function<void(double /* progress */)>& value) noexcept {
|
|
286
|
+
return std::optional<std::function<void(double /* progress */)>>(value);
|
|
287
|
+
}
|
|
288
|
+
inline bool has_value_std__optional_std__function_void_double____progress______(const std::optional<std::function<void(double /* progress */)>>& optional) noexcept {
|
|
289
|
+
return optional.has_value();
|
|
290
|
+
}
|
|
291
|
+
inline std::function<void(double /* progress */)> get_std__optional_std__function_void_double____progress______(const std::optional<std::function<void(double /* progress */)>>& optional) noexcept {
|
|
292
|
+
return optional.value();
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// pragma MARK: std::optional<std::shared_ptr<ArrayBuffer>>
|
|
296
|
+
/**
|
|
297
|
+
* Specialized version of `std::optional<std::shared_ptr<ArrayBuffer>>`.
|
|
298
|
+
*/
|
|
299
|
+
using std__optional_std__shared_ptr_ArrayBuffer__ = std::optional<std::shared_ptr<ArrayBuffer>>;
|
|
300
|
+
inline std::optional<std::shared_ptr<ArrayBuffer>> create_std__optional_std__shared_ptr_ArrayBuffer__(const std::shared_ptr<ArrayBuffer>& value) noexcept {
|
|
301
|
+
return std::optional<std::shared_ptr<ArrayBuffer>>(value);
|
|
302
|
+
}
|
|
303
|
+
inline bool has_value_std__optional_std__shared_ptr_ArrayBuffer__(const std::optional<std::shared_ptr<ArrayBuffer>>& optional) noexcept {
|
|
304
|
+
return optional.has_value();
|
|
305
|
+
}
|
|
306
|
+
inline std::shared_ptr<ArrayBuffer> get_std__optional_std__shared_ptr_ArrayBuffer__(const std::optional<std::shared_ptr<ArrayBuffer>>& optional) noexcept {
|
|
307
|
+
return optional.value();
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// pragma MARK: std::vector<MultimodalPart>
|
|
311
|
+
/**
|
|
312
|
+
* Specialized version of `std::vector<MultimodalPart>`.
|
|
313
|
+
*/
|
|
314
|
+
using std__vector_MultimodalPart_ = std::vector<MultimodalPart>;
|
|
315
|
+
inline std::vector<MultimodalPart> create_std__vector_MultimodalPart_(size_t size) noexcept {
|
|
316
|
+
std::vector<MultimodalPart> vector;
|
|
317
|
+
vector.reserve(size);
|
|
318
|
+
return vector;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// pragma MARK: std::function<void(const std::string& /* token */, bool /* done */)>
|
|
322
|
+
/**
|
|
323
|
+
* Specialized version of `std::function<void(const std::string&, bool)>`.
|
|
324
|
+
*/
|
|
325
|
+
using Func_void_std__string_bool = std::function<void(const std::string& /* token */, bool /* done */)>;
|
|
326
|
+
/**
|
|
327
|
+
* Wrapper class for a `std::function<void(const std::string& / * token * /, bool / * done * /)>`, this can be used from Swift.
|
|
328
|
+
*/
|
|
329
|
+
class Func_void_std__string_bool_Wrapper final {
|
|
330
|
+
public:
|
|
331
|
+
explicit Func_void_std__string_bool_Wrapper(std::function<void(const std::string& /* token */, bool /* done */)>&& func): _function(std::make_unique<std::function<void(const std::string& /* token */, bool /* done */)>>(std::move(func))) {}
|
|
332
|
+
inline void call(std::string token, bool done) const noexcept {
|
|
333
|
+
_function->operator()(token, done);
|
|
334
|
+
}
|
|
335
|
+
private:
|
|
336
|
+
std::unique_ptr<std::function<void(const std::string& /* token */, bool /* done */)>> _function;
|
|
337
|
+
} SWIFT_NONCOPYABLE;
|
|
338
|
+
Func_void_std__string_bool create_Func_void_std__string_bool(void* NON_NULL swiftClosureWrapper) noexcept;
|
|
339
|
+
inline Func_void_std__string_bool_Wrapper wrap_Func_void_std__string_bool(Func_void_std__string_bool value) noexcept {
|
|
340
|
+
return Func_void_std__string_bool_Wrapper(std::move(value));
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// pragma MARK: std::vector<Message>
|
|
344
|
+
/**
|
|
345
|
+
* Specialized version of `std::vector<Message>`.
|
|
346
|
+
*/
|
|
347
|
+
using std__vector_Message_ = std::vector<Message>;
|
|
348
|
+
inline std::vector<Message> create_std__vector_Message_(size_t size) noexcept {
|
|
349
|
+
std::vector<Message> vector;
|
|
350
|
+
vector.reserve(size);
|
|
351
|
+
return vector;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// pragma MARK: std::shared_ptr<HybridLiteRTLMSpec>
|
|
355
|
+
/**
|
|
356
|
+
* Specialized version of `std::shared_ptr<HybridLiteRTLMSpec>`.
|
|
357
|
+
*/
|
|
358
|
+
using std__shared_ptr_HybridLiteRTLMSpec_ = std::shared_ptr<HybridLiteRTLMSpec>;
|
|
359
|
+
std::shared_ptr<HybridLiteRTLMSpec> create_std__shared_ptr_HybridLiteRTLMSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
|
|
360
|
+
void* NON_NULL get_std__shared_ptr_HybridLiteRTLMSpec_(std__shared_ptr_HybridLiteRTLMSpec_ cppType);
|
|
361
|
+
|
|
362
|
+
// pragma MARK: std::weak_ptr<HybridLiteRTLMSpec>
|
|
363
|
+
using std__weak_ptr_HybridLiteRTLMSpec_ = std::weak_ptr<HybridLiteRTLMSpec>;
|
|
364
|
+
inline std__weak_ptr_HybridLiteRTLMSpec_ weakify_std__shared_ptr_HybridLiteRTLMSpec_(const std::shared_ptr<HybridLiteRTLMSpec>& strong) noexcept { return strong; }
|
|
365
|
+
|
|
366
|
+
// pragma MARK: Result<std::shared_ptr<Promise<void>>>
|
|
367
|
+
using Result_std__shared_ptr_Promise_void___ = Result<std::shared_ptr<Promise<void>>>;
|
|
368
|
+
inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::shared_ptr<Promise<void>>& value) noexcept {
|
|
369
|
+
return Result<std::shared_ptr<Promise<void>>>::withValue(value);
|
|
370
|
+
}
|
|
371
|
+
inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::exception_ptr& error) noexcept {
|
|
372
|
+
return Result<std::shared_ptr<Promise<void>>>::withError(error);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// pragma MARK: Result<std::shared_ptr<Promise<std::string>>>
|
|
376
|
+
using Result_std__shared_ptr_Promise_std__string___ = Result<std::shared_ptr<Promise<std::string>>>;
|
|
377
|
+
inline Result_std__shared_ptr_Promise_std__string___ create_Result_std__shared_ptr_Promise_std__string___(const std::shared_ptr<Promise<std::string>>& value) noexcept {
|
|
378
|
+
return Result<std::shared_ptr<Promise<std::string>>>::withValue(value);
|
|
379
|
+
}
|
|
380
|
+
inline Result_std__shared_ptr_Promise_std__string___ create_Result_std__shared_ptr_Promise_std__string___(const std::exception_ptr& error) noexcept {
|
|
381
|
+
return Result<std::shared_ptr<Promise<std::string>>>::withError(error);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// pragma MARK: Result<std::vector<Message>>
|
|
385
|
+
using Result_std__vector_Message__ = Result<std::vector<Message>>;
|
|
386
|
+
inline Result_std__vector_Message__ create_Result_std__vector_Message__(const std::vector<Message>& value) noexcept {
|
|
387
|
+
return Result<std::vector<Message>>::withValue(value);
|
|
388
|
+
}
|
|
389
|
+
inline Result_std__vector_Message__ create_Result_std__vector_Message__(const std::exception_ptr& error) noexcept {
|
|
390
|
+
return Result<std::vector<Message>>::withError(error);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// pragma MARK: Result<void>
|
|
394
|
+
using Result_void_ = Result<void>;
|
|
395
|
+
inline Result_void_ create_Result_void_() noexcept {
|
|
396
|
+
return Result<void>::withValue();
|
|
397
|
+
}
|
|
398
|
+
inline Result_void_ create_Result_void_(const std::exception_ptr& error) noexcept {
|
|
399
|
+
return Result<void>::withError(error);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// pragma MARK: Result<bool>
|
|
403
|
+
using Result_bool_ = Result<bool>;
|
|
404
|
+
inline Result_bool_ create_Result_bool_(bool value) noexcept {
|
|
405
|
+
return Result<bool>::withValue(std::move(value));
|
|
406
|
+
}
|
|
407
|
+
inline Result_bool_ create_Result_bool_(const std::exception_ptr& error) noexcept {
|
|
408
|
+
return Result<bool>::withError(error);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// pragma MARK: Result<GenerationStats>
|
|
412
|
+
using Result_GenerationStats_ = Result<GenerationStats>;
|
|
413
|
+
inline Result_GenerationStats_ create_Result_GenerationStats_(const GenerationStats& value) noexcept {
|
|
414
|
+
return Result<GenerationStats>::withValue(value);
|
|
415
|
+
}
|
|
416
|
+
inline Result_GenerationStats_ create_Result_GenerationStats_(const std::exception_ptr& error) noexcept {
|
|
417
|
+
return Result<GenerationStats>::withError(error);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// pragma MARK: Result<double>
|
|
421
|
+
using Result_double_ = Result<double>;
|
|
422
|
+
inline Result_double_ create_Result_double_(double value) noexcept {
|
|
423
|
+
return Result<double>::withValue(std::move(value));
|
|
424
|
+
}
|
|
425
|
+
inline Result_double_ create_Result_double_(const std::exception_ptr& error) noexcept {
|
|
426
|
+
return Result<double>::withError(error);
|
|
427
|
+
}
|
|
25
428
|
|
|
429
|
+
// pragma MARK: Result<MemoryUsage>
|
|
430
|
+
using Result_MemoryUsage_ = Result<MemoryUsage>;
|
|
431
|
+
inline Result_MemoryUsage_ create_Result_MemoryUsage_(const MemoryUsage& value) noexcept {
|
|
432
|
+
return Result<MemoryUsage>::withValue(value);
|
|
433
|
+
}
|
|
434
|
+
inline Result_MemoryUsage_ create_Result_MemoryUsage_(const std::exception_ptr& error) noexcept {
|
|
435
|
+
return Result<MemoryUsage>::withError(error);
|
|
436
|
+
}
|
|
26
437
|
|
|
27
438
|
} // namespace margelo::nitro::litertlm::bridge::swift
|
|
@@ -8,10 +8,47 @@
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
10
|
// Forward declarations of C++ defined types
|
|
11
|
-
|
|
11
|
+
// Forward declaration of `Backend` to properly resolve imports.
|
|
12
|
+
namespace margelo::nitro::litertlm { enum class Backend; }
|
|
13
|
+
// Forward declaration of `GenerationStats` to properly resolve imports.
|
|
14
|
+
namespace margelo::nitro::litertlm { struct GenerationStats; }
|
|
15
|
+
// Forward declaration of `HybridLiteRTLMSpec` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::litertlm { class HybridLiteRTLMSpec; }
|
|
17
|
+
// Forward declaration of `LLMConfig` to properly resolve imports.
|
|
18
|
+
namespace margelo::nitro::litertlm { struct LLMConfig; }
|
|
19
|
+
// Forward declaration of `MemoryUsage` to properly resolve imports.
|
|
20
|
+
namespace margelo::nitro::litertlm { struct MemoryUsage; }
|
|
21
|
+
// Forward declaration of `Message` to properly resolve imports.
|
|
22
|
+
namespace margelo::nitro::litertlm { struct Message; }
|
|
23
|
+
// Forward declaration of `MultimodalPart` to properly resolve imports.
|
|
24
|
+
namespace margelo::nitro::litertlm { struct MultimodalPart; }
|
|
25
|
+
// Forward declaration of `PartType` to properly resolve imports.
|
|
26
|
+
namespace margelo::nitro::litertlm { enum class PartType; }
|
|
27
|
+
// Forward declaration of `Role` to properly resolve imports.
|
|
28
|
+
namespace margelo::nitro::litertlm { enum class Role; }
|
|
29
|
+
// Forward declaration of `ToolDefinition` to properly resolve imports.
|
|
30
|
+
namespace margelo::nitro::litertlm { struct ToolDefinition; }
|
|
12
31
|
|
|
13
32
|
// Include C++ defined types
|
|
14
|
-
|
|
33
|
+
#include "Backend.hpp"
|
|
34
|
+
#include "GenerationStats.hpp"
|
|
35
|
+
#include "HybridLiteRTLMSpec.hpp"
|
|
36
|
+
#include "LLMConfig.hpp"
|
|
37
|
+
#include "MemoryUsage.hpp"
|
|
38
|
+
#include "Message.hpp"
|
|
39
|
+
#include "MultimodalPart.hpp"
|
|
40
|
+
#include "PartType.hpp"
|
|
41
|
+
#include "Role.hpp"
|
|
42
|
+
#include "ToolDefinition.hpp"
|
|
43
|
+
#include <NitroModules/ArrayBuffer.hpp>
|
|
44
|
+
#include <NitroModules/Promise.hpp>
|
|
45
|
+
#include <NitroModules/Result.hpp>
|
|
46
|
+
#include <exception>
|
|
47
|
+
#include <functional>
|
|
48
|
+
#include <memory>
|
|
49
|
+
#include <optional>
|
|
50
|
+
#include <string>
|
|
51
|
+
#include <vector>
|
|
15
52
|
|
|
16
53
|
// C++ helpers for Swift
|
|
17
54
|
#include "LiteRTLM-Swift-Cxx-Bridge.hpp"
|
|
@@ -23,7 +60,8 @@
|
|
|
23
60
|
#include <NitroModules/DateToChronoDate.hpp>
|
|
24
61
|
|
|
25
62
|
// Forward declarations of Swift defined types
|
|
26
|
-
|
|
63
|
+
// Forward declaration of `HybridLiteRTLMSpec_cxx` to properly resolve imports.
|
|
64
|
+
namespace LiteRTLM { class HybridLiteRTLMSpec_cxx; }
|
|
27
65
|
|
|
28
66
|
// Include Swift defined types
|
|
29
67
|
#if __has_include("LiteRTLM-Swift.h")
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
#import <Foundation/Foundation.h>
|
|
9
9
|
#import <NitroModules/HybridObjectRegistry.hpp>
|
|
10
|
-
|
|
10
|
+
#import "LiteRTLM-Swift-Cxx-Umbrella.hpp"
|
|
11
11
|
#import <type_traits>
|
|
12
12
|
|
|
13
|
-
#include "
|
|
13
|
+
#include "HybridLiteRTLMSpecSwift.hpp"
|
|
14
14
|
|
|
15
15
|
@interface LiteRTLMAutolinking : NSObject
|
|
16
16
|
@end
|
|
@@ -24,10 +24,8 @@
|
|
|
24
24
|
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
25
25
|
"LiteRTLM",
|
|
26
26
|
[]() -> std::shared_ptr<HybridObject> {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"Create a public constructor that takes zero arguments to be able to autolink this HybridObject.");
|
|
30
|
-
return std::make_shared<HybridLiteRTLM>();
|
|
27
|
+
std::shared_ptr<HybridLiteRTLMSpec> hybridObject = LiteRTLM::LiteRTLMAutolinking::createLiteRTLM();
|
|
28
|
+
return hybridObject;
|
|
31
29
|
}
|
|
32
30
|
);
|
|
33
31
|
}
|
|
@@ -12,5 +12,15 @@ import NitroModules
|
|
|
12
12
|
public final class LiteRTLMAutolinking {
|
|
13
13
|
public typealias bridge = margelo.nitro.litertlm.bridge.swift
|
|
14
14
|
|
|
15
|
+
public static func createLiteRTLM() -> bridge.std__shared_ptr_HybridLiteRTLMSpec_ {
|
|
16
|
+
let hybridObject = HybridLiteRTLM()
|
|
17
|
+
return { () -> bridge.std__shared_ptr_HybridLiteRTLMSpec_ in
|
|
18
|
+
let __cxxWrapped = hybridObject.getCxxWrapper()
|
|
19
|
+
return __cxxWrapped.getCxxPart()
|
|
20
|
+
}()
|
|
21
|
+
}
|
|
15
22
|
|
|
23
|
+
public static func isLiteRTLMRecyclable() -> Bool {
|
|
24
|
+
return HybridLiteRTLM.self is any RecyclableView.Type
|
|
25
|
+
}
|
|
16
26
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridLiteRTLMSpecSwift.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridLiteRTLMSpecSwift.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::litertlm {
|
|
11
|
+
} // namespace margelo::nitro::litertlm
|