kjarni-wasm 0.1.10 → 0.2.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kjarni-wasm",
3
- "version": "0.1.10",
3
+ "version": "0.2.1",
4
4
  "description": "Local AI inference in the browser: embeddings, classification, reranking, semantic search and chat, running in a Web Worker.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,19 +1,6 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
 
4
- /**
5
- * A local language model running in the browser.
6
- *
7
- * Text generation is synchronous here, and deliberately so. The engine's streaming
8
- * path builds a background task with `tokio::task::spawn_blocking`, and wasm has no
9
- * blocking pool for that to run on — it compiles but would fail at runtime. Calling
10
- * the generation loop directly and draining the channel afterwards avoids the
11
- * problem entirely.
12
- *
13
- * The cost is that a call blocks until the whole response is ready, which for a few
14
- * hundred tokens is seconds, not milliseconds. Run it in a Web Worker; on the main
15
- * thread it will freeze the tab.
16
- */
17
4
  export class WasmChat {
18
5
  private constructor();
19
6
  free(): void;
@@ -26,6 +13,20 @@ export class WasmChat {
26
13
  * The model's context window, in tokens.
27
14
  */
28
15
  context_size(): number;
16
+ /**
17
+ * Reuse the KV cache across turns, so a conversation prefills only its newest
18
+ * message instead of replaying the whole transcript.
19
+ *
20
+ * Measured natively on Qwen2.5-0.5B with a long system prompt: turn one is
21
+ * unchanged, turns two and three go from about 2.2s to roughly 0.2s, for
22
+ * identical answers. A browser tab is one conversation, so there is no sharing
23
+ * hazard here.
24
+ *
25
+ * `tokens` is the longest transcript that can be reused, and what the memory
26
+ * cost scales with; pass 0 for [`DEFAULT_WASM_PREFIX_CACHE_TOKENS`]. Longer
27
+ * conversations keep working, they simply stop reusing once they outgrow it.
28
+ */
29
+ enablePrefixCache(tokens: number): void;
29
30
  /**
30
31
  * Generate a completion for `prompt`.
31
32
  */
@@ -45,6 +46,10 @@ export class WasmChat {
45
46
  * itself is in `generate_stream_core`, which builds and is tested natively.
46
47
  */
47
48
  generate_stream(prompt: string, max_new_tokens: number, temperature: number, on_token: Function): string;
49
+ /**
50
+ * Whether prefix reuse is on.
51
+ */
52
+ hasPrefixCache(): boolean;
48
53
  /**
49
54
  * Number of messages held, system prompt included.
50
55
  */
@@ -81,13 +86,6 @@ export class WasmClassifier {
81
86
  private constructor();
82
87
  free(): void;
83
88
  [Symbol.dispose](): void;
84
- /**
85
- * Classify a batch, returning the single best label for each input.
86
- *
87
- * One result per input, in input order, so the caller can line them up with
88
- * whatever it passed in.
89
- */
90
- classify_batch(texts: string[]): any;
91
89
  /**
92
90
  * Classify one text, returning every label with its score, highest first.
93
91
  *
@@ -96,6 +94,13 @@ export class WasmClassifier {
96
94
  * what makes the behaviour testable on the host.
97
95
  */
98
96
  classify(text: string): any;
97
+ /**
98
+ * Classify a batch, returning the single best label for each input.
99
+ *
100
+ * One result per input, in input order, so the caller can line them up with
101
+ * whatever it passed in.
102
+ */
103
+ classify_batch(texts: string[]): any;
99
104
  /**
100
105
  * The labels this model predicts, in index order.
101
106
  */
@@ -215,8 +220,10 @@ export interface InitOutput {
215
220
  readonly set_debug_logging: (a: number) => void;
216
221
  readonly wasmchat_clear_history: (a: number) => void;
217
222
  readonly wasmchat_context_size: (a: number) => number;
223
+ readonly wasmchat_enablePrefixCache: (a: number, b: number, c: number) => void;
218
224
  readonly wasmchat_generate: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
219
225
  readonly wasmchat_generate_stream: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
226
+ readonly wasmchat_hasPrefixCache: (a: number) => number;
220
227
  readonly wasmchat_history_len: (a: number) => number;
221
228
  readonly wasmchat_load: (a: number, b: number, c: number, d: number, e: number) => void;
222
229
  readonly wasmchat_send_stream: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
@@ -248,8 +255,8 @@ export interface InitOutput {
248
255
  readonly wasmsearch_search_keywords: (a: number, b: number, c: number, d: number, e: number) => void;
249
256
  readonly wasmsearch_search_semantic: (a: number, b: number, c: number, d: number, e: number) => void;
250
257
  readonly wasmsearch_update_file: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
251
- readonly __wasm_bindgen_func_elem_5599: (a: number, b: number, c: number, d: number) => void;
252
- readonly __wasm_bindgen_func_elem_5619: (a: number, b: number, c: number, d: number) => void;
258
+ readonly __wasm_bindgen_func_elem_5677: (a: number, b: number, c: number, d: number) => void;
259
+ readonly __wasm_bindgen_func_elem_5695: (a: number, b: number, c: number, d: number) => void;
253
260
  readonly __wbindgen_export: (a: number, b: number) => number;
254
261
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
255
262
  readonly __wbindgen_export3: (a: number) => void;
@@ -1,18 +1,5 @@
1
1
  /* @ts-self-types="./kjarni_wasm.d.ts" */
2
2
 
3
- /**
4
- * A local language model running in the browser.
5
- *
6
- * Text generation is synchronous here, and deliberately so. The engine's streaming
7
- * path builds a background task with `tokio::task::spawn_blocking`, and wasm has no
8
- * blocking pool for that to run on — it compiles but would fail at runtime. Calling
9
- * the generation loop directly and draining the channel afterwards avoids the
10
- * problem entirely.
11
- *
12
- * The cost is that a call blocks until the whole response is ready, which for a few
13
- * hundred tokens is seconds, not milliseconds. Run it in a Web Worker; on the main
14
- * thread it will freeze the tab.
15
- */
16
3
  export class WasmChat {
17
4
  static __wrap(ptr) {
18
5
  const obj = Object.create(WasmChat.prototype);
@@ -44,6 +31,33 @@ export class WasmChat {
44
31
  const ret = wasm.wasmchat_context_size(this.__wbg_ptr);
45
32
  return ret >>> 0;
46
33
  }
34
+ /**
35
+ * Reuse the KV cache across turns, so a conversation prefills only its newest
36
+ * message instead of replaying the whole transcript.
37
+ *
38
+ * Measured natively on Qwen2.5-0.5B with a long system prompt: turn one is
39
+ * unchanged, turns two and three go from about 2.2s to roughly 0.2s, for
40
+ * identical answers. A browser tab is one conversation, so there is no sharing
41
+ * hazard here.
42
+ *
43
+ * `tokens` is the longest transcript that can be reused, and what the memory
44
+ * cost scales with; pass 0 for [`DEFAULT_WASM_PREFIX_CACHE_TOKENS`]. Longer
45
+ * conversations keep working, they simply stop reusing once they outgrow it.
46
+ * @param {number} tokens
47
+ */
48
+ enablePrefixCache(tokens) {
49
+ try {
50
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
51
+ wasm.wasmchat_enablePrefixCache(retptr, this.__wbg_ptr, tokens);
52
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
53
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
54
+ if (r1) {
55
+ throw takeObject(r0);
56
+ }
57
+ } finally {
58
+ wasm.__wbindgen_add_to_stack_pointer(16);
59
+ }
60
+ }
47
61
  /**
48
62
  * Generate a completion for `prompt`.
49
63
  * @param {string} prompt
@@ -123,6 +137,14 @@ export class WasmChat {
123
137
  wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
124
138
  }
125
139
  }
140
+ /**
141
+ * Whether prefix reuse is on.
142
+ * @returns {boolean}
143
+ */
144
+ hasPrefixCache() {
145
+ const ret = wasm.wasmchat_hasPrefixCache(this.__wbg_ptr);
146
+ return ret !== 0;
147
+ }
126
148
  /**
127
149
  * Number of messages held, system prompt included.
128
150
  * @returns {number}
@@ -230,19 +252,20 @@ export class WasmClassifier {
230
252
  wasm.__wbg_wasmclassifier_free(ptr, 0);
231
253
  }
232
254
  /**
233
- * Classify a batch, returning the single best label for each input.
255
+ * Classify one text, returning every label with its score, highest first.
234
256
  *
235
- * One result per input, in input order, so the caller can line them up with
236
- * whatever it passed in.
237
- * @param {string[]} texts
257
+ * Serializing to a `JsValue` panics outside wasm32, so the work lives in
258
+ * [`WasmClassifier::classify_core`] and this is only the conversion. That is
259
+ * what makes the behaviour testable on the host.
260
+ * @param {string} text
238
261
  * @returns {any}
239
262
  */
240
- classify_batch(texts) {
263
+ classify(text) {
241
264
  try {
242
265
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
243
- const ptr0 = passArrayJsValueToWasm0(texts, wasm.__wbindgen_export);
266
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
244
267
  const len0 = WASM_VECTOR_LEN;
245
- wasm.wasmclassifier_classify_batch(retptr, this.__wbg_ptr, ptr0, len0);
268
+ wasm.wasmclassifier_classify(retptr, this.__wbg_ptr, ptr0, len0);
246
269
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
247
270
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
248
271
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -255,20 +278,19 @@ export class WasmClassifier {
255
278
  }
256
279
  }
257
280
  /**
258
- * Classify one text, returning every label with its score, highest first.
281
+ * Classify a batch, returning the single best label for each input.
259
282
  *
260
- * Serializing to a `JsValue` panics outside wasm32, so the work lives in
261
- * [`WasmClassifier::classify_core`] and this is only the conversion. That is
262
- * what makes the behaviour testable on the host.
263
- * @param {string} text
283
+ * One result per input, in input order, so the caller can line them up with
284
+ * whatever it passed in.
285
+ * @param {string[]} texts
264
286
  * @returns {any}
265
287
  */
266
- classify(text) {
288
+ classify_batch(texts) {
267
289
  try {
268
290
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
269
- const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
291
+ const ptr0 = passArrayJsValueToWasm0(texts, wasm.__wbindgen_export);
270
292
  const len0 = WASM_VECTOR_LEN;
271
- wasm.wasmclassifier_classify(retptr, this.__wbg_ptr, ptr0, len0);
293
+ wasm.wasmclassifier_classify_batch(retptr, this.__wbg_ptr, ptr0, len0);
272
294
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
273
295
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
274
296
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -938,7 +960,7 @@ export function set_debug_logging(enabled) {
938
960
  function __wbg_get_imports() {
939
961
  const import0 = {
940
962
  __proto__: null,
941
- __wbg_Error_67e7344beaa85059: function(arg0, arg1) {
963
+ __wbg_Error_30c8987f7c2ed4e2: function(arg0, arg1) {
942
964
  const ret = Error(getStringFromWasm0(arg0, arg1));
943
965
  return addHeapObject(ret);
944
966
  },
@@ -949,31 +971,31 @@ function __wbg_get_imports() {
949
971
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
950
972
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
951
973
  },
952
- __wbg___wbindgen_debug_string_0e68cf47c9cbd9b0: function(arg0, arg1) {
974
+ __wbg___wbindgen_debug_string_4687d8d8c2017d52: function(arg0, arg1) {
953
975
  const ret = debugString(getObject(arg1));
954
976
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
955
977
  const len1 = WASM_VECTOR_LEN;
956
978
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
957
979
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
958
980
  },
959
- __wbg___wbindgen_is_function_fcda5e3902d732fe: function(arg0) {
981
+ __wbg___wbindgen_is_function_1f9d30630b8b1d3d: function(arg0) {
960
982
  const ret = typeof(getObject(arg0)) === 'function';
961
983
  return ret;
962
984
  },
963
- __wbg___wbindgen_is_object_edb6b15aa3afe12e: function(arg0) {
985
+ __wbg___wbindgen_is_object_3c45d4f2dde4e749: function(arg0) {
964
986
  const val = getObject(arg0);
965
987
  const ret = typeof(val) === 'object' && val !== null;
966
988
  return ret;
967
989
  },
968
- __wbg___wbindgen_is_string_c4f7cb494a2a21f1: function(arg0) {
990
+ __wbg___wbindgen_is_string_90b56bc79aad6f6c: function(arg0) {
969
991
  const ret = typeof(getObject(arg0)) === 'string';
970
992
  return ret;
971
993
  },
972
- __wbg___wbindgen_is_undefined_8c687d0b90d5b524: function(arg0) {
994
+ __wbg___wbindgen_is_undefined_8865fb403f8fe9d8: function(arg0) {
973
995
  const ret = getObject(arg0) === undefined;
974
996
  return ret;
975
997
  },
976
- __wbg___wbindgen_string_get_92ab86bb19cbc12f: function(arg0, arg1) {
998
+ __wbg___wbindgen_string_get_0380ccaa2f57f0d9: function(arg0, arg1) {
977
999
  const obj = getObject(arg1);
978
1000
  const ret = typeof(obj) === 'string' ? obj : undefined;
979
1001
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
@@ -981,17 +1003,17 @@ function __wbg_get_imports() {
981
1003
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
982
1004
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
983
1005
  },
984
- __wbg___wbindgen_throw_5d9e815e6fdf150f: function(arg0, arg1) {
1006
+ __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
985
1007
  throw new Error(getStringFromWasm0(arg0, arg1));
986
1008
  },
987
- __wbg__wbg_cb_unref_997e73d32238e655: function(arg0) {
1009
+ __wbg__wbg_cb_unref_dcc1a90847f04c41: function(arg0) {
988
1010
  getObject(arg0)._wbg_cb_unref();
989
1011
  },
990
- __wbg_arrayBuffer_06f3da76f071d37f: function() { return handleError(function (arg0) {
1012
+ __wbg_arrayBuffer_f07be74819944ea2: function() { return handleError(function (arg0) {
991
1013
  const ret = getObject(arg0).arrayBuffer();
992
1014
  return addHeapObject(ret);
993
1015
  }, arguments); },
994
- __wbg_call_6bcf8d3e20937e46: function() { return handleError(function (arg0, arg1, arg2) {
1016
+ __wbg_call_187d372bd5fdd4aa: function() { return handleError(function (arg0, arg1, arg2) {
995
1017
  const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
996
1018
  return addHeapObject(ret);
997
1019
  }, arguments); },
@@ -1010,11 +1032,11 @@ function __wbg_get_imports() {
1010
1032
  wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);
1011
1033
  }
1012
1034
  },
1013
- __wbg_fetch_079086473aeec73d: function(arg0, arg1, arg2) {
1035
+ __wbg_fetch_4178962c570137ca: function(arg0, arg1, arg2) {
1014
1036
  const ret = getObject(arg0).fetch(getStringFromWasm0(arg1, arg2));
1015
1037
  return addHeapObject(ret);
1016
1038
  },
1017
- __wbg_fetch_dde0fc0522f3018f: function(arg0, arg1, arg2) {
1039
+ __wbg_fetch_4a78764f83137409: function(arg0, arg1, arg2) {
1018
1040
  const ret = getObject(arg0).fetch(getStringFromWasm0(arg1, arg2));
1019
1041
  return addHeapObject(ret);
1020
1042
  },
@@ -1024,7 +1046,7 @@ function __wbg_get_imports() {
1024
1046
  __wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
1025
1047
  getObject(arg0).getRandomValues(getObject(arg1));
1026
1048
  }, arguments); },
1027
- __wbg_instanceof_Response_6366a785e400039b: function(arg0) {
1049
+ __wbg_instanceof_Response_b8758567269c30b2: function(arg0) {
1028
1050
  let result;
1029
1051
  try {
1030
1052
  result = getObject(arg0) instanceof Response;
@@ -1034,7 +1056,7 @@ function __wbg_get_imports() {
1034
1056
  const ret = result;
1035
1057
  return ret;
1036
1058
  },
1037
- __wbg_instanceof_Window_a3b8566f0a9c5d1a: function(arg0) {
1059
+ __wbg_instanceof_Window_82d71df4eddf88bc: function(arg0) {
1038
1060
  let result;
1039
1061
  try {
1040
1062
  result = getObject(arg0) instanceof Window;
@@ -1044,7 +1066,7 @@ function __wbg_get_imports() {
1044
1066
  const ret = result;
1045
1067
  return ret;
1046
1068
  },
1047
- __wbg_instanceof_WorkerGlobalScope_0c1a6411473b843f: function(arg0) {
1069
+ __wbg_instanceof_WorkerGlobalScope_8966e756dd00e8b7: function(arg0) {
1048
1070
  let result;
1049
1071
  try {
1050
1072
  result = getObject(arg0) instanceof WorkerGlobalScope;
@@ -1054,18 +1076,18 @@ function __wbg_get_imports() {
1054
1076
  const ret = result;
1055
1077
  return ret;
1056
1078
  },
1057
- __wbg_length_31bdaf014f5fbde2: function(arg0) {
1079
+ __wbg_length_7f3c00c40364105e: function(arg0) {
1058
1080
  const ret = getObject(arg0).length;
1059
1081
  return ret;
1060
1082
  },
1061
- __wbg_log_363d83b9114c8831: function(arg0) {
1083
+ __wbg_log_17c30ef363c61cf4: function(arg0) {
1062
1084
  console.log(getObject(arg0));
1063
1085
  },
1064
1086
  __wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
1065
1087
  const ret = getObject(arg0).msCrypto;
1066
1088
  return addHeapObject(ret);
1067
1089
  },
1068
- __wbg_new_1da3429bc3c4541c: function(arg0) {
1090
+ __wbg_new_1dbf7428bba60a42: function(arg0) {
1069
1091
  const ret = new Uint8Array(getObject(arg0));
1070
1092
  return addHeapObject(ret);
1071
1093
  },
@@ -1073,26 +1095,26 @@ function __wbg_get_imports() {
1073
1095
  const ret = new Error();
1074
1096
  return addHeapObject(ret);
1075
1097
  },
1076
- __wbg_new_8d36e20aa758e411: function() {
1098
+ __wbg_new_28744009d011f847: function() {
1077
1099
  const ret = new Map();
1078
1100
  return addHeapObject(ret);
1079
1101
  },
1080
- __wbg_new_bebc3f4757acf305: function() {
1102
+ __wbg_new_617a8cdb8bb1130e: function() {
1081
1103
  const ret = new Object();
1082
1104
  return addHeapObject(ret);
1083
1105
  },
1084
- __wbg_new_ffa92086ea89f79c: function() {
1106
+ __wbg_new_ee2291f50781bf1d: function() {
1085
1107
  const ret = new Array();
1086
1108
  return addHeapObject(ret);
1087
1109
  },
1088
- __wbg_new_typed_6f8b0d724fe26c07: function(arg0, arg1) {
1110
+ __wbg_new_typed_b01cb72a8af741a3: function(arg0, arg1) {
1089
1111
  try {
1090
1112
  var state0 = {a: arg0, b: arg1};
1091
1113
  var cb0 = (arg0, arg1) => {
1092
1114
  const a = state0.a;
1093
1115
  state0.a = 0;
1094
1116
  try {
1095
- return __wasm_bindgen_func_elem_5619(a, state0.b, arg0, arg1);
1117
+ return __wasm_bindgen_func_elem_5695(a, state0.b, arg0, arg1);
1096
1118
  } finally {
1097
1119
  state0.a = a;
1098
1120
  }
@@ -1103,7 +1125,7 @@ function __wbg_get_imports() {
1103
1125
  state0.a = 0;
1104
1126
  }
1105
1127
  },
1106
- __wbg_new_with_length_5ffeddb9d9fbb96f: function(arg0) {
1128
+ __wbg_new_with_length_3da0ad195f6f63ba: function(arg0) {
1107
1129
  const ret = new Uint8Array(arg0 >>> 0);
1108
1130
  return addHeapObject(ret);
1109
1131
  },
@@ -1111,7 +1133,7 @@ function __wbg_get_imports() {
1111
1133
  const ret = getObject(arg0).node;
1112
1134
  return addHeapObject(ret);
1113
1135
  },
1114
- __wbg_now_d1fb6650485d7f3e: function() {
1136
+ __wbg_now_aa4ccb83129e9e55: function() {
1115
1137
  const ret = Date.now();
1116
1138
  return ret;
1117
1139
  },
@@ -1127,14 +1149,14 @@ function __wbg_get_imports() {
1127
1149
  const ret = getObject(arg0).process;
1128
1150
  return addHeapObject(ret);
1129
1151
  },
1130
- __wbg_prototypesetcall_ae9f5e7459250748: function(arg0, arg1, arg2) {
1152
+ __wbg_prototypesetcall_bc27214492979395: function(arg0, arg1, arg2) {
1131
1153
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
1132
1154
  },
1133
- __wbg_queueMicrotask_85c90f6987555d65: function(arg0) {
1155
+ __wbg_queueMicrotask_9833f9a49df95a49: function(arg0) {
1134
1156
  const ret = getObject(arg0).queueMicrotask;
1135
1157
  return addHeapObject(ret);
1136
1158
  },
1137
- __wbg_queueMicrotask_f6a1fa10b81d1fc0: function(arg0) {
1159
+ __wbg_queueMicrotask_a72f977e97f23c5f: function(arg0) {
1138
1160
  queueMicrotask(getObject(arg0));
1139
1161
  },
1140
1162
  __wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {
@@ -1144,19 +1166,19 @@ function __wbg_get_imports() {
1144
1166
  const ret = module.require;
1145
1167
  return addHeapObject(ret);
1146
1168
  }, arguments); },
1147
- __wbg_resolve_35ec7e0c6af4c82c: function(arg0) {
1169
+ __wbg_resolve_0076e10020304ede: function(arg0) {
1148
1170
  const ret = Promise.resolve(getObject(arg0));
1149
1171
  return addHeapObject(ret);
1150
1172
  },
1151
- __wbg_set_13d25b81ab403f5e: function(arg0, arg1, arg2) {
1152
- getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
1173
+ __wbg_set_6ae97e73113c4f0b: function(arg0, arg1, arg2) {
1174
+ const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
1175
+ return addHeapObject(ret);
1153
1176
  },
1154
1177
  __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
1155
1178
  getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
1156
1179
  },
1157
- __wbg_set_bf6dde4923b9b059: function(arg0, arg1, arg2) {
1158
- const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
1159
- return addHeapObject(ret);
1180
+ __wbg_set_bea140a88be9b277: function(arg0, arg1, arg2) {
1181
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
1160
1182
  },
1161
1183
  __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
1162
1184
  const ret = getObject(arg1).stack;
@@ -1165,35 +1187,35 @@ function __wbg_get_imports() {
1165
1187
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1166
1188
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1167
1189
  },
1168
- __wbg_static_accessor_GLOBAL_8eb4cd83130a11a0: function() {
1190
+ __wbg_static_accessor_GLOBAL_266715b9d96ba635: function() {
1169
1191
  const ret = typeof global === 'undefined' ? null : global;
1170
1192
  return isLikeNone(ret) ? 0 : addHeapObject(ret);
1171
1193
  },
1172
- __wbg_static_accessor_GLOBAL_THIS_1e7044f654e934db: function() {
1194
+ __wbg_static_accessor_GLOBAL_THIS_10fb7dc1ae063179: function() {
1173
1195
  const ret = typeof globalThis === 'undefined' ? null : globalThis;
1174
1196
  return isLikeNone(ret) ? 0 : addHeapObject(ret);
1175
1197
  },
1176
- __wbg_static_accessor_SELF_d8b50611246a6d92: function() {
1198
+ __wbg_static_accessor_SELF_0b583911f537483a: function() {
1177
1199
  const ret = typeof self === 'undefined' ? null : self;
1178
1200
  return isLikeNone(ret) ? 0 : addHeapObject(ret);
1179
1201
  },
1180
- __wbg_static_accessor_WINDOW_fd0bc376bf0f8b42: function() {
1202
+ __wbg_static_accessor_WINDOW_d7f903d1508cbdc4: function() {
1181
1203
  const ret = typeof window === 'undefined' ? null : window;
1182
1204
  return isLikeNone(ret) ? 0 : addHeapObject(ret);
1183
1205
  },
1184
- __wbg_subarray_1daff70dde20c145: function(arg0, arg1, arg2) {
1206
+ __wbg_subarray_002b94d5e13d1411: function(arg0, arg1, arg2) {
1185
1207
  const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
1186
1208
  return addHeapObject(ret);
1187
1209
  },
1188
- __wbg_text_b00323a194b10fa8: function() { return handleError(function (arg0) {
1210
+ __wbg_text_ff3f476b3d6b1246: function() { return handleError(function (arg0) {
1189
1211
  const ret = getObject(arg0).text();
1190
1212
  return addHeapObject(ret);
1191
1213
  }, arguments); },
1192
- __wbg_then_7a850dae4493f353: function(arg0, arg1, arg2) {
1214
+ __wbg_then_c949d5a25a4e78f8: function(arg0, arg1, arg2) {
1193
1215
  const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
1194
1216
  return addHeapObject(ret);
1195
1217
  },
1196
- __wbg_then_b830475380919203: function(arg0, arg1) {
1218
+ __wbg_then_e71170d78fcf8954: function(arg0, arg1) {
1197
1219
  const ret = getObject(arg0).then(getObject(arg1));
1198
1220
  return addHeapObject(ret);
1199
1221
  },
@@ -1206,8 +1228,8 @@ function __wbg_get_imports() {
1206
1228
  return addHeapObject(ret);
1207
1229
  },
1208
1230
  __wbindgen_generic_0000000000000001: function(arg0, arg1) {
1209
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 2061, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1210
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_5599);
1231
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 2083, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1232
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_5677);
1211
1233
  return addHeapObject(ret);
1212
1234
  },
1213
1235
  __wbindgen_generic_0000000000000002: function(arg0) {
@@ -1244,14 +1266,14 @@ function __wbg_get_imports() {
1244
1266
  };
1245
1267
  }
1246
1268
 
1247
- function __wasm_bindgen_func_elem_5619(arg0, arg1, arg2, arg3) {
1248
- wasm.__wasm_bindgen_func_elem_5619(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1269
+ function __wasm_bindgen_func_elem_5695(arg0, arg1, arg2, arg3) {
1270
+ wasm.__wasm_bindgen_func_elem_5695(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1249
1271
  }
1250
1272
 
1251
- function __wasm_bindgen_func_elem_5599(arg0, arg1, arg2) {
1273
+ function __wasm_bindgen_func_elem_5677(arg0, arg1, arg2) {
1252
1274
  try {
1253
1275
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1254
- wasm.__wasm_bindgen_func_elem_5599(retptr, arg0, arg1, addHeapObject(arg2));
1276
+ wasm.__wasm_bindgen_func_elem_5677(retptr, arg0, arg1, addHeapObject(arg2));
1255
1277
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1256
1278
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1257
1279
  if (r1) {
Binary file
@@ -12,8 +12,10 @@ export const init: () => void;
12
12
  export const set_debug_logging: (a: number) => void;
13
13
  export const wasmchat_clear_history: (a: number) => void;
14
14
  export const wasmchat_context_size: (a: number) => number;
15
+ export const wasmchat_enablePrefixCache: (a: number, b: number, c: number) => void;
15
16
  export const wasmchat_generate: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
16
17
  export const wasmchat_generate_stream: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
18
+ export const wasmchat_hasPrefixCache: (a: number) => number;
17
19
  export const wasmchat_history_len: (a: number) => number;
18
20
  export const wasmchat_load: (a: number, b: number, c: number, d: number, e: number) => void;
19
21
  export const wasmchat_send_stream: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
@@ -45,8 +47,8 @@ export const wasmsearch_search: (a: number, b: number, c: number, d: number, e:
45
47
  export const wasmsearch_search_keywords: (a: number, b: number, c: number, d: number, e: number) => void;
46
48
  export const wasmsearch_search_semantic: (a: number, b: number, c: number, d: number, e: number) => void;
47
49
  export const wasmsearch_update_file: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
48
- export const __wasm_bindgen_func_elem_5599: (a: number, b: number, c: number, d: number) => void;
49
- export const __wasm_bindgen_func_elem_5619: (a: number, b: number, c: number, d: number) => void;
50
+ export const __wasm_bindgen_func_elem_5677: (a: number, b: number, c: number, d: number) => void;
51
+ export const __wasm_bindgen_func_elem_5695: (a: number, b: number, c: number, d: number) => void;
50
52
  export const __wbindgen_export: (a: number, b: number) => number;
51
53
  export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
52
54
  export const __wbindgen_export3: (a: number) => void;
package/pkg/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "Ólafur Aron Jóhannsson <olafurjohannss@gmail.com>"
6
6
  ],
7
7
  "description": "Local AI inference in the browser: embeddings, classification, reranking, semantic search and chat, compiled to WebAssembly.",
8
- "version": "0.1.10",
8
+ "version": "0.2.0",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",