UNPKG

@0xplaygrounds/rig-wasm

Version:

A TS and WebAssembly-based port of the Rust agentic AI framework Rig.

1,594 lines (1,456 loc) 159 kB
'use strict'; var util = require('util'); var path = require('node:path'); var fs = require('node:fs'); var process = require('node:process'); var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null; function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { if (k !== 'default') { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, get: function () { return e[k]; } }); } }); } n.default = e; return Object.freeze(n); } var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path); var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs); var process__namespace = /*#__PURE__*/_interopNamespaceDefault(process); let wasm$1; function __wbg_set_wasm(exports, module) { wasm$1 = exports; } let WASM_VECTOR_LEN = 0; let cachedUint8ArrayMemory0 = null; function getUint8ArrayMemory0() { if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) { cachedUint8ArrayMemory0 = new Uint8Array(wasm$1.memory.buffer); } return cachedUint8ArrayMemory0; } let cachedTextEncoder = new util.TextEncoder('utf-8'); const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' ? function (arg, view) { return cachedTextEncoder.encodeInto(arg, view); } : function (arg, view) { const buf = cachedTextEncoder.encode(arg); view.set(buf); return { read: arg.length, written: buf.length }; }); function passStringToWasm0(arg, malloc, realloc) { if (realloc === undefined) { const buf = cachedTextEncoder.encode(arg); const ptr = malloc(buf.length, 1) >>> 0; getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf); WASM_VECTOR_LEN = buf.length; return ptr; } let len = arg.length; let ptr = malloc(len, 1) >>> 0; const mem = getUint8ArrayMemory0(); let offset = 0; for (; offset < len; offset++) { const code = arg.charCodeAt(offset); if (code > 0x7F) break; mem[ptr + offset] = code; } if (offset !== len) { if (offset !== 0) { arg = arg.slice(offset); } ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len); const ret = encodeString(arg, view); offset += ret.written; ptr = realloc(ptr, len, offset, 1) >>> 0; } WASM_VECTOR_LEN = offset; return ptr; } let cachedDataViewMemory0 = null; function getDataViewMemory0() { if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm$1.memory.buffer)) { cachedDataViewMemory0 = new DataView(wasm$1.memory.buffer); } return cachedDataViewMemory0; } let cachedTextDecoder = new util.TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); cachedTextDecoder.decode(); function getStringFromWasm0(ptr, len) { ptr = ptr >>> 0; return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len)); } function addToExternrefTable0(obj) { const idx = wasm$1.__externref_table_alloc(); wasm$1.__wbindgen_export_4.set(idx, obj); return idx; } function handleError(f, args) { try { return f.apply(this, args); } catch (e) { const idx = addToExternrefTable0(e); wasm$1.__wbindgen_exn_store(idx); } } function isLikeNone(x) { return x === undefined || x === null; } const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(state => { wasm$1.__wbindgen_export_6.get(state.dtor)(state.a, state.b); }); function makeMutClosure(arg0, arg1, dtor, f) { const state = { a: arg0, b: arg1, cnt: 1, dtor }; const real = (...args) => { // First up with a closure we increment the internal reference // count. This ensures that the Rust closure environment won't // be deallocated while we're invoking it. state.cnt++; const a = state.a; state.a = 0; try { return f(a, state.b, ...args); } finally { if (--state.cnt === 0) { wasm$1.__wbindgen_export_6.get(state.dtor)(a, state.b); CLOSURE_DTORS.unregister(state); } else { state.a = a; } } }; real.original = state; CLOSURE_DTORS.register(real, state, state); return real; } function debugString(val) { // primitive types const type = typeof val; if (type == 'number' || type == 'boolean' || val == null) { return `${val}`; } if (type == 'string') { return `"${val}"`; } if (type == 'symbol') { const description = val.description; if (description == null) { return 'Symbol'; } else { return `Symbol(${description})`; } } if (type == 'function') { const name = val.name; if (typeof name == 'string' && name.length > 0) { return `Function(${name})`; } else { return 'Function'; } } // objects if (Array.isArray(val)) { const length = val.length; let debug = '['; if (length > 0) { debug += debugString(val[0]); } for(let i = 1; i < length; i++) { debug += ', ' + debugString(val[i]); } debug += ']'; return debug; } // Test for built-in const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); let className; if (builtInMatches && builtInMatches.length > 1) { className = builtInMatches[1]; } else { // Failed to match the standard '[object ClassName]' return toString.call(val); } if (className == 'Object') { // we're a user defined class or Object // JSON.stringify avoids problems with cycles, and is generally much // easier than looping through ownProperties of `val`. try { return 'Object(' + JSON.stringify(val) + ')'; } catch (_) { return 'Object'; } } // errors if (val instanceof Error) { return `${val.name}: ${val.message}\n${val.stack}`; } // TODO we could test for more things here, like `Set`s and `Map`s. return className; } function takeFromExternrefTable0(idx) { const value = wasm$1.__wbindgen_export_4.get(idx); wasm$1.__externref_table_dealloc(idx); return value; } function passArrayJsValueToWasm0(array, malloc) { const ptr = malloc(array.length * 4, 4) >>> 0; for (let i = 0; i < array.length; i++) { const add = addToExternrefTable0(array[i]); getDataViewMemory0().setUint32(ptr + 4 * i, add, true); } WASM_VECTOR_LEN = array.length; return ptr; } function _assertClass(instance, klass) { if (!(instance instanceof klass)) { throw new Error(`expected instance of ${klass.name}`); } } let cachedFloat64ArrayMemory0 = null; function getFloat64ArrayMemory0() { if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) { cachedFloat64ArrayMemory0 = new Float64Array(wasm$1.memory.buffer); } return cachedFloat64ArrayMemory0; } function passArrayF64ToWasm0(arg, malloc) { const ptr = malloc(arg.length * 8, 8) >>> 0; getFloat64ArrayMemory0().set(arg, ptr / 8); WASM_VECTOR_LEN = arg.length; return ptr; } function getArrayF64FromWasm0(ptr, len) { ptr = ptr >>> 0; return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len); } function initPanicHook() { wasm$1.initPanicHook(); } function __wbg_adapter_62(arg0, arg1, arg2) { wasm$1.closure111_externref_shim(arg0, arg1, arg2); } function __wbg_adapter_65(arg0, arg1) { wasm$1._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h840edcdc529e167f(arg0, arg1); } function __wbg_adapter_120(arg0, arg1, arg2, arg3) { wasm$1.closure52_externref_shim(arg0, arg1, arg2, arg3); } /** * Configuration options for Cloudflare's image optimization feature: * <https://blog.cloudflare.com/introducing-polish-automatic-image-optimizati/> * @enum {0 | 1 | 2} */ const PolishConfig = Object.freeze({ Off: 0, "0": "Off", Lossy: 1, "1": "Lossy", Lossless: 2, "2": "Lossless", }); /** * @enum {0 | 1 | 2} */ const RequestRedirect = Object.freeze({ Error: 0, "0": "Error", Follow: 1, "1": "Follow", Manual: 2, "2": "Manual", }); const __wbindgen_enum_ReadableStreamType = ["bytes"]; const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"]; const __wbindgen_enum_RequestMode = ["same-origin", "no-cors", "cors", "navigate"]; const AnthropicAgentFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm$1.__wbg_anthropicagent_free(ptr >>> 0, 1)); class AnthropicAgent { __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; AnthropicAgentFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm$1.__wbg_anthropicagent_free(ptr, 0); } /** * @param {AgentOpts} opts */ constructor(opts) { const ret = wasm$1.anthropicagent_new(opts); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } this.__wbg_ptr = ret[0] >>> 0; AnthropicAgentFinalization.register(this, this.__wbg_ptr, this); return this; } /** * @param {string} prompt * @returns {Promise<string>} */ prompt(prompt) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm$1.anthropicagent_prompt(this.__wbg_ptr, ptr0, len0); return ret; } /** * @param {string} prompt * @returns {Promise<ReadableStream>} */ prompt_stream(prompt) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm$1.anthropicagent_prompt_stream(this.__wbg_ptr, ptr0, len0); return ret; } /** * @param {string} prompt * @param {number} turns * @returns {Promise<string>} */ prompt_multi_turn(prompt, turns) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm$1.anthropicagent_prompt_multi_turn(this.__wbg_ptr, ptr0, len0, turns); return ret; } /** * @param {string} prompt * @param {Message[]} messages * @returns {Promise<string>} */ chat(prompt, messages) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ptr1 = passArrayJsValueToWasm0(messages, wasm$1.__wbindgen_malloc); const len1 = WASM_VECTOR_LEN; const ret = wasm$1.anthropicagent_chat(this.__wbg_ptr, ptr0, len0, ptr1, len1); return ret; } } const AnthropicCompletionModelFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm$1.__wbg_anthropiccompletionmodel_free(ptr >>> 0, 1)); /** * The Anthropic completions chat API. */ class AnthropicCompletionModel { __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; AnthropicCompletionModelFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm$1.__wbg_anthropiccompletionmodel_free(ptr, 0); } /** * @param {ModelOpts} opts */ constructor(opts) { const ret = wasm$1.anthropiccompletionmodel_new(opts); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } this.__wbg_ptr = ret[0] >>> 0; AnthropicCompletionModelFinalization.register(this, this.__wbg_ptr, this); return this; } /** * @param {CompletionOpts} opts * @returns {Promise<any>} */ completion(opts) { const ret = wasm$1.anthropiccompletionmodel_completion(this.__wbg_ptr, opts); return ret; } } const AssistantContentFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm$1.__wbg_assistantcontent_free(ptr >>> 0, 1)); class AssistantContent { static __wrap(ptr) { ptr = ptr >>> 0; const obj = Object.create(AssistantContent.prototype); obj.__wbg_ptr = ptr; AssistantContentFinalization.register(obj, obj.__wbg_ptr, obj); return obj; } __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; AssistantContentFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm$1.__wbg_assistantcontent_free(ptr, 0); } /** * @param {string} text * @returns {AssistantContent} */ static text(text) { const ptr0 = passStringToWasm0(text, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm$1.assistantcontent_text(ptr0, len0); return AssistantContent.__wrap(ret); } /** * @param {string} id * @param {ToolFunction} _function * @returns {AssistantContent} */ static tool_call(id, _function) { const ptr0 = passStringToWasm0(id, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; _assertClass(_function, ToolFunction); var ptr1 = _function.__destroy_into_raw(); const ret = wasm$1.assistantcontent_tool_call(ptr0, len0, ptr1); return AssistantContent.__wrap(ret); } /** * @param {string} id * @param {string} call_id * @param {ToolFunction} _function * @returns {AssistantContent} */ static tool_call_with_call_id(id, call_id, _function) { const ptr0 = passStringToWasm0(id, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ptr1 = passStringToWasm0(call_id, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len1 = WASM_VECTOR_LEN; _assertClass(_function, ToolFunction); var ptr2 = _function.__destroy_into_raw(); const ret = wasm$1.assistantcontent_tool_call_with_call_id(ptr0, len0, ptr1, len1, ptr2); return AssistantContent.__wrap(ret); } } const CohereAgentFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm$1.__wbg_cohereagent_free(ptr >>> 0, 1)); class CohereAgent { __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; CohereAgentFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm$1.__wbg_cohereagent_free(ptr, 0); } /** * @param {AgentOpts} opts */ constructor(opts) { const ret = wasm$1.cohereagent_new(opts); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } this.__wbg_ptr = ret[0] >>> 0; CohereAgentFinalization.register(this, this.__wbg_ptr, this); return this; } /** * @param {string} prompt * @returns {Promise<string>} */ prompt(prompt) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm$1.cohereagent_prompt(this.__wbg_ptr, ptr0, len0); return ret; } /** * @param {string} prompt * @returns {Promise<ReadableStream>} */ prompt_stream(prompt) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm$1.cohereagent_prompt_stream(this.__wbg_ptr, ptr0, len0); return ret; } /** * @param {string} prompt * @param {number} turns * @returns {Promise<string>} */ prompt_multi_turn(prompt, turns) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm$1.cohereagent_prompt_multi_turn(this.__wbg_ptr, ptr0, len0, turns); return ret; } /** * @param {string} prompt * @param {Message[]} messages * @returns {Promise<string>} */ chat(prompt, messages) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ptr1 = passArrayJsValueToWasm0(messages, wasm$1.__wbindgen_malloc); const len1 = WASM_VECTOR_LEN; const ret = wasm$1.cohereagent_chat(this.__wbg_ptr, ptr0, len0, ptr1, len1); return ret; } } const CohereCompletionModelFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm$1.__wbg_coherecompletionmodel_free(ptr >>> 0, 1)); /** * The Cohere Responses API, modelled as the Completions API. */ class CohereCompletionModel { __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; CohereCompletionModelFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm$1.__wbg_coherecompletionmodel_free(ptr, 0); } /** * @param {ModelOpts} opts */ constructor(opts) { const ret = wasm$1.coherecompletionmodel_new(opts); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } this.__wbg_ptr = ret[0] >>> 0; CohereCompletionModelFinalization.register(this, this.__wbg_ptr, this); return this; } /** * @param {CompletionOpts} opts * @returns {Promise<any>} */ completion(opts) { const ret = wasm$1.coherecompletionmodel_completion(this.__wbg_ptr, opts); return ret; } } const CohereEmbeddingModelFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm$1.__wbg_cohereembeddingmodel_free(ptr >>> 0, 1)); class CohereEmbeddingModel { __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; CohereEmbeddingModelFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm$1.__wbg_cohereembeddingmodel_free(ptr, 0); } /** * @param {ModelOpts} opts */ constructor(opts) { const ret = wasm$1.cohereembeddingmodel_new(opts); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } this.__wbg_ptr = ret[0] >>> 0; CohereEmbeddingModelFinalization.register(this, this.__wbg_ptr, this); return this; } /** * @param {string} text * @returns {Promise<Embedding>} */ embedText(text) { const ptr0 = passStringToWasm0(text, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm$1.cohereembeddingmodel_embedText(this.__wbg_ptr, ptr0, len0); return ret; } /** * @param {Iterable<string>} iter * @returns {Promise<Embedding[]>} */ embedTexts(iter) { const ret = wasm$1.cohereembeddingmodel_embedTexts(this.__wbg_ptr, iter); return ret; } } const CompletionRequestFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm$1.__wbg_completionrequest_free(ptr >>> 0, 1)); class CompletionRequest { __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; CompletionRequestFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm$1.__wbg_completionrequest_free(ptr, 0); } /** * @param {CompletionOpts} opts */ constructor(opts) { const ret = wasm$1.completionrequest_new(opts); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } this.__wbg_ptr = ret[0] >>> 0; CompletionRequestFinalization.register(this, this.__wbg_ptr, this); return this; } } const DeepSeekAgentFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm$1.__wbg_deepseekagent_free(ptr >>> 0, 1)); class DeepSeekAgent { __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; DeepSeekAgentFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm$1.__wbg_deepseekagent_free(ptr, 0); } /** * @param {AgentOpts} opts */ constructor(opts) { const ret = wasm$1.deepseekagent_new(opts); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } this.__wbg_ptr = ret[0] >>> 0; DeepSeekAgentFinalization.register(this, this.__wbg_ptr, this); return this; } /** * @param {string} prompt * @returns {Promise<string>} */ prompt(prompt) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm$1.deepseekagent_prompt(this.__wbg_ptr, ptr0, len0); return ret; } /** * @param {string} prompt * @returns {Promise<ReadableStream>} */ prompt_stream(prompt) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm$1.deepseekagent_prompt_stream(this.__wbg_ptr, ptr0, len0); return ret; } /** * @param {string} prompt * @param {number} turns * @returns {Promise<string>} */ prompt_multi_turn(prompt, turns) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm$1.deepseekagent_prompt_multi_turn(this.__wbg_ptr, ptr0, len0, turns); return ret; } /** * @param {string} prompt * @param {Message[]} messages * @returns {Promise<string>} */ chat(prompt, messages) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ptr1 = passArrayJsValueToWasm0(messages, wasm$1.__wbindgen_malloc); const len1 = WASM_VECTOR_LEN; const ret = wasm$1.deepseekagent_chat(this.__wbg_ptr, ptr0, len0, ptr1, len1); return ret; } } const DeepSeekCompletionsModelFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm$1.__wbg_deepseekcompletionsmodel_free(ptr >>> 0, 1)); /** * The DeepSeek completions chat API. */ class DeepSeekCompletionsModel { __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; DeepSeekCompletionsModelFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm$1.__wbg_deepseekcompletionsmodel_free(ptr, 0); } /** * @param {ModelOpts} opts */ constructor(opts) { const ret = wasm$1.deepseekcompletionsmodel_new(opts); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } this.__wbg_ptr = ret[0] >>> 0; DeepSeekCompletionsModelFinalization.register(this, this.__wbg_ptr, this); return this; } /** * @param {CompletionOpts} opts * @returns {Promise<any>} */ completion(opts) { const ret = wasm$1.deepseekcompletionsmodel_completion(this.__wbg_ptr, opts); return ret; } } const DocumentFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm$1.__wbg_document_free(ptr >>> 0, 1)); class Document { static __wrap(ptr) { ptr = ptr >>> 0; const obj = Object.create(Document.prototype); obj.__wbg_ptr = ptr; DocumentFinalization.register(obj, obj.__wbg_ptr, obj); return obj; } __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; DocumentFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm$1.__wbg_document_free(ptr, 0); } /** * @param {string} id * @param {string} text */ constructor(id, text) { const ptr0 = passStringToWasm0(id, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ptr1 = passStringToWasm0(text, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len1 = WASM_VECTOR_LEN; const ret = wasm$1.document_new(ptr0, len0, ptr1, len1); this.__wbg_ptr = ret >>> 0; DocumentFinalization.register(this, this.__wbg_ptr, this); return this; } /** * @param {any} additional_props * @returns {Document} */ setAdditionalProps(additional_props) { const ptr = this.__destroy_into_raw(); const ret = wasm$1.document_setAdditionalProps(ptr, additional_props); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } return Document.__wrap(ret[0]); } } const EmbeddingFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm$1.__wbg_embedding_free(ptr >>> 0, 1)); class Embedding { static __wrap(ptr) { ptr = ptr >>> 0; const obj = Object.create(Embedding.prototype); obj.__wbg_ptr = ptr; EmbeddingFinalization.register(obj, obj.__wbg_ptr, obj); return obj; } __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; EmbeddingFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm$1.__wbg_embedding_free(ptr, 0); } /** * Create a new Embedding instance. * Generally not recommended as these are typically generated automatically from sending embedding requests to model providers. * @param {string} document * @param {Float64Array} embedding */ constructor(document, embedding) { const ptr0 = passStringToWasm0(document, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ptr1 = passArrayF64ToWasm0(embedding, wasm$1.__wbindgen_malloc); const len1 = WASM_VECTOR_LEN; const ret = wasm$1.embedding_new(ptr0, len0, ptr1, len1); this.__wbg_ptr = ret >>> 0; EmbeddingFinalization.register(this, this.__wbg_ptr, this); return this; } /** * @returns {string} */ get document() { let deferred1_0; let deferred1_1; try { const ret = wasm$1.embedding_document(this.__wbg_ptr); deferred1_0 = ret[0]; deferred1_1 = ret[1]; return getStringFromWasm0(ret[0], ret[1]); } finally { wasm$1.__wbindgen_free(deferred1_0, deferred1_1, 1); } } /** * @param {string} val */ set document(val) { const ptr0 = passStringToWasm0(val, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; wasm$1.embedding_set_document(this.__wbg_ptr, ptr0, len0); } /** * @returns {Float64Array} */ get vec() { const ret = wasm$1.embedding_vec(this.__wbg_ptr); var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice(); wasm$1.__wbindgen_free(ret[0], ret[1] * 8, 8); return v1; } /** * @param {Float64Array} vec */ set vec(vec) { const ptr0 = passArrayF64ToWasm0(vec, wasm$1.__wbindgen_malloc); const len0 = WASM_VECTOR_LEN; wasm$1.embedding_set_vec(this.__wbg_ptr, ptr0, len0); } } const GaladrielAgentFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm$1.__wbg_galadrielagent_free(ptr >>> 0, 1)); class GaladrielAgent { __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; GaladrielAgentFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm$1.__wbg_galadrielagent_free(ptr, 0); } /** * @param {AgentOpts} opts */ constructor(opts) { const ret = wasm$1.galadrielagent_new(opts); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } this.__wbg_ptr = ret[0] >>> 0; GaladrielAgentFinalization.register(this, this.__wbg_ptr, this); return this; } /** * @param {string} prompt * @returns {Promise<string>} */ prompt(prompt) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm$1.galadrielagent_prompt(this.__wbg_ptr, ptr0, len0); return ret; } /** * @param {string} prompt * @returns {Promise<ReadableStream>} */ prompt_stream(prompt) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm$1.galadrielagent_prompt_stream(this.__wbg_ptr, ptr0, len0); return ret; } /** * @param {string} prompt * @param {number} turns * @returns {Promise<string>} */ prompt_multi_turn(prompt, turns) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm$1.galadrielagent_prompt_multi_turn(this.__wbg_ptr, ptr0, len0, turns); return ret; } /** * @param {string} prompt * @param {Message[]} messages * @returns {Promise<string>} */ chat(prompt, messages) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ptr1 = passArrayJsValueToWasm0(messages, wasm$1.__wbindgen_malloc); const len1 = WASM_VECTOR_LEN; const ret = wasm$1.galadrielagent_chat(this.__wbg_ptr, ptr0, len0, ptr1, len1); return ret; } } const GaladrielCompletionsModelFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm$1.__wbg_galadrielcompletionsmodel_free(ptr >>> 0, 1)); /** * The Galadriel completions chat API. */ class GaladrielCompletionsModel { __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; GaladrielCompletionsModelFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm$1.__wbg_galadrielcompletionsmodel_free(ptr, 0); } /** * @param {ModelOpts} opts */ constructor(opts) { const ret = wasm$1.galadrielcompletionsmodel_new(opts); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } this.__wbg_ptr = ret[0] >>> 0; GaladrielCompletionsModelFinalization.register(this, this.__wbg_ptr, this); return this; } /** * @param {CompletionOpts} opts * @returns {Promise<any>} */ completion(opts) { const ret = wasm$1.galadrielcompletionsmodel_completion(this.__wbg_ptr, opts); return ret; } } const GeminiAgentFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm$1.__wbg_geminiagent_free(ptr >>> 0, 1)); class GeminiAgent { __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; GeminiAgentFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm$1.__wbg_geminiagent_free(ptr, 0); } /** * @param {AgentOpts} opts */ constructor(opts) { const ret = wasm$1.geminiagent_new(opts); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } this.__wbg_ptr = ret[0] >>> 0; GeminiAgentFinalization.register(this, this.__wbg_ptr, this); return this; } /** * @param {string} prompt * @returns {Promise<string>} */ prompt(prompt) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm$1.geminiagent_prompt(this.__wbg_ptr, ptr0, len0); return ret; } /** * @param {string} prompt * @returns {Promise<ReadableStream>} */ prompt_stream(prompt) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm$1.geminiagent_prompt_stream(this.__wbg_ptr, ptr0, len0); return ret; } /** * @param {string} prompt * @param {number} turns * @returns {Promise<string>} */ prompt_multi_turn(prompt, turns) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm$1.geminiagent_prompt_multi_turn(this.__wbg_ptr, ptr0, len0, turns); return ret; } /** * @param {string} prompt * @param {Message[]} messages * @returns {Promise<string>} */ chat(prompt, messages) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ptr1 = passArrayJsValueToWasm0(messages, wasm$1.__wbindgen_malloc); const len1 = WASM_VECTOR_LEN; const ret = wasm$1.geminiagent_chat(this.__wbg_ptr, ptr0, len0, ptr1, len1); return ret; } } const GeminiCompletionModelFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm$1.__wbg_geminicompletionmodel_free(ptr >>> 0, 1)); /** * The Gemini Responses API, modelled as the Completions API. */ class GeminiCompletionModel { __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; GeminiCompletionModelFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm$1.__wbg_geminicompletionmodel_free(ptr, 0); } /** * @param {ModelOpts} opts */ constructor(opts) { const ret = wasm$1.geminicompletionmodel_new(opts); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } this.__wbg_ptr = ret[0] >>> 0; GeminiCompletionModelFinalization.register(this, this.__wbg_ptr, this); return this; } /** * @param {CompletionOpts} opts * @returns {Promise<any>} */ completion(opts) { const ret = wasm$1.geminicompletionmodel_completion(this.__wbg_ptr, opts); return ret; } } const GeminiEmbeddingModelFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm$1.__wbg_geminiembeddingmodel_free(ptr >>> 0, 1)); class GeminiEmbeddingModel { __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; GeminiEmbeddingModelFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm$1.__wbg_geminiembeddingmodel_free(ptr, 0); } /** * @param {ModelOpts} opts */ constructor(opts) { const ret = wasm$1.geminiembeddingmodel_new(opts); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } this.__wbg_ptr = ret[0] >>> 0; GeminiEmbeddingModelFinalization.register(this, this.__wbg_ptr, this); return this; } /** * @param {string} text * @returns {Promise<Embedding>} */ embedText(text) { const ptr0 = passStringToWasm0(text, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm$1.geminiembeddingmodel_embedText(this.__wbg_ptr, ptr0, len0); return ret; } /** * @param {Iterable<string>} iter * @returns {Promise<Embedding[]>} */ embedTexts(iter) { const ret = wasm$1.geminiembeddingmodel_embedTexts(this.__wbg_ptr, iter); return ret; } } const GeminiTranscriptionModelFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm$1.__wbg_geminitranscriptionmodel_free(ptr >>> 0, 1)); class GeminiTranscriptionModel { static __wrap(ptr) { ptr = ptr >>> 0; const obj = Object.create(GeminiTranscriptionModel.prototype); obj.__wbg_ptr = ptr; GeminiTranscriptionModelFinalization.register(obj, obj.__wbg_ptr, obj); return obj; } __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; GeminiTranscriptionModelFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm$1.__wbg_geminitranscriptionmodel_free(ptr, 0); } /** * @param {ModelOpts} opts * @returns {GeminiTranscriptionModel} */ static new(opts) { const ret = wasm$1.geminitranscriptionmodel_new(opts); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } return GeminiTranscriptionModel.__wrap(ret[0]); } /** * @param {TranscriptionOpts} opts * @returns {Promise<GeminiTranscriptionResponse>} */ transcription(opts) { const ret = wasm$1.geminitranscriptionmodel_transcription(this.__wbg_ptr, opts); return ret; } } const GeminiTranscriptionResponseFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm$1.__wbg_geminitranscriptionresponse_free(ptr >>> 0, 1)); class GeminiTranscriptionResponse { static __wrap(ptr) { ptr = ptr >>> 0; const obj = Object.create(GeminiTranscriptionResponse.prototype); obj.__wbg_ptr = ptr; GeminiTranscriptionResponseFinalization.register(obj, obj.__wbg_ptr, obj); return obj; } __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; GeminiTranscriptionResponseFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm$1.__wbg_geminitranscriptionresponse_free(ptr, 0); } /** * @returns {string} */ get text() { let deferred1_0; let deferred1_1; try { const ret = wasm$1.geminitranscriptionresponse_text(this.__wbg_ptr); deferred1_0 = ret[0]; deferred1_1 = ret[1]; return getStringFromWasm0(ret[0], ret[1]); } finally { wasm$1.__wbindgen_free(deferred1_0, deferred1_1, 1); } } } const GroqAgentFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm$1.__wbg_groqagent_free(ptr >>> 0, 1)); class GroqAgent { __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; GroqAgentFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm$1.__wbg_groqagent_free(ptr, 0); } /** * @param {AgentOpts} opts */ constructor(opts) { const ret = wasm$1.groqagent_new(opts); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } this.__wbg_ptr = ret[0] >>> 0; GroqAgentFinalization.register(this, this.__wbg_ptr, this); return this; } /** * @param {string} prompt * @returns {Promise<string>} */ prompt(prompt) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm$1.groqagent_prompt(this.__wbg_ptr, ptr0, len0); return ret; } /** * @param {string} prompt * @returns {Promise<ReadableStream>} */ prompt_stream(prompt) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm$1.groqagent_prompt_stream(this.__wbg_ptr, ptr0, len0); return ret; } /** * @param {string} prompt * @param {number} turns * @returns {Promise<string>} */ prompt_multi_turn(prompt, turns) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm$1.groqagent_prompt_multi_turn(this.__wbg_ptr, ptr0, len0, turns); return ret; } /** * @param {string} prompt * @param {Message[]} messages * @returns {Promise<string>} */ chat(prompt, messages) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ptr1 = passArrayJsValueToWasm0(messages, wasm$1.__wbindgen_malloc); const len1 = WASM_VECTOR_LEN; const ret = wasm$1.groqagent_chat(this.__wbg_ptr, ptr0, len0, ptr1, len1); return ret; } } const GroqCompletionsCompletionModelFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm$1.__wbg_groqcompletionscompletionmodel_free(ptr >>> 0, 1)); /** * The Groq completions chat API. */ class GroqCompletionsCompletionModel { __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; GroqCompletionsCompletionModelFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm$1.__wbg_groqcompletionscompletionmodel_free(ptr, 0); } /** * @param {ModelOpts} opts */ constructor(opts) { const ret = wasm$1.groqcompletionscompletionmodel_new(opts); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } this.__wbg_ptr = ret[0] >>> 0; GroqCompletionsCompletionModelFinalization.register(this, this.__wbg_ptr, this); return this; } /** * @param {CompletionOpts} opts * @returns {Promise<any>} */ completion(opts) { const ret = wasm$1.groqcompletionscompletionmodel_completion(this.__wbg_ptr, opts); return ret; } } const GroqTranscriptionModelFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm$1.__wbg_groqtranscriptionmodel_free(ptr >>> 0, 1)); class GroqTranscriptionModel { static __wrap(ptr) { ptr = ptr >>> 0; const obj = Object.create(GroqTranscriptionModel.prototype); obj.__wbg_ptr = ptr; GroqTranscriptionModelFinalization.register(obj, obj.__wbg_ptr, obj); return obj; } __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; GroqTranscriptionModelFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm$1.__wbg_groqtranscriptionmodel_free(ptr, 0); } /** * @param {ModelOpts} opts * @returns {GroqTranscriptionModel} */ static new(opts) { const ret = wasm$1.groqtranscriptionmodel_new(opts); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } return GroqTranscriptionModel.__wrap(ret[0]); } /** * @param {TranscriptionOpts} opts * @returns {Promise<GroqTranscriptionResponse>} */ transcription(opts) { const ret = wasm$1.groqtranscriptionmodel_transcription(this.__wbg_ptr, opts); return ret; } } const GroqTranscriptionResponseFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm$1.__wbg_groqtranscriptionresponse_free(ptr >>> 0, 1)); class GroqTranscriptionResponse { static __wrap(ptr) { ptr = ptr >>> 0; const obj = Object.create(GroqTranscriptionResponse.prototype); obj.__wbg_ptr = ptr; GroqTranscriptionResponseFinalization.register(obj, obj.__wbg_ptr, obj); return obj; } __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; GroqTranscriptionResponseFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm$1.__wbg_groqtranscriptionresponse_free(ptr, 0); } /** * @returns {string} */ get text() { let deferred1_0; let deferred1_1; try { const ret = wasm$1.groqtranscriptionresponse_text(this.__wbg_ptr); deferred1_0 = ret[0]; deferred1_1 = ret[1]; return getStringFromWasm0(ret[0], ret[1]); } finally { wasm$1.__wbindgen_free(deferred1_0, deferred1_1, 1); } } } const HuggingFaceAgentFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm$1.__wbg_huggingfaceagent_free(ptr >>> 0, 1)); class HuggingFaceAgent { __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; HuggingFaceAgentFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm$1.__wbg_huggingfaceagent_free(ptr, 0); } /** * @param {AgentOpts} opts */ constructor(opts) { const ret = wasm$1.huggingfaceagent_new(opts); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } this.__wbg_ptr = ret[0] >>> 0; HuggingFaceAgentFinalization.register(this, this.__wbg_ptr, this); return this; } /** * @param {string} prompt * @returns {Promise<string>} */ prompt(prompt) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm$1.huggingfaceagent_prompt(this.__wbg_ptr, ptr0, len0); return ret; } /** * @param {string} prompt * @returns {Promise<ReadableStream>} */ prompt_stream(prompt) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm$1.huggingfaceagent_prompt_stream(this.__wbg_ptr, ptr0, len0); return ret; } /** * @param {string} prompt * @param {number} turns * @returns {Promise<string>} */ prompt_multi_turn(prompt, turns) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ret = wasm$1.huggingfaceagent_prompt_multi_turn(this.__wbg_ptr, ptr0, len0, turns); return ret; } /** * @param {string} prompt * @param {Message[]} messages * @returns {Promise<string>} */ chat(prompt, messages) { const ptr0 = passStringToWasm0(prompt, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ptr1 = passArrayJsValueToWasm0(messages, wasm$1.__wbindgen_malloc); const len1 = WASM_VECTOR_LEN; const ret = wasm$1.huggingfaceagent_chat(this.__wbg_ptr, ptr0, len0, ptr1, len1); return ret; } }