@litert-lm/core 0.14.0 → 0.16.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/package.json +1 -1
- package/README.md +0 -164
- package/dist/cleanup.d.ts +0 -25
- package/dist/cleanup.d.ts.map +0 -1
- package/dist/cleanup.js +0 -36
- package/dist/cleanup.js.map +0 -1
- package/dist/conversation.d.ts +0 -46
- package/dist/conversation.d.ts.map +0 -1
- package/dist/conversation.js +0 -152
- package/dist/conversation.js.map +0 -1
- package/dist/conversation_config.d.ts +0 -153
- package/dist/conversation_config.d.ts.map +0 -1
- package/dist/conversation_config.js +0 -17
- package/dist/conversation_config.js.map +0 -1
- package/dist/engine.d.ts +0 -37
- package/dist/engine.d.ts.map +0 -1
- package/dist/engine.js +0 -203
- package/dist/engine.js.map +0 -1
- package/dist/engine_settings.d.ts +0 -57
- package/dist/engine_settings.d.ts.map +0 -1
- package/dist/engine_settings.js +0 -114
- package/dist/engine_settings.js.map +0 -1
- package/dist/global_litertlm.d.ts +0 -66
- package/dist/global_litertlm.d.ts.map +0 -1
- package/dist/global_litertlm.js +0 -85
- package/dist/global_litertlm.js.map +0 -1
- package/dist/index.d.ts +0 -31
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -31
- package/dist/index.js.map +0 -1
- package/dist/litertlm_web.d.ts +0 -32
- package/dist/litertlm_web.d.ts.map +0 -1
- package/dist/litertlm_web.js +0 -75
- package/dist/litertlm_web.js.map +0 -1
- package/dist/load.d.ts +0 -28
- package/dist/load.d.ts.map +0 -1
- package/dist/load.js +0 -50
- package/dist/load.js.map +0 -1
- package/dist/load_litertlm.d.ts +0 -58
- package/dist/load_litertlm.d.ts.map +0 -1
- package/dist/load_litertlm.js +0 -87
- package/dist/load_litertlm.js.map +0 -1
- package/dist/mutex.d.ts +0 -45
- package/dist/mutex.d.ts.map +0 -1
- package/dist/mutex.js +0 -62
- package/dist/mutex.js.map +0 -1
- package/dist/orchestration/auto_tool_chat.d.ts +0 -82
- package/dist/orchestration/auto_tool_chat.d.ts.map +0 -1
- package/dist/orchestration/auto_tool_chat.js +0 -304
- package/dist/orchestration/auto_tool_chat.js.map +0 -1
- package/dist/orchestration/chat_interface.d.ts +0 -30
- package/dist/orchestration/chat_interface.d.ts.map +0 -1
- package/dist/orchestration/chat_interface.js +0 -17
- package/dist/orchestration/chat_interface.js.map +0 -1
- package/dist/orchestration/webmcp_tool.d.ts +0 -41
- package/dist/orchestration/webmcp_tool.d.ts.map +0 -1
- package/dist/orchestration/webmcp_tool.js +0 -32
- package/dist/orchestration/webmcp_tool.js.map +0 -1
- package/dist/readable_stream_data_stream_wrapper.d.ts +0 -44
- package/dist/readable_stream_data_stream_wrapper.d.ts.map +0 -1
- package/dist/readable_stream_data_stream_wrapper.js +0 -315
- package/dist/readable_stream_data_stream_wrapper.js.map +0 -1
- package/dist/session.d.ts +0 -46
- package/dist/session.d.ts.map +0 -1
- package/dist/session.js +0 -88
- package/dist/session.js.map +0 -1
- package/dist/session_config.d.ts +0 -55
- package/dist/session_config.d.ts.map +0 -1
- package/dist/session_config.js +0 -109
- package/dist/session_config.js.map +0 -1
- package/dist/testing/fakes.d.ts +0 -65
- package/dist/testing/fakes.d.ts.map +0 -1
- package/dist/testing/fakes.js +0 -115
- package/dist/testing/fakes.js.map +0 -1
- package/dist/testing/index.d.ts +0 -17
- package/dist/testing/index.d.ts.map +0 -1
- package/dist/testing/index.js +0 -17
- package/dist/testing/index.js.map +0 -1
- package/dist/types.d.ts +0 -42
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -17
- package/dist/types.js.map +0 -1
- package/dist/url_path_utils.d.ts +0 -28
- package/dist/url_path_utils.d.ts.map +0 -1
- package/dist/url_path_utils.js +0 -34
- package/dist/url_path_utils.js.map +0 -1
- package/dist/wasm_binding_types.d.ts +0 -376
- package/dist/wasm_binding_types.d.ts.map +0 -1
- package/dist/wasm_binding_types.js +0 -39
- package/dist/wasm_binding_types.js.map +0 -1
- package/dist/wasm_feature_detect.d.ts +0 -45
- package/dist/wasm_feature_detect.d.ts.map +0 -1
- package/dist/wasm_feature_detect.js +0 -139
- package/dist/wasm_feature_detect.js.map +0 -1
- package/dist/wasm_utils.d.ts +0 -30
- package/dist/wasm_utils.d.ts.map +0 -1
- package/dist/wasm_utils.js +0 -41
- package/dist/wasm_utils.js.map +0 -1
- package/wasm/litertlm_wasm_asyncify_internal.js +0 -8615
- package/wasm/litertlm_wasm_asyncify_internal.wasm +0 -0
- package/wasm/litertlm_wasm_compat_asyncify_internal.js +0 -8624
- package/wasm/litertlm_wasm_compat_asyncify_internal.wasm +0 -0
- package/wasm/litertlm_wasm_compat_internal.js +0 -8410
- package/wasm/litertlm_wasm_compat_internal.wasm +0 -0
- package/wasm/litertlm_wasm_internal.js +0 -8399
- package/wasm/litertlm_wasm_internal.wasm +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"litertlm_web.d.ts","sourceRoot":"","sources":["../src/litertlm_web.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAIhD,OAAO,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAC;AAErD;;GAEG;AACH,wBAAsB,wBAAwB,kBAE7C;AAED;;GAEG;AACH,qBAAa,QAAQ;IACnB,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,MAAM,CAAC,iBAAiB,SAA8D;gBAE1E,UAAU,EAAE,UAAU;IAK5B,wBAAwB;IAQ9B,MAAM;CAGP"}
|
package/dist/litertlm_web.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2026 Google LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
// Placeholder for internal dependency on trusted resource url
|
|
17
|
-
import { getGlobalLiteRtLm } from './global_litertlm.js';
|
|
18
|
-
/**
|
|
19
|
-
* Set up the default WebGPU device for the LiteRT LM Wasm module.
|
|
20
|
-
*/
|
|
21
|
-
export async function setupDefaultWebGpuDevice() {
|
|
22
|
-
await getGlobalLiteRtLm().setupDefaultWebGpuDevice();
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Run LiteRt LM models in the browser.
|
|
26
|
-
*/
|
|
27
|
-
export class LiteRtLm {
|
|
28
|
-
liteRtLmWasm;
|
|
29
|
-
static DEFAULT_WASM_PATH = 'https://cdn.jsdelivr.net/npm/@litert-lm/core@0.14.0/wasm';
|
|
30
|
-
constructor(wasmModule) {
|
|
31
|
-
this.liteRtLmWasm = wasmModule;
|
|
32
|
-
this.liteRtLmWasm.setupLogging();
|
|
33
|
-
}
|
|
34
|
-
async setupDefaultWebGpuDevice() {
|
|
35
|
-
if (this.liteRtLmWasm.preinitializedWebGPUDevice) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
this.liteRtLmWasm.preinitializedWebGPUDevice =
|
|
39
|
-
await createDefaultWebGpuDevice();
|
|
40
|
-
}
|
|
41
|
-
delete() {
|
|
42
|
-
// no op for now.
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
// TODO: b/475939320 - Use a shared implementation with LiteRT.
|
|
46
|
-
const DESIRED_WEBGPU_FEATURES = [
|
|
47
|
-
'shader-f16',
|
|
48
|
-
'subgroups',
|
|
49
|
-
];
|
|
50
|
-
async function createDefaultWebGpuDevice() {
|
|
51
|
-
const adapterDescriptor = {
|
|
52
|
-
powerPreference: 'high-performance',
|
|
53
|
-
};
|
|
54
|
-
const adapter = await navigator.gpu.requestAdapter(adapterDescriptor);
|
|
55
|
-
if (!adapter) {
|
|
56
|
-
throw new Error('No GPU adapter found.');
|
|
57
|
-
}
|
|
58
|
-
const requiredLimits = {
|
|
59
|
-
maxBufferSize: adapter.limits.maxBufferSize,
|
|
60
|
-
maxStorageBufferBindingSize: adapter.limits.maxStorageBufferBindingSize,
|
|
61
|
-
maxStorageBuffersPerShaderStage: adapter.limits.maxStorageBuffersPerShaderStage,
|
|
62
|
-
maxTextureDimension2D: adapter.limits.maxTextureDimension2D,
|
|
63
|
-
};
|
|
64
|
-
const requiredFeatures = [];
|
|
65
|
-
for (const feature of DESIRED_WEBGPU_FEATURES) {
|
|
66
|
-
if (adapter.features.has(feature)) {
|
|
67
|
-
requiredFeatures.push(feature);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return await adapter.requestDevice({
|
|
71
|
-
requiredFeatures,
|
|
72
|
-
requiredLimits,
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
//# sourceMappingURL=litertlm_web.js.map
|
package/dist/litertlm_web.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"litertlm_web.js","sourceRoot":"","sources":["../src/litertlm_web.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,8DAA8D;AAE9D,OAAO,EAAC,iBAAiB,EAAC,MAAM,sBAAsB,CAAC;AAGvD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB;IAC5C,MAAM,iBAAiB,EAAE,CAAC,wBAAwB,EAAE,CAAC;AACvD,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,QAAQ;IACV,YAAY,CAAe;IACpC,MAAM,CAAC,iBAAiB,GAAG,0DAA0D,CAAC;IAEtF,YAAY,UAAsB;QAChC,IAAI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f,CAAC,CAAC;AACL,CAAC"}
|
package/dist/load.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2025 Google LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { LiteRtLm } from './litertlm_web.js';
|
|
17
|
-
import { UrlPath } from './url_path_utils.js';
|
|
18
|
-
/**
|
|
19
|
-
* Options for loading LiteRT-LM's Wasm module.
|
|
20
|
-
**/
|
|
21
|
-
export interface LoadOptions {
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Load the LiteRtLm library with WASM from the given URL. Does not set the
|
|
25
|
-
* global LiteRtLm instance.
|
|
26
|
-
*/
|
|
27
|
-
export declare function load(path: UrlPath, options?: LoadOptions): Promise<LiteRtLm>;
|
|
28
|
-
//# sourceMappingURL=load.d.ts.map
|
package/dist/load.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAkC,OAAO,EAAC,MAAM,qBAAqB,CAAC;AAS7E;;IAEI;AACJ,MAAM,WAAW,WAAW;CAAG;AAE/B;;;GAGG;AACH,wBAAsB,IAAI,CACtB,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAsB3D"}
|
package/dist/load.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2025 Google LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { createWasmLib } from '@litertjs/wasm-utils';
|
|
17
|
-
import { LiteRtLm } from './litertlm_web.js';
|
|
18
|
-
import { appendPathSegment, pathToString } from './url_path_utils.js';
|
|
19
|
-
import { supportsFeature } from './wasm_feature_detect.js';
|
|
20
|
-
const WASM_JS_FILE_NAME = 'litertlm_wasm_internal.js';
|
|
21
|
-
const WASM_JS_COMPAT_FILE_NAME = 'litertlm_wasm_compat_internal.js';
|
|
22
|
-
const WASM_JS_ASYNCIFY_FILE_NAME = 'litertlm_wasm_asyncify_internal.js';
|
|
23
|
-
const WASM_JS_COMPAT_ASYNCIFY_FILE_NAME = 'litertlm_wasm_compat_asyncify_internal.js';
|
|
24
|
-
/**
|
|
25
|
-
* Load the LiteRtLm library with WASM from the given URL. Does not set the
|
|
26
|
-
* global LiteRtLm instance.
|
|
27
|
-
*/
|
|
28
|
-
export async function load(path, options) {
|
|
29
|
-
const pathString = pathToString(path);
|
|
30
|
-
const relaxedSimd = await supportsFeature('relaxedSimd');
|
|
31
|
-
const jspi = await supportsFeature('jspi');
|
|
32
|
-
let fileName = '';
|
|
33
|
-
if (relaxedSimd) {
|
|
34
|
-
fileName = jspi ? WASM_JS_FILE_NAME : WASM_JS_ASYNCIFY_FILE_NAME;
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
fileName =
|
|
38
|
-
jspi ? WASM_JS_COMPAT_FILE_NAME : WASM_JS_COMPAT_ASYNCIFY_FILE_NAME;
|
|
39
|
-
}
|
|
40
|
-
let jsFilePath = path;
|
|
41
|
-
if (pathString.endsWith('.wasm')) {
|
|
42
|
-
throw new Error('Please load the `.js` file corresponding to the `.wasm` file, or ' +
|
|
43
|
-
'load the directory containing it.');
|
|
44
|
-
}
|
|
45
|
-
else if (!pathString.endsWith('.js')) {
|
|
46
|
-
jsFilePath = appendPathSegment(path, fileName);
|
|
47
|
-
}
|
|
48
|
-
return createWasmLib(LiteRtLm, jsFilePath);
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=load.js.map
|
package/dist/load.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"load.js","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAC,iBAAiB,EAAE,YAAY,EAAU,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAC,eAAe,EAAC,MAAM,0BAA0B,CAAC;AAEzD,MAAM,iBAAiB,GAAG,2BAA2B,CAAC;AACtD,MAAM,wBAAwB,GAAG,kCAAkC,CAAC;AACpE,MAAM,0BAA0B,GAAG,oCAAoC,CAAC;AACxE,MAAM,iCAAiC,GACnC,2CAA2C,CAAC;AAOhD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CACtB,IAAa,EAAE,OAAqB;IACtC,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACtC,MAAM,WAAW,GAAG,MAAM,eAAe,CAAC,aAAa,CAAC,CAAC;IACzD,MAAM,IAAI,GAAG,MAAM,eAAe,CAAC,MAAM,CAAC,CAAC;IAC3C,IAAI,QAAQ,GAAG,EAAE,CAAC;IAClB,IAAI,WAAW,EAAE,CAAC;QAChB,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,0BAA0B,CAAC;IACnE,CAAC;SAAM,CAAC;QACN,QAAQ;YACJ,IAAI,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,iCAAiC,CAAC;IAC1E,CAAC;IAED,IAAI,UAAU,GAAG,IAAI,CAAC;IACtB,IAAI,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CACX,mEAAmE;YACnE,mCAAmC,CAAC,CAAC;IAC3C,CAAC;SAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACvC,UAAU,GAAG,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACjD,CAAC;IAED,OAAO,aAAa,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AAC7C,CAAC"}
|
package/dist/load_litertlm.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2025 Google LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { LiteRtLm } from './litertlm_web.js';
|
|
17
|
-
import { LoadOptions } from './load.js';
|
|
18
|
-
type UrlString = string;
|
|
19
|
-
/**
|
|
20
|
-
* Options for loading LiteRT-LM.
|
|
21
|
-
*
|
|
22
|
-
* @property threads Whether to load the threaded version of the Wasm module.
|
|
23
|
-
* Defaults to false. Unused when specifying a .js file directly instead of
|
|
24
|
-
* a directory containing the Wasm files.
|
|
25
|
-
**/
|
|
26
|
-
export interface LoadLiteRtLmOptions extends LoadOptions {
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Load LiteRT-LM Wasm files from the given URL. This needs to be called before
|
|
30
|
-
* calling any other LiteRT-LM functions.
|
|
31
|
-
*
|
|
32
|
-
* The URL can be:
|
|
33
|
-
*
|
|
34
|
-
* - A directory containing the LiteRT Wasm files (e.g. `.../wasm/`), or
|
|
35
|
-
* - The LiteRT-LM Wasm's js file (e.g. `.../litertlm_wasm_internal.js`)
|
|
36
|
-
*
|
|
37
|
-
* If the URL is to a directory, LiteRT-LM will detect what WASM features are
|
|
38
|
-
* available in the browser and load the compatible WASM file. If the URL is
|
|
39
|
-
* to a file, it will be loaded as is.
|
|
40
|
-
*
|
|
41
|
-
* @param path The path to the directory containing the LiteRT-LM Wasm files, or
|
|
42
|
-
* the full URL of the LiteRT-LM Wasm .js file.
|
|
43
|
-
*/
|
|
44
|
-
export declare function loadLiteRtLm(path: UrlString, options?: LoadLiteRtLmOptions): Promise<LiteRtLm>;
|
|
45
|
-
/**
|
|
46
|
-
* Unload the LiteRT-LM WASM module.
|
|
47
|
-
*
|
|
48
|
-
* This deletes the global LiteRT-LM instance and invalidate any models
|
|
49
|
-
* associated with it. You will need to call loadLiteRtLm() again to reload the
|
|
50
|
-
* module.
|
|
51
|
-
*/
|
|
52
|
-
export declare function unloadLiteRtLm(): void;
|
|
53
|
-
/**
|
|
54
|
-
* Get the global LiteRT-LM instance, or load it if it hasn't been loaded yet.
|
|
55
|
-
*/
|
|
56
|
-
export declare function getOrLoadGlobalLiteRtLm(path?: UrlString): Promise<LiteRtLm>;
|
|
57
|
-
export {};
|
|
58
|
-
//# sourceMappingURL=load_litertlm.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"load_litertlm.d.ts","sourceRoot":"","sources":["../src/load_litertlm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAO,WAAW,EAAC,MAAM,WAAW,CAAC;AAE5C,KAAK,SAAS,GAAG,MAAM,CAAC;AAGxB;;;;;;IAMI;AACJ,MAAM,WAAW,mBAAoB,SAAQ,WAAW;CAAG;AAE3D;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CACxB,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAcrE;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAarC;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC,CAa3E"}
|
package/dist/load_litertlm.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2025 Google LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
// Placeholder for internal dependency on trusted resource url type
|
|
17
|
-
import { getGlobalLiteRtLm, getGlobalLiteRtLmPromise, hasGlobalLiteRtLm, hasGlobalLiteRtLmPromise, setGlobalLiteRtLm, setGlobalLiteRtLmPromise } from './global_litertlm.js';
|
|
18
|
-
import { LiteRtLm } from './litertlm_web.js';
|
|
19
|
-
import { load } from './load.js';
|
|
20
|
-
let globalLiteRtLmPath = undefined;
|
|
21
|
-
/**
|
|
22
|
-
* Load LiteRT-LM Wasm files from the given URL. This needs to be called before
|
|
23
|
-
* calling any other LiteRT-LM functions.
|
|
24
|
-
*
|
|
25
|
-
* The URL can be:
|
|
26
|
-
*
|
|
27
|
-
* - A directory containing the LiteRT Wasm files (e.g. `.../wasm/`), or
|
|
28
|
-
* - The LiteRT-LM Wasm's js file (e.g. `.../litertlm_wasm_internal.js`)
|
|
29
|
-
*
|
|
30
|
-
* If the URL is to a directory, LiteRT-LM will detect what WASM features are
|
|
31
|
-
* available in the browser and load the compatible WASM file. If the URL is
|
|
32
|
-
* to a file, it will be loaded as is.
|
|
33
|
-
*
|
|
34
|
-
* @param path The path to the directory containing the LiteRT-LM Wasm files, or
|
|
35
|
-
* the full URL of the LiteRT-LM Wasm .js file.
|
|
36
|
-
*/
|
|
37
|
-
export function loadLiteRtLm(path, options) {
|
|
38
|
-
if (hasGlobalLiteRtLmPromise()) {
|
|
39
|
-
throw new Error('LiteRT-LM is already loading / loaded.');
|
|
40
|
-
}
|
|
41
|
-
setGlobalLiteRtLmPromise(load(path, options)
|
|
42
|
-
.then(async (liteRtLm) => {
|
|
43
|
-
setGlobalLiteRtLm(liteRtLm);
|
|
44
|
-
return liteRtLm;
|
|
45
|
-
})
|
|
46
|
-
.catch(error => {
|
|
47
|
-
setGlobalLiteRtLmPromise(undefined);
|
|
48
|
-
throw error;
|
|
49
|
-
}));
|
|
50
|
-
return getGlobalLiteRtLmPromise();
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Unload the LiteRT-LM WASM module.
|
|
54
|
-
*
|
|
55
|
-
* This deletes the global LiteRT-LM instance and invalidate any models
|
|
56
|
-
* associated with it. You will need to call loadLiteRtLm() again to reload the
|
|
57
|
-
* module.
|
|
58
|
-
*/
|
|
59
|
-
export function unloadLiteRtLm() {
|
|
60
|
-
if (hasGlobalLiteRtLmPromise() && !hasGlobalLiteRtLm()) {
|
|
61
|
-
throw new Error('LiteRT-LM is loading and can not be unloaded or canceled ' +
|
|
62
|
-
'until it is finished loading.');
|
|
63
|
-
}
|
|
64
|
-
if (hasGlobalLiteRtLm()) {
|
|
65
|
-
getGlobalLiteRtLm().delete();
|
|
66
|
-
setGlobalLiteRtLm(undefined);
|
|
67
|
-
globalLiteRtLmPath = undefined;
|
|
68
|
-
}
|
|
69
|
-
setGlobalLiteRtLmPromise(undefined);
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Get the global LiteRT-LM instance, or load it if it hasn't been loaded yet.
|
|
73
|
-
*/
|
|
74
|
-
export function getOrLoadGlobalLiteRtLm(path) {
|
|
75
|
-
const liteRtLmPromise = getGlobalLiteRtLmPromise();
|
|
76
|
-
if (liteRtLmPromise) {
|
|
77
|
-
if (path && globalLiteRtLmPath !== path) {
|
|
78
|
-
throw new Error(`LiteRT-LM is already loading / loaded with a different path ` +
|
|
79
|
-
`${globalLiteRtLmPath} but was requested to load ${path}. To ` +
|
|
80
|
-
`reload with a different path, call unloadLiteRtLm() first.`);
|
|
81
|
-
}
|
|
82
|
-
return liteRtLmPromise;
|
|
83
|
-
}
|
|
84
|
-
globalLiteRtLmPath = path ?? LiteRtLm.DEFAULT_WASM_PATH;
|
|
85
|
-
return liteRtLmPromise ?? loadLiteRtLm(globalLiteRtLmPath);
|
|
86
|
-
}
|
|
87
|
-
//# sourceMappingURL=load_litertlm.js.map
|
|
@@ -1 +0,0 @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C,CAAC;QAC7B,kBAAkB,GAAG,SAAS,CAAC;IACjC,CAAC;IACD,wBAAwB,CAAC,SAAS,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAgB;IACtD,MAAM,eAAe,GAAG,wBAAwB,EAAE,CAAC;IACnD,IAAI,eAAe,EAAE,CAAC;QACpB,IAAI,IAAI,IAAI,kBAAkB,KAAK,IAAI,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CACX,8DAA8D;gBAC9D,GAAG,kBAAkB,8BAA8B,IAAI,OAAO;gBAC9D,4DAA4D,CAAC,CAAC;QACpE,CAAC;QACD,OAAO,eAAe,CAAC;IACzB,CAAC;IACD,kBAAkB,GAAG,IAAI,IAAI,QAAQ,CAAC,iBAAiB,CAAC;IACxD,OAAO,eAAe,IAAI,YAAY,CAAC,kBAAkB,CAAC,CAAC;AAC7D,CAAC"}
|
package/dist/mutex.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2026 The ODML Authors.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
/**
|
|
17
|
-
* A mutual exclusion lock for managing asynchronous operations.
|
|
18
|
-
*
|
|
19
|
-
* In an Emscripten WebAssembly environment using Asyncify or JSPI, C++
|
|
20
|
-
* execution can be paused during asynchronous operations (such as waiting for
|
|
21
|
-
* WebGPU execution). While Wasm is paused, the JS event loop continues running.
|
|
22
|
-
* If JS invokes another Wasm binding function that attempts to acquire the same
|
|
23
|
-
* C++ mutex held by the paused stack frame, single-threaded C++ cannot yield
|
|
24
|
-
* and triggers an unrecoverable deadlock.
|
|
25
|
-
*
|
|
26
|
-
* This class prevents re-entrancy deadlocks by serializing all entry points
|
|
27
|
-
* from JavaScript into Wasm that interact with underlying C++ mutexes. Even
|
|
28
|
-
* seemingly synchronous tasks (like creating or deleting a session) must
|
|
29
|
-
* asynchronously wait for this mutex to ensure any paused C++ tasks have fully
|
|
30
|
-
* completed and released their locks.
|
|
31
|
-
*/
|
|
32
|
-
export declare class Mutex {
|
|
33
|
-
private mutexPromise;
|
|
34
|
-
private queueCount;
|
|
35
|
-
/**
|
|
36
|
-
* Whether the mutex is currently locked.
|
|
37
|
-
*/
|
|
38
|
-
get isLocked(): boolean;
|
|
39
|
-
/**
|
|
40
|
-
* Executes the provided function once the mutex is acquired, and releases
|
|
41
|
-
* the mutex when the function completes.
|
|
42
|
-
*/
|
|
43
|
-
acquireAndRun<T>(fn: () => Promise<T> | T): Promise<T>;
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=mutex.d.ts.map
|
package/dist/mutex.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mutex.d.ts","sourceRoot":"","sources":["../src/mutex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,KAAK;IAChB,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,UAAU,CAAK;IAEvB;;OAEG;IACH,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED;;;OAGG;IACG,aAAa,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAe5D"}
|
package/dist/mutex.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2026 The ODML Authors.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
/**
|
|
17
|
-
* A mutual exclusion lock for managing asynchronous operations.
|
|
18
|
-
*
|
|
19
|
-
* In an Emscripten WebAssembly environment using Asyncify or JSPI, C++
|
|
20
|
-
* execution can be paused during asynchronous operations (such as waiting for
|
|
21
|
-
* WebGPU execution). While Wasm is paused, the JS event loop continues running.
|
|
22
|
-
* If JS invokes another Wasm binding function that attempts to acquire the same
|
|
23
|
-
* C++ mutex held by the paused stack frame, single-threaded C++ cannot yield
|
|
24
|
-
* and triggers an unrecoverable deadlock.
|
|
25
|
-
*
|
|
26
|
-
* This class prevents re-entrancy deadlocks by serializing all entry points
|
|
27
|
-
* from JavaScript into Wasm that interact with underlying C++ mutexes. Even
|
|
28
|
-
* seemingly synchronous tasks (like creating or deleting a session) must
|
|
29
|
-
* asynchronously wait for this mutex to ensure any paused C++ tasks have fully
|
|
30
|
-
* completed and released their locks.
|
|
31
|
-
*/
|
|
32
|
-
export class Mutex {
|
|
33
|
-
mutexPromise = Promise.resolve();
|
|
34
|
-
queueCount = 0;
|
|
35
|
-
/**
|
|
36
|
-
* Whether the mutex is currently locked.
|
|
37
|
-
*/
|
|
38
|
-
get isLocked() {
|
|
39
|
-
return this.queueCount > 0;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Executes the provided function once the mutex is acquired, and releases
|
|
43
|
-
* the mutex when the function completes.
|
|
44
|
-
*/
|
|
45
|
-
async acquireAndRun(fn) {
|
|
46
|
-
this.queueCount++;
|
|
47
|
-
const previousPromise = this.mutexPromise;
|
|
48
|
-
let resolveMutex;
|
|
49
|
-
this.mutexPromise = new Promise((resolve) => {
|
|
50
|
-
resolveMutex = resolve;
|
|
51
|
-
});
|
|
52
|
-
try {
|
|
53
|
-
await previousPromise;
|
|
54
|
-
return await fn();
|
|
55
|
-
}
|
|
56
|
-
finally {
|
|
57
|
-
this.queueCount--;
|
|
58
|
-
resolveMutex();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=mutex.js.map
|
package/dist/mutex.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mutex.js","sourceRoot":"","sources":["../src/mutex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,KAAK;IACR,YAAY,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IACjC,UAAU,GAAG,CAAC,CAAC;IAEvB;;OAEG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,aAAa,CAAI,EAAuB;QAC5C,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,MAAM,eAAe,GAAG,IAAI,CAAC,YAAY,CAAC;QAC1C,IAAI,YAAyB,CAAC;QAC9B,IAAI,CAAC,YAAY,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YAChD,YAAY,GAAG,OAAO,CAAC;QACzB,CAAC,CAAC,CAAC;QACH,IAAI,CAAC;YACH,MAAM,eAAe,CAAC;YACtB,OAAO,MAAM,EAAE,EAAE,CAAC;QACpB,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,YAAY,EAAE,CAAC;QACjB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2026 The ODML Authors.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { ConversationConfig, Message, MessageLike, Tool } from '../conversation_config.js';
|
|
17
|
-
import { Engine } from '../engine.js';
|
|
18
|
-
import { JsonValue } from '../types.js';
|
|
19
|
-
import { BenchmarkInfo } from '../wasm_binding_types.js';
|
|
20
|
-
import { ChatInterface } from './chat_interface.js';
|
|
21
|
-
import { WebMcpTool } from './webmcp_tool.js';
|
|
22
|
-
type ToolExecute = (args: Record<string, JsonValue>) => JsonValue | Promise<JsonValue>;
|
|
23
|
-
/**
|
|
24
|
-
* A tool with an `execute` function implementation.
|
|
25
|
-
*/
|
|
26
|
-
export type ToolWithImplementation = Tool & {
|
|
27
|
-
execute: ToolExecute;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Event detail representing the execution progress of a single tool.
|
|
31
|
-
*/
|
|
32
|
-
export interface ToolProgressEvent {
|
|
33
|
-
id: number;
|
|
34
|
-
name: string;
|
|
35
|
-
arguments: Record<string, JsonValue>;
|
|
36
|
-
status: 'started' | 'completed' | 'error';
|
|
37
|
-
result?: unknown;
|
|
38
|
-
error?: string;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Options for configuring an AutoToolChat.
|
|
42
|
-
*/
|
|
43
|
-
export interface AutoToolChatOptions {
|
|
44
|
-
engine: Engine;
|
|
45
|
-
config?: ConversationConfig;
|
|
46
|
-
tools?: Array<ToolWithImplementation | WebMcpTool>;
|
|
47
|
-
recurringToolCallLimit?: number;
|
|
48
|
-
onToolProgress?: (event: ToolProgressEvent) => void;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Wraps a conversation and automatically executes tools for the model.
|
|
52
|
-
*
|
|
53
|
-
* Tools are called in parallel, but the model waits for all of them to
|
|
54
|
-
* finish before being woken up again.
|
|
55
|
-
*/
|
|
56
|
-
export declare class AutoToolChat implements ChatInterface {
|
|
57
|
-
private readonly options;
|
|
58
|
-
private baseConversation;
|
|
59
|
-
private isBusy;
|
|
60
|
-
private isCancelled;
|
|
61
|
-
private readonly tools;
|
|
62
|
-
private nextToolCallId;
|
|
63
|
-
private currentBatch;
|
|
64
|
-
constructor(options: AutoToolChatOptions);
|
|
65
|
-
private getConversation;
|
|
66
|
-
sendMessage(message: MessageLike | MessageLike[]): Promise<Message>;
|
|
67
|
-
sendMessageStreaming(message: MessageLike | MessageLike[]): ReadableStream<Message>;
|
|
68
|
-
/**
|
|
69
|
-
* Cancels the current generation.
|
|
70
|
-
* Note: This does not abort any in-progress tool calls natively. Tools that
|
|
71
|
-
* affect state may still complete in the background eventually, but their
|
|
72
|
-
* results will be discarded and not reported back to the model or the user.
|
|
73
|
-
*/
|
|
74
|
-
cancel(): void;
|
|
75
|
-
getHistory(): Promise<Message[]>;
|
|
76
|
-
getTokenCount(): Promise<number>;
|
|
77
|
-
getBenchmarkInfo(): Promise<BenchmarkInfo>;
|
|
78
|
-
delete(): Promise<void>;
|
|
79
|
-
private executeToolCalls;
|
|
80
|
-
}
|
|
81
|
-
export {};
|
|
82
|
-
//# sourceMappingURL=auto_tool_chat.d.ts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