@ariacompute/engine-ts 1.6.2 → 1.6.3
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/dist/index.js +9 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -175,9 +175,9 @@ class Engine {
|
|
|
175
175
|
this.lib = loadLib(opts.ffiLib);
|
|
176
176
|
this.fnInit = this.lib.func("aria_model_init", "void*", ["str"]);
|
|
177
177
|
this.fnDestroy = this.lib.func("aria_model_destroy", "void", ["void*"]);
|
|
178
|
-
this.fnComplete = this.lib.func("aria_complete", "int", ["void*", "str", "str", "str", "
|
|
179
|
-
this.fnEmbed = this.lib.func("aria_embed", "int", ["void*", "str", "
|
|
180
|
-
this.fnTranscribe = this.lib.func("aria_transcribe", "int", ["void*", "void*", "size_t", "str", "
|
|
178
|
+
this.fnComplete = this.lib.func("aria_complete", "int", ["void*", "str", "str", "str", "void*", "size_t"]);
|
|
179
|
+
this.fnEmbed = this.lib.func("aria_embed", "int", ["void*", "str", "void*", "size_t"]);
|
|
180
|
+
this.fnTranscribe = this.lib.func("aria_transcribe", "int", ["void*", "void*", "size_t", "str", "void*", "size_t"]);
|
|
181
181
|
this.fnLastError = this.lib.func("aria_last_error", "str", []);
|
|
182
182
|
this.handle = this.fnInit(bundle);
|
|
183
183
|
if (!this.handle) {
|
|
@@ -198,9 +198,11 @@ class Engine {
|
|
|
198
198
|
return new Engine(bundle, opts);
|
|
199
199
|
}
|
|
200
200
|
complete(messages, opts = {}) {
|
|
201
|
-
const
|
|
201
|
+
const messagesJson = JSON.stringify(messages);
|
|
202
|
+
const optionsJson = JSON.stringify(opts || { max_tokens: 16 });
|
|
203
|
+
const toolsJson = JSON.stringify([]);
|
|
202
204
|
const buf = Buffer.alloc(1 << 16);
|
|
203
|
-
const rc = this.fnComplete(this.handle,
|
|
205
|
+
const rc = this.fnComplete(this.handle, messagesJson, optionsJson, toolsJson, buf, buf.length);
|
|
204
206
|
if (rc !== 0) {
|
|
205
207
|
const err = this.fnLastError();
|
|
206
208
|
return { success: false, response: "", error: err || "complete failed" };
|
|
@@ -215,7 +217,7 @@ class Engine {
|
|
|
215
217
|
}
|
|
216
218
|
embed(text) {
|
|
217
219
|
const buf = Buffer.alloc(1 << 20);
|
|
218
|
-
const rc = this.fnEmbed(this.handle, text, buf, buf.length);
|
|
220
|
+
const rc = this.fnEmbed(this.handle, JSON.stringify({ input: text }), buf, buf.length);
|
|
219
221
|
if (rc !== 0) {
|
|
220
222
|
const err = this.fnLastError();
|
|
221
223
|
throw new Error(err || "embed failed");
|
|
@@ -224,7 +226,7 @@ class Engine {
|
|
|
224
226
|
}
|
|
225
227
|
transcribe(pcm) {
|
|
226
228
|
const buf = Buffer.alloc(1 << 16);
|
|
227
|
-
const rc = this.fnTranscribe(this.handle, pcm, pcm.length,
|
|
229
|
+
const rc = this.fnTranscribe(this.handle, Buffer.from(pcm), pcm.length, null, buf, buf.length);
|
|
228
230
|
if (rc !== 0) {
|
|
229
231
|
const err = this.fnLastError();
|
|
230
232
|
throw new Error(err || "transcribe failed");
|