@dbx-tools/model-rs 0.6.221
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/LICENSE +202 -0
- package/README.md +33 -0
- package/index.ts +7 -0
- package/lib/index.js +548 -0
- package/package.json +47 -0
- package/src/_bindings-ffi.ts +432 -0
- package/src/_bindings.ts +284 -0
- package/src/bindings.ts +11 -0
package/src/_bindings.ts
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
// GENERATED by UniFFI binding generation - DO NOT EDIT.
|
|
2
|
+
// Regenerated from the dbx-tools-model Rust exports.
|
|
3
|
+
// Hand edits are overwritten on the next watch; this file is read-only.
|
|
4
|
+
|
|
5
|
+
/* eslint-disable */
|
|
6
|
+
// @ts-nocheck
|
|
7
|
+
// This file was autogenerated by some hot garbage in the `uniffi-bindgen-react-native` crate.
|
|
8
|
+
// Trust me, you don't want to mess with it!
|
|
9
|
+
import nativeModule from "./_bindings-ffi.ts";
|
|
10
|
+
import { type UniffiRustFutureContinuationCallback, type UniffiForeignFutureDroppedCallback, type UniffiForeignFutureDroppedCallbackStruct,
|
|
11
|
+
} from "./_bindings-ffi.ts";
|
|
12
|
+
import { type UniffiByteArray, AbstractFfiConverterByteArray, Cursor, FfiConverterArray, FfiConverterBool, FfiConverterOptional, FfiConverterUInt8, RustBuffer, UniffiEnum, UniffiInternalError, UniffiRustCaller, uniffiCreateFfiConverterString,
|
|
13
|
+
} from "@ubjs/core";
|
|
14
|
+
const uniffiCaller = new UniffiRustCaller(() => ({ code: 0 }));
|
|
15
|
+
|
|
16
|
+
const uniffiIsDebug =
|
|
17
|
+
// @ts-ignore -- The process global might not be defined
|
|
18
|
+
typeof process !== "object" ||
|
|
19
|
+
// @ts-ignore -- The process global might not be defined
|
|
20
|
+
process?.env?.NODE_ENV !== "production" ||
|
|
21
|
+
false;
|
|
22
|
+
|
|
23
|
+
// Public interface members begin here.
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Return the Chat Completions effort required when function tools are present.
|
|
27
|
+
*/
|
|
28
|
+
export function chatToolReasoningEffort(name: string): ReasoningEffort | undefined {
|
|
29
|
+
const __rb: Uint8Array = uniffiCaller.rustCall(
|
|
30
|
+
/*caller:*/ (callStatus) => {
|
|
31
|
+
return nativeModule().uniffi_dbx_tools_model_fn_func_chat_tool_reasoning_effort(
|
|
32
|
+
FfiConverterString.lower(name, nativeModule().rustbuffer_alloc),
|
|
33
|
+
callStatus);
|
|
34
|
+
},
|
|
35
|
+
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
|
|
36
|
+
);
|
|
37
|
+
try {
|
|
38
|
+
return FfiConverterOptionalTypeReasoningEffort.lift(__rb);
|
|
39
|
+
} finally {
|
|
40
|
+
nativeModule().rustbuffer_free(__rb);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Return whether a model requires Databricks' native Responses endpoint.
|
|
46
|
+
*/
|
|
47
|
+
export function isResponsesOnly(value: string): boolean {
|
|
48
|
+
return FfiConverterBool.lift(uniffiCaller.rustCall(
|
|
49
|
+
/*caller:*/ (callStatus) => {
|
|
50
|
+
return nativeModule().uniffi_dbx_tools_model_fn_func_is_responses_only(
|
|
51
|
+
FfiConverterString.lower(value, nativeModule().rustbuffer_alloc),
|
|
52
|
+
callStatus);
|
|
53
|
+
},
|
|
54
|
+
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
|
|
55
|
+
));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Return the Databricks inference protocol required by a model.
|
|
60
|
+
*/
|
|
61
|
+
export function modelServingApi(value: string): ModelServingApi {
|
|
62
|
+
const __rb: Uint8Array = uniffiCaller.rustCall(
|
|
63
|
+
/*caller:*/ (callStatus) => {
|
|
64
|
+
return nativeModule().uniffi_dbx_tools_model_fn_func_model_serving_api(
|
|
65
|
+
FfiConverterString.lower(value, nativeModule().rustbuffer_alloc),
|
|
66
|
+
callStatus);
|
|
67
|
+
},
|
|
68
|
+
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
|
|
69
|
+
);
|
|
70
|
+
try {
|
|
71
|
+
return FfiConverterTypeModelServingApi.lift(__rb);
|
|
72
|
+
} finally {
|
|
73
|
+
nativeModule().rustbuffer_free(__rb);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Infer the accepted reasoning efforts from a model or service name.
|
|
79
|
+
*/
|
|
80
|
+
export function reasoningEffortsByFamily(name: string): Array<ReasoningEffort> {
|
|
81
|
+
const __rb: Uint8Array = uniffiCaller.rustCall(
|
|
82
|
+
/*caller:*/ (callStatus) => {
|
|
83
|
+
return nativeModule().uniffi_dbx_tools_model_fn_func_reasoning_efforts_by_family(
|
|
84
|
+
FfiConverterString.lower(name, nativeModule().rustbuffer_alloc),
|
|
85
|
+
callStatus);
|
|
86
|
+
},
|
|
87
|
+
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
|
|
88
|
+
);
|
|
89
|
+
try {
|
|
90
|
+
return FfiConverterSequenceTypeReasoningEffort.lift(__rb);
|
|
91
|
+
} finally {
|
|
92
|
+
nativeModule().rustbuffer_free(__rb);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Infer whether a model family supports a complete tool-calling round trip.
|
|
98
|
+
*/
|
|
99
|
+
export function supportsToolsByFamily(name: string): boolean {
|
|
100
|
+
return FfiConverterBool.lift(uniffiCaller.rustCall(
|
|
101
|
+
/*caller:*/ (callStatus) => {
|
|
102
|
+
return nativeModule().uniffi_dbx_tools_model_fn_func_supports_tools_by_family(
|
|
103
|
+
FfiConverterString.lower(name, nativeModule().rustbuffer_alloc),
|
|
104
|
+
callStatus);
|
|
105
|
+
},
|
|
106
|
+
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
|
|
107
|
+
));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Databricks inference protocol selected for a model.
|
|
112
|
+
*/
|
|
113
|
+
export enum ModelServingApi {
|
|
114
|
+
/**
|
|
115
|
+
* OpenAI-compatible Chat Completions.
|
|
116
|
+
*/
|
|
117
|
+
Chat,
|
|
118
|
+
/**
|
|
119
|
+
* Native OpenAI Responses.
|
|
120
|
+
*/
|
|
121
|
+
Responses
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const FfiConverterTypeModelServingApi = (() => {
|
|
125
|
+
type TypeName = ModelServingApi;
|
|
126
|
+
class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
127
|
+
readFromCursor(c: Cursor): TypeName {
|
|
128
|
+
switch (c.readI32()) {
|
|
129
|
+
case 1: return ModelServingApi.Chat;
|
|
130
|
+
case 2: return ModelServingApi.Responses;
|
|
131
|
+
default: throw new UniffiInternalError.UnexpectedEnumCase();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
writeIntoCursor(value: TypeName, c: Cursor): void {
|
|
135
|
+
switch (value) {
|
|
136
|
+
case ModelServingApi.Chat: return c.writeI32(1);
|
|
137
|
+
case ModelServingApi.Responses: return c.writeI32(2);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
allocationSize(value: TypeName): number {
|
|
141
|
+
return 4;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return new FFIConverter();
|
|
145
|
+
})();
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Reasoning effort accepted by a model endpoint.
|
|
149
|
+
*/
|
|
150
|
+
export enum ReasoningEffort {
|
|
151
|
+
/**
|
|
152
|
+
* Disable explicit reasoning.
|
|
153
|
+
*/
|
|
154
|
+
None,
|
|
155
|
+
/**
|
|
156
|
+
* Use the smallest available reasoning budget.
|
|
157
|
+
*/
|
|
158
|
+
Minimal,
|
|
159
|
+
/**
|
|
160
|
+
* Use a low reasoning budget.
|
|
161
|
+
*/
|
|
162
|
+
Low,
|
|
163
|
+
/**
|
|
164
|
+
* Use a medium reasoning budget.
|
|
165
|
+
*/
|
|
166
|
+
Medium,
|
|
167
|
+
/**
|
|
168
|
+
* Use a high reasoning budget.
|
|
169
|
+
*/
|
|
170
|
+
High,
|
|
171
|
+
/**
|
|
172
|
+
* Use an extra-high reasoning budget.
|
|
173
|
+
*/
|
|
174
|
+
Xhigh,
|
|
175
|
+
/**
|
|
176
|
+
* Use the largest available reasoning budget.
|
|
177
|
+
*/
|
|
178
|
+
Max
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const FfiConverterTypeReasoningEffort = (() => {
|
|
182
|
+
type TypeName = ReasoningEffort;
|
|
183
|
+
class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
184
|
+
readFromCursor(c: Cursor): TypeName {
|
|
185
|
+
switch (c.readI32()) {
|
|
186
|
+
case 1: return ReasoningEffort.None;
|
|
187
|
+
case 2: return ReasoningEffort.Minimal;
|
|
188
|
+
case 3: return ReasoningEffort.Low;
|
|
189
|
+
case 4: return ReasoningEffort.Medium;
|
|
190
|
+
case 5: return ReasoningEffort.High;
|
|
191
|
+
case 6: return ReasoningEffort.Xhigh;
|
|
192
|
+
case 7: return ReasoningEffort.Max;
|
|
193
|
+
default: throw new UniffiInternalError.UnexpectedEnumCase();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
writeIntoCursor(value: TypeName, c: Cursor): void {
|
|
197
|
+
switch (value) {
|
|
198
|
+
case ReasoningEffort.None: return c.writeI32(1);
|
|
199
|
+
case ReasoningEffort.Minimal: return c.writeI32(2);
|
|
200
|
+
case ReasoningEffort.Low: return c.writeI32(3);
|
|
201
|
+
case ReasoningEffort.Medium: return c.writeI32(4);
|
|
202
|
+
case ReasoningEffort.High: return c.writeI32(5);
|
|
203
|
+
case ReasoningEffort.Xhigh: return c.writeI32(6);
|
|
204
|
+
case ReasoningEffort.Max: return c.writeI32(7);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
allocationSize(value: TypeName): number {
|
|
208
|
+
return 4;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return new FFIConverter();
|
|
212
|
+
})();
|
|
213
|
+
|
|
214
|
+
const stringConverter = (() => {
|
|
215
|
+
const encoder = new TextEncoder();
|
|
216
|
+
const decoder = new TextDecoder();
|
|
217
|
+
return {
|
|
218
|
+
stringToBytes: (s: string) => encoder.encode(s),
|
|
219
|
+
bytesToString: (ab: UniffiByteArray) => decoder.decode(ab),
|
|
220
|
+
stringByteLength: (s: string) => encoder.encode(s).byteLength,
|
|
221
|
+
writeStringIntoBuffer: (s: string, buf: any, offset: number): number => {
|
|
222
|
+
const view = new Uint8Array(
|
|
223
|
+
buf.arrayBuffer,
|
|
224
|
+
offset,
|
|
225
|
+
buf.arrayBuffer.byteLength - offset,
|
|
226
|
+
);
|
|
227
|
+
return encoder.encodeInto(s, view).written;
|
|
228
|
+
},
|
|
229
|
+
readStringFromBuffer: (buf: any, offset: number, length: number): string =>
|
|
230
|
+
decoder.decode(new Uint8Array(buf.arrayBuffer, offset, length)),
|
|
231
|
+
};
|
|
232
|
+
})();
|
|
233
|
+
const FfiConverterString = uniffiCreateFfiConverterString(stringConverter);
|
|
234
|
+
|
|
235
|
+
// FfiConverter for ReasoningEffort | undefined
|
|
236
|
+
const FfiConverterOptionalTypeReasoningEffort = new FfiConverterOptional(FfiConverterTypeReasoningEffort);
|
|
237
|
+
|
|
238
|
+
// FfiConverter for Array<ReasoningEffort>
|
|
239
|
+
const FfiConverterSequenceTypeReasoningEffort = new FfiConverterArray(FfiConverterTypeReasoningEffort);
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* This should be called before anything else.
|
|
244
|
+
*
|
|
245
|
+
* It is likely that this is being done for you by the library's `index.ts`.
|
|
246
|
+
*
|
|
247
|
+
* It checks versions of uniffi between when the Rust scaffolding was generated
|
|
248
|
+
* and when the bindings were generated.
|
|
249
|
+
*
|
|
250
|
+
* It also initializes the machinery to enable Rust to talk back to Javascript.
|
|
251
|
+
*/
|
|
252
|
+
function uniffiEnsureInitialized() {
|
|
253
|
+
// Get the bindings contract version from our ComponentInterface
|
|
254
|
+
const bindingsContractVersion = 30;
|
|
255
|
+
// Get the scaffolding contract version by calling the into the dylib
|
|
256
|
+
const scaffoldingContractVersion = nativeModule().ffi_dbx_tools_model_uniffi_contract_version();
|
|
257
|
+
if (bindingsContractVersion !== scaffoldingContractVersion) {
|
|
258
|
+
throw new UniffiInternalError.ContractVersionMismatch(scaffoldingContractVersion, bindingsContractVersion);
|
|
259
|
+
}
|
|
260
|
+
if (nativeModule().uniffi_dbx_tools_model_checksum_func_chat_tool_reasoning_effort() !== 31707) {
|
|
261
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_model_checksum_func_chat_tool_reasoning_effort");
|
|
262
|
+
}
|
|
263
|
+
if (nativeModule().uniffi_dbx_tools_model_checksum_func_is_responses_only() !== 5794) {
|
|
264
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_model_checksum_func_is_responses_only");
|
|
265
|
+
}
|
|
266
|
+
if (nativeModule().uniffi_dbx_tools_model_checksum_func_model_serving_api() !== 54338) {
|
|
267
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_model_checksum_func_model_serving_api");
|
|
268
|
+
}
|
|
269
|
+
if (nativeModule().uniffi_dbx_tools_model_checksum_func_reasoning_efforts_by_family() !== 49390) {
|
|
270
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_model_checksum_func_reasoning_efforts_by_family");
|
|
271
|
+
}
|
|
272
|
+
if (nativeModule().uniffi_dbx_tools_model_checksum_func_supports_tools_by_family() !== 34147) {
|
|
273
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_model_checksum_func_supports_tools_by_family");
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export default Object.freeze({
|
|
279
|
+
initialize: uniffiEnsureInitialized,
|
|
280
|
+
converters: {
|
|
281
|
+
FfiConverterTypeModelServingApi,
|
|
282
|
+
FfiConverterTypeReasoningEffort,
|
|
283
|
+
}
|
|
284
|
+
});
|
package/src/bindings.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// GENERATED by UniFFI binding generation - DO NOT EDIT.
|
|
2
|
+
// Regenerated from the dbx-tools-model Rust exports.
|
|
3
|
+
// Hand edits are overwritten on the next watch; this file is read-only.
|
|
4
|
+
|
|
5
|
+
/* eslint-disable */
|
|
6
|
+
// @ts-nocheck
|
|
7
|
+
export * from './_bindings.ts';
|
|
8
|
+
import uniffiModule from './_bindings.ts';
|
|
9
|
+
uniffiModule.initialize();
|
|
10
|
+
export { uniffiModule };
|
|
11
|
+
export async function uniffiInitAsync() {}
|