@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
package/package.json
CHANGED
package/README.md
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
# LiteRT-LM JS API
|
|
2
|
-
|
|
3
|
-
The JavaScript API of LiteRT-LM for running LLMs in the browser. This is an
|
|
4
|
-
early preview that supports text-in / text-out running in WebGPU.
|
|
5
|
-
[LiteRT-LM](https://www.google.com/url?sa=D&q=https%3A%2F%2Fai.google.dev%2Fedge%2Flitert-lm%2F)
|
|
6
|
-
is the **production-ready** orchestration layer to run LLMs with LiteRT,
|
|
7
|
-
engineered for **high-performance**, **cross-platform** execution.
|
|
8
|
-
|
|
9
|
-
- **Documentation**: [https://ai.google.dev/edge/litert-lm/js](https://ai.google.dev/edge/litert-lm/js)
|
|
10
|
-
- **GitHub**: [https://github.com/google-ai-edge/LiteRT-LM](https://github.com/google-ai-edge/LiteRT-LM)
|
|
11
|
-
|
|
12
|
-
## Supported Models
|
|
13
|
-
|
|
14
|
-
The LiteRT-LM JS API currently supports a limited set of web-compatible models.
|
|
15
|
-
We're working on expanding this to cover general `.litertlm` model files, but
|
|
16
|
-
for now, the following models are supported:
|
|
17
|
-
|
|
18
|
-
* `gemma-4-E2B-it-web.litertlm` from
|
|
19
|
-
[litert-community/gemma-4-E2B-it-litert-lm](https://huggingface.co/litert-community/gemma-4-E2B-it-litert-lm)
|
|
20
|
-
* `gemma-4-E4B-it-web.litertlm` from
|
|
21
|
-
[litert-community/gemma-4-E4B-it-litert-lm](https://huggingface.co/litert-community/gemma-4-E4B-it-litert-lm)
|
|
22
|
-
|
|
23
|
-
## Introduction
|
|
24
|
-
|
|
25
|
-
Here is a sample REPL chat app built with the JavaScript API:
|
|
26
|
-
|
|
27
|
-
```ts
|
|
28
|
-
<div id="out" style="white-space: pre-wrap; font-family: monospace;"></div>
|
|
29
|
-
<input id="in" onkeydown="if(event.key === 'Enter') repl(this)">
|
|
30
|
-
|
|
31
|
-
<script type="module">
|
|
32
|
-
import { Engine } from 'https://cdn.jsdelivr.net/npm/@litert-lm/core/+esm';
|
|
33
|
-
const engine = await Engine.create({
|
|
34
|
-
// Load the Gemma 4 E2B model
|
|
35
|
-
model: 'https://huggingface.co/litert-community/gemma-4-E2B-it-litert-lm/resolve/main/gemma-4-E2B-it-web.litertlm'
|
|
36
|
-
// Or use the E4B model by swapping in this line
|
|
37
|
-
// model: 'https://huggingface.co/litert-community/gemma-4-E4B-it-litert-lm/resolve/main/gemma-4-E4B-it-web.litertlm'
|
|
38
|
-
});
|
|
39
|
-
const chat = await engine.createConversation();
|
|
40
|
-
|
|
41
|
-
window.repl = async (el) => {
|
|
42
|
-
const text = el.value;
|
|
43
|
-
el.value = ''; // Clear immediately
|
|
44
|
-
out.append(`\n>>> ${text}\nAI: `);
|
|
45
|
-
|
|
46
|
-
for await (const chunk of chat.sendMessageStreaming(text)) {
|
|
47
|
-
out.append(chunk.content[0].text);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
</script>
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
## Getting Started
|
|
54
|
-
|
|
55
|
-
LiteRT-LM is available as an npm package. You can install the latest version
|
|
56
|
-
from npm or directly import it from a CDN:
|
|
57
|
-
|
|
58
|
-
```shell
|
|
59
|
-
# From npm
|
|
60
|
-
npm i --save @litert-lm/core
|
|
61
|
-
|
|
62
|
-
# From a CDN (in your JavaScript file)
|
|
63
|
-
import * as litertlm from 'https://cdn.jsdelivr.net/npm/@litert-lm/core/+esm';
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### Initialize the Engine
|
|
67
|
-
|
|
68
|
-
The `Engine` is the entry point to the API. It handles model loading, session
|
|
69
|
-
creation, and resource management. Remember to `delete` the engine to release
|
|
70
|
-
resources when the model is no longer needed.
|
|
71
|
-
|
|
72
|
-
**Note:** Initializing the engine can take several seconds to load the model.
|
|
73
|
-
|
|
74
|
-
```ts
|
|
75
|
-
import {Engine, EngineSettings} from '@litert-lm/core';
|
|
76
|
-
|
|
77
|
-
const engineSettings = {
|
|
78
|
-
model: 'url/path/to/model.litertlm', // or a ReadableStream, or a Blob
|
|
79
|
-
|
|
80
|
-
// You can configure context length and other settings here
|
|
81
|
-
mainExecutorSettings: {
|
|
82
|
-
maxNumTokens: 8192,
|
|
83
|
-
},
|
|
84
|
-
} satisfies EngineSettings;
|
|
85
|
-
|
|
86
|
-
const engine = await Engine.create(engineSettings);
|
|
87
|
-
|
|
88
|
-
// ... Use the engine to create a conversation ...
|
|
89
|
-
|
|
90
|
-
// Delete the engine when done.
|
|
91
|
-
await engine.delete();
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### Create a Conversation
|
|
95
|
-
|
|
96
|
-
Once the engine is initialized, create a `Conversation` instance. You can
|
|
97
|
-
provide a `ConversationConfig` to customize its behavior.
|
|
98
|
-
|
|
99
|
-
```ts
|
|
100
|
-
const conversation = await engine.createConversation({
|
|
101
|
-
preface: {
|
|
102
|
-
messages: [
|
|
103
|
-
{role: 'system', content: 'You are a helpful assistant'}
|
|
104
|
-
]
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
conversation.sendMessage({
|
|
109
|
-
role: 'user',
|
|
110
|
-
content: 'Write a poem',
|
|
111
|
-
});
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### Send Messages
|
|
115
|
-
|
|
116
|
-
You can send messages with or without streaming.
|
|
117
|
-
|
|
118
|
-
#### Non-Streaming Example
|
|
119
|
-
|
|
120
|
-
```ts
|
|
121
|
-
// Simple string input
|
|
122
|
-
let response = await conversation.sendMessage("What is the capital of France?");
|
|
123
|
-
console.log(response.content[0].text);
|
|
124
|
-
|
|
125
|
-
// Or with full message structure
|
|
126
|
-
response = await conversation.sendMessage({role: 'user', content: '...'});
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
#### Streaming Example
|
|
130
|
-
|
|
131
|
-
```ts
|
|
132
|
-
// sendMessageStreaming returns a ReadableStream of response chunks
|
|
133
|
-
const stream = conversation.sendMessageStreaming('Tell me a long story.');
|
|
134
|
-
|
|
135
|
-
for await (const chunk of stream) {
|
|
136
|
-
// Chunks are Records containing pieces of the response
|
|
137
|
-
for (const item of chunk.content) {
|
|
138
|
-
if (item.type === 'text') {
|
|
139
|
-
console.log(item.text);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
#### Cancel Generation
|
|
146
|
-
|
|
147
|
-
You can cancel an ongoing generation explicitly by calling `cancel()` on the
|
|
148
|
-
`Conversation` instance:
|
|
149
|
-
|
|
150
|
-
```ts
|
|
151
|
-
// Cancel any ongoing generation
|
|
152
|
-
conversation.cancel();
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
If you are streaming the response, exiting the `for await...of` loop early (such
|
|
156
|
-
as with `break`) will also automatically cancel the ongoing generation:
|
|
157
|
-
|
|
158
|
-
```ts
|
|
159
|
-
for await (const chunk of stream) {
|
|
160
|
-
if (shouldStop()) {
|
|
161
|
-
break; // Cancels the stream and underlying generation
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
```
|
package/dist/cleanup.d.ts
DELETED
|
@@ -1,25 +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 utility class for managing a set of callbacks that can be called to clean
|
|
18
|
-
* up resources.
|
|
19
|
-
*/
|
|
20
|
-
export declare class Cleanup {
|
|
21
|
-
private readonly callbacks;
|
|
22
|
-
add(callback: () => void): () => void;
|
|
23
|
-
run(): void;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=cleanup.d.ts.map
|
package/dist/cleanup.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cleanup.d.ts","sourceRoot":"","sources":["../src/cleanup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;GAGG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA8B;IAExD,GAAG,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IASrC,GAAG,IAAI,IAAI;CAMZ"}
|
package/dist/cleanup.js
DELETED
|
@@ -1,36 +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 utility class for managing a set of callbacks that can be called to clean
|
|
18
|
-
* up resources.
|
|
19
|
-
*/
|
|
20
|
-
export class Cleanup {
|
|
21
|
-
callbacks = new Set();
|
|
22
|
-
add(callback) {
|
|
23
|
-
this.callbacks.add(callback);
|
|
24
|
-
return () => {
|
|
25
|
-
this.callbacks.delete(callback);
|
|
26
|
-
callback();
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
run() {
|
|
30
|
-
for (const callback of this.callbacks) {
|
|
31
|
-
callback();
|
|
32
|
-
}
|
|
33
|
-
this.callbacks.clear();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=cleanup.js.map
|
package/dist/cleanup.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cleanup.js","sourceRoot":"","sources":["../src/cleanup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;GAGG;AACH,MAAM,OAAO,OAAO;IACD,SAAS,GAAoB,IAAI,GAAG,EAAE,CAAC;IAExD,GAAG,CAAC,QAAoB;QACtB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC7B,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAChC,QAAQ,EAAE,CAAC;QACb,CAAC,CAAC;IACJ,CAAC;IAGD,GAAG;QACD,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACtC,QAAQ,EAAE,CAAC;QACb,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;CACF"}
|
package/dist/conversation.d.ts
DELETED
|
@@ -1,46 +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 { Message, MessageLike } from './conversation_config.js';
|
|
17
|
-
import { Mutex } from './mutex.js';
|
|
18
|
-
import { ChatInterface } from './orchestration/chat_interface.js';
|
|
19
|
-
import { BenchmarkInfo, Conversation as WasmConversation, Engine as WasmEngine } from './wasm_binding_types.js';
|
|
20
|
-
/**
|
|
21
|
-
* LiteRT-LM Conversation
|
|
22
|
-
*/
|
|
23
|
-
export declare class Conversation implements ChatInterface {
|
|
24
|
-
private readonly conversation;
|
|
25
|
-
private readonly engine;
|
|
26
|
-
private readonly mutexes;
|
|
27
|
-
private isBusy;
|
|
28
|
-
constructor(conversation: WasmConversation, engine: WasmEngine, mutexes: {
|
|
29
|
-
executor: Mutex;
|
|
30
|
-
});
|
|
31
|
-
sendMessage(message: MessageLike | MessageLike[]): Promise<Message>;
|
|
32
|
-
/**
|
|
33
|
-
* Sends a message to the LLM and returns a ReadableStream that yields
|
|
34
|
-
* message chunks as they are generated.
|
|
35
|
-
*/
|
|
36
|
-
sendMessageStreaming(message: MessageLike | MessageLike[]): ReadableStream<Message>;
|
|
37
|
-
/**
|
|
38
|
-
* Sends a signal to cancel any current generation.
|
|
39
|
-
*/
|
|
40
|
-
cancel(): void;
|
|
41
|
-
getHistory(): Promise<Message[]>;
|
|
42
|
-
getTokenCount(): Promise<number>;
|
|
43
|
-
getBenchmarkInfo(): Promise<BenchmarkInfo>;
|
|
44
|
-
delete(): Promise<void>;
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=conversation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../src/conversation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAC,OAAO,EAAE,WAAW,EAAC,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AACjC,OAAO,EAAC,aAAa,EAAC,MAAM,mCAAmC,CAAC;AAChE,OAAO,EAAC,aAAa,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,IAAI,UAAU,EAAC,MAAM,yBAAyB,CAAC;AAK9G;;GAEG;AACH,qBAAa,YAAa,YAAW,aAAa;IAI5C,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAL5B,OAAO,CAAC,MAAM,CAAS;gBAGF,YAAY,EAAE,gBAAgB,EAC9B,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE;QAAC,QAAQ,EAAE,KAAK,CAAA;KAAC;IAEzC,WAAW,CAAC,OAAO,EAAE,WAAW,GAAC,WAAW,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAiBvE;;;OAGG;IACH,oBAAoB,CAAC,OAAO,EAAE,WAAW,GAAC,WAAW,EAAE,GACnD,cAAc,CAAC,OAAO,CAAC;IA6D3B;;OAEG;IACH,MAAM;IAIA,UAAU,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAOhC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAMhC,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC;IAM1C,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAK9B"}
|
package/dist/conversation.js
DELETED
|
@@ -1,152 +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
|
-
const BUSY_MESSAGE = 'Conversation is busy. A generation is already in progress.';
|
|
17
|
-
/**
|
|
18
|
-
* LiteRT-LM Conversation
|
|
19
|
-
*/
|
|
20
|
-
export class Conversation {
|
|
21
|
-
conversation;
|
|
22
|
-
engine;
|
|
23
|
-
mutexes;
|
|
24
|
-
isBusy = false;
|
|
25
|
-
constructor(conversation, engine, mutexes) {
|
|
26
|
-
this.conversation = conversation;
|
|
27
|
-
this.engine = engine;
|
|
28
|
-
this.mutexes = mutexes;
|
|
29
|
-
}
|
|
30
|
-
async sendMessage(message) {
|
|
31
|
-
if (this.isBusy) {
|
|
32
|
-
throw new Error(BUSY_MESSAGE);
|
|
33
|
-
}
|
|
34
|
-
this.isBusy = true;
|
|
35
|
-
try {
|
|
36
|
-
return await this.mutexes.executor.acquireAndRun(async () => {
|
|
37
|
-
const currentMessageJson = messageToJsonString(message);
|
|
38
|
-
const resultStr = await this.conversation.sendMessage(currentMessageJson);
|
|
39
|
-
return JSON.parse(resultStr);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
finally {
|
|
43
|
-
this.isBusy = false;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Sends a message to the LLM and returns a ReadableStream that yields
|
|
48
|
-
* message chunks as they are generated.
|
|
49
|
-
*/
|
|
50
|
-
sendMessageStreaming(message) {
|
|
51
|
-
if (this.isBusy) {
|
|
52
|
-
throw new Error(BUSY_MESSAGE);
|
|
53
|
-
}
|
|
54
|
-
this.isBusy = true;
|
|
55
|
-
let isCancelled = false;
|
|
56
|
-
let hasErrored = false;
|
|
57
|
-
return new ReadableStream({
|
|
58
|
-
start: (controller) => {
|
|
59
|
-
const currentMessageJson = messageToJsonString(message);
|
|
60
|
-
const executeGeneration = async () => {
|
|
61
|
-
await this.mutexes.executor.acquireAndRun(async () => {
|
|
62
|
-
await this.conversation.sendMessageAsync(currentMessageJson, (chunk, isDone, error) => {
|
|
63
|
-
if (isCancelled || hasErrored)
|
|
64
|
-
return;
|
|
65
|
-
if (error) {
|
|
66
|
-
hasErrored = true;
|
|
67
|
-
this.isBusy = false;
|
|
68
|
-
controller.error(new Error(error));
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
if (chunk) {
|
|
72
|
-
try {
|
|
73
|
-
const msg = JSON.parse(chunk);
|
|
74
|
-
controller.enqueue(msg);
|
|
75
|
-
}
|
|
76
|
-
catch (e) {
|
|
77
|
-
hasErrored = true;
|
|
78
|
-
this.isBusy = false;
|
|
79
|
-
controller.error(e);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
// Since we're using the synchronus execution manager in C++, which
|
|
84
|
-
// lazily executes tasks, we must queue the message and call
|
|
85
|
-
// waitUntilDone to start the execution concurrently while holding
|
|
86
|
-
// the mutex lock.
|
|
87
|
-
await this.engine.waitUntilDone();
|
|
88
|
-
});
|
|
89
|
-
if (isCancelled || hasErrored)
|
|
90
|
-
return;
|
|
91
|
-
this.isBusy = false;
|
|
92
|
-
controller.close();
|
|
93
|
-
};
|
|
94
|
-
executeGeneration().catch((e) => {
|
|
95
|
-
if (isCancelled || hasErrored)
|
|
96
|
-
return;
|
|
97
|
-
this.isBusy = false;
|
|
98
|
-
controller.error(e);
|
|
99
|
-
});
|
|
100
|
-
},
|
|
101
|
-
cancel: () => {
|
|
102
|
-
isCancelled = true;
|
|
103
|
-
this.isBusy = false;
|
|
104
|
-
this.cancel();
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Sends a signal to cancel any current generation.
|
|
110
|
-
*/
|
|
111
|
-
cancel() {
|
|
112
|
-
this.conversation.cancelProcess();
|
|
113
|
-
}
|
|
114
|
-
async getHistory() {
|
|
115
|
-
return this.mutexes.executor.acquireAndRun(() => {
|
|
116
|
-
const historyStr = this.conversation.getHistory();
|
|
117
|
-
return JSON.parse(historyStr);
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
async getTokenCount() {
|
|
121
|
-
return this.mutexes.executor.acquireAndRun(() => {
|
|
122
|
-
return this.conversation.getTokenCount();
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
async getBenchmarkInfo() {
|
|
126
|
-
return this.mutexes.executor.acquireAndRun(() => {
|
|
127
|
-
return this.conversation.getBenchmarkInfo();
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
async delete() {
|
|
131
|
-
await this.mutexes.executor.acquireAndRun(() => {
|
|
132
|
-
this.conversation.delete();
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
function messageToJsonString(messageLike) {
|
|
137
|
-
let message;
|
|
138
|
-
if (Array.isArray(messageLike)) {
|
|
139
|
-
message = messageLike.map(toMessage);
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
message = toMessage(messageLike);
|
|
143
|
-
}
|
|
144
|
-
return JSON.stringify(message);
|
|
145
|
-
}
|
|
146
|
-
function toMessage(messageLike) {
|
|
147
|
-
if (typeof messageLike === 'string') {
|
|
148
|
-
return { role: 'user', content: messageLike };
|
|
149
|
-
}
|
|
150
|
-
return messageLike;
|
|
151
|
-
}
|
|
152
|
-
//# sourceMappingURL=conversation.js.map
|
package/dist/conversation.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.js","sourceRoot":"","sources":["../src/conversation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAOH,MAAM,YAAY,GACd,4DAA4D,CAAC;AAEjE;;GAEG;AACH,MAAM,OAAO,YAAY;IAIF;IACA;IACA;IALb,MAAM,GAAG,KAAK,CAAC;IAEvB,YACqB,YAA8B,EAC9B,MAAkB,EAClB,OAA0B;QAF1B,iBAAY,GAAZ,YAAY,CAAkB;QAC9B,WAAM,GAAN,MAAM,CAAY;QAClB,YAAO,GAAP,OAAO,CAAmB;IAAG,CAAC;IAEnD,KAAK,CAAC,WAAW,CAAC,OAAkC;QAClD,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;QAChC,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,IAAI,EAAE;gBAC1D,MAAM,kBAAkB,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;gBACxD,MAAM,SAAS,GACX,MAAM,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;gBAC5D,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAY,CAAC;YAC1C,CAAC,CAAC,CAAC;QACL,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,MAAM,GAAG,KAAK,CA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aAAa,EAAE,CAAC;QAC3C,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,EAAE;YAC9C,OAAO,IAAI,CAAC,YAAY,CAAC,gBAAgB,EAAE,CAAC;QAC9C,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,EAAE;YAC7C,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,SAAS,mBAAmB,CAAC,WAAsC;IACjE,IAAI,OAA0B,CAAC;IAC/B,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QAC/B,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,SAAS,CAAC,WAAwB;IACzC,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;QACpC,OAAO,EAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAC,CAAC;IAC9C,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -1,153 +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 { SessionConfig } from './session_config.js';
|
|
17
|
-
import { JsonValue } from './types.js';
|
|
18
|
-
/**
|
|
19
|
-
* A parameter schema definition, adhering to a subset of JSON Schema.
|
|
20
|
-
*/
|
|
21
|
-
export interface Schema {
|
|
22
|
-
type?: 'object' | 'array' | 'string' | 'number' | 'integer' | 'boolean' | 'null';
|
|
23
|
-
description?: string;
|
|
24
|
-
properties?: Record<string, Schema>;
|
|
25
|
-
required?: string[];
|
|
26
|
-
items?: Schema;
|
|
27
|
-
enum?: string[];
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Declaration of a function that the model can call.
|
|
31
|
-
*/
|
|
32
|
-
export interface FunctionDeclaration {
|
|
33
|
-
name: string;
|
|
34
|
-
description?: string;
|
|
35
|
-
parameters?: Schema;
|
|
36
|
-
response?: Schema;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* A wrapper for a function tool. This is the canonical format
|
|
40
|
-
* generated by platform SDKs.
|
|
41
|
-
*/
|
|
42
|
-
export declare interface FunctionTool {
|
|
43
|
-
type: string;
|
|
44
|
-
function: FunctionDeclaration;
|
|
45
|
-
[key: string]: JsonValue | FunctionDeclaration | undefined;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* A tool that can be provided to the model.
|
|
49
|
-
* The C++ runtime is flexible and accepts both wrapped and unwrapped formats.
|
|
50
|
-
*/
|
|
51
|
-
export type Tool = FunctionDeclaration | FunctionTool;
|
|
52
|
-
/**
|
|
53
|
-
* Any support content part in a message.
|
|
54
|
-
*/
|
|
55
|
-
export type ContentPart = TextContentPart | ImageContentPart | AudioContentPart | VideoContentPart | ToolResponsePart;
|
|
56
|
-
/**
|
|
57
|
-
* Text content part of a message.
|
|
58
|
-
*/
|
|
59
|
-
export interface TextContentPart {
|
|
60
|
-
type: 'text';
|
|
61
|
-
text: string;
|
|
62
|
-
[key: string]: JsonValue | undefined;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Image content part of a message.
|
|
66
|
-
*
|
|
67
|
-
* This is a placeholder. Images are not supported in JS yet.
|
|
68
|
-
*/
|
|
69
|
-
export interface ImageContentPart {
|
|
70
|
-
type: 'image';
|
|
71
|
-
[key: string]: JsonValue | undefined;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Audio content part of a message.
|
|
75
|
-
*
|
|
76
|
-
* This is a placeholder. Audio is not supported in JS yet.
|
|
77
|
-
*/
|
|
78
|
-
export interface AudioContentPart {
|
|
79
|
-
type: 'audio';
|
|
80
|
-
[key: string]: JsonValue | undefined;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Video content part of a message.
|
|
84
|
-
*
|
|
85
|
-
* This is a placeholder. Video is not supported in JS yet.
|
|
86
|
-
*/
|
|
87
|
-
export interface VideoContentPart {
|
|
88
|
-
type: 'video';
|
|
89
|
-
[key: string]: JsonValue | undefined;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* The response from a tool execution.
|
|
93
|
-
*/
|
|
94
|
-
export declare interface ToolResponsePart {
|
|
95
|
-
type: 'tool_response';
|
|
96
|
-
name?: string;
|
|
97
|
-
response?: JsonValue;
|
|
98
|
-
value?: JsonValue;
|
|
99
|
-
[key: string]: JsonValue | undefined;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* A function call predicted by the model.
|
|
103
|
-
*/
|
|
104
|
-
export declare interface ToolCallFunction {
|
|
105
|
-
name: string;
|
|
106
|
-
arguments: Record<string, JsonValue>;
|
|
107
|
-
[key: string]: JsonValue | undefined;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* A tool call in the message.
|
|
111
|
-
*/
|
|
112
|
-
export declare interface ToolCall {
|
|
113
|
-
type: string;
|
|
114
|
-
id?: string;
|
|
115
|
-
function: ToolCallFunction;
|
|
116
|
-
[key: string]: JsonValue | undefined;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* A message in the conversation.
|
|
120
|
-
*/
|
|
121
|
-
export declare interface Message {
|
|
122
|
-
role: string;
|
|
123
|
-
content?: string | ContentPart[];
|
|
124
|
-
channels?: Record<string, string>;
|
|
125
|
-
tool_calls?: ToolCall[];
|
|
126
|
-
[key: string]: JsonValue | undefined;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Types that can be used as a Message in the conversation.
|
|
130
|
-
*/
|
|
131
|
-
export type MessageLike = string | Message;
|
|
132
|
-
/**
|
|
133
|
-
* Preface is the initial messages, tools and extra context for the
|
|
134
|
-
* conversation to begin with. It provides the initial background for the
|
|
135
|
-
* conversation.
|
|
136
|
-
*/
|
|
137
|
-
export declare interface Preface {
|
|
138
|
-
messages?: Message[];
|
|
139
|
-
tools?: Tool[];
|
|
140
|
-
extra_context?: Record<string, JsonValue>;
|
|
141
|
-
[key: string]: unknown;
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Configuration for the Conversation instance.
|
|
145
|
-
*/
|
|
146
|
-
export declare interface ConversationConfig {
|
|
147
|
-
sessionConfig?: SessionConfig;
|
|
148
|
-
preface?: Preface;
|
|
149
|
-
enableConstrainedDecoding?: boolean;
|
|
150
|
-
prefillPrefaceOnInit?: boolean;
|
|
151
|
-
filterChannelContentFromKvCache?: boolean;
|
|
152
|
-
}
|
|
153
|
-
//# sourceMappingURL=conversation_config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conversation_config.d.ts","sourceRoot":"","sources":["../src/conversation_config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CA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,CAAC;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAC,SAAS,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAC,OAAO,CAAC;AAEzC;;;;GAIG;AACH,MAAM,CAAC,OAAO,WAAW,OAAO;IAI9B,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IAErB,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IAIf,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC1C,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,WAAW,kBAAkB;IACzC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,+BAA+B,CAAC,EAAE,OAAO,CAAC;CAE3C"}
|
|
@@ -1,17 +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
|
-
export {};
|
|
17
|
-
//# sourceMappingURL=conversation_config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conversation_config.js","sourceRoot":"","sources":["../src/conversation_config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}
|
package/dist/engine.d.ts
DELETED
|
@@ -1,37 +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 { Conversation } from './conversation.js';
|
|
17
|
-
import { ConversationConfig } from './conversation_config.js';
|
|
18
|
-
import { EngineSettings } from './engine_settings.js';
|
|
19
|
-
import { Session } from './session.js';
|
|
20
|
-
import { RecursiveRequired } from './types.js';
|
|
21
|
-
import { Deletable } from './wasm_binding_types.js';
|
|
22
|
-
/**
|
|
23
|
-
* LiteRT-LM Engine
|
|
24
|
-
*/
|
|
25
|
-
export declare class Engine implements Deletable {
|
|
26
|
-
private readonly wasm;
|
|
27
|
-
private readonly engine;
|
|
28
|
-
private readonly deleteCallback;
|
|
29
|
-
readonly settings: RecursiveRequired<EngineSettings>;
|
|
30
|
-
private mutexes;
|
|
31
|
-
private constructor();
|
|
32
|
-
static create(engineSettings: EngineSettings, inputPromptAsHint?: string): Promise<Engine>;
|
|
33
|
-
createSession(sessionConfig?: {}): Promise<Session>;
|
|
34
|
-
createConversation(config?: ConversationConfig): Promise<Conversation>;
|
|
35
|
-
delete(): Promise<void>;
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=engine.d.ts.map
|
package/dist/engine.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAC,kBAAkB,EAAC,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAC,cAAc,EAA+E,MAAM,sBAAsB,CAAC;AAKlI,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AAErC,OAAO,EAAC,iBAAiB,EAAC,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAwD,SAAS,EAAsF,MAAM,yBAAyB,CAAC;AAQ9L;;GAEG;AACH,qBAAa,MAAO,YAAW,SAAS;IAOlC,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAEvB,OAAO,CAAC,QAAQ,CAAC,cAAc;IATnC,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAC;IACrD,OAAO,CAAC,OAAO,CAEb;IAEF,OAAO;WAgBM,MAAM,CAAC,cAAc,EAAE,cAAc,EAAE,iBAAiB,SAAK,GACtE,OAAO,CAAC,MAAM,CAAC;IAsFb,aAAa,CAAC,aAAa,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC;IAWnD,kBAAkB,CAAC,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC;IA8BtE,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAK9B"}
|