@trymirai/uzu 0.1.39 → 0.1.42
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/README.md +30 -6
- package/bridging/chatModel.d.mts +15 -0
- package/bridging/chatModel.d.mts.map +1 -0
- package/bridging/chatModel.d.ts +15 -0
- package/bridging/chatModel.d.ts.map +1 -0
- package/bridging/chatModel.js +33 -0
- package/bridging/chatModel.js.map +1 -0
- package/bridging/chatModel.mjs +29 -0
- package/bridging/chatModel.mjs.map +1 -0
- package/bridging/chatSession.d.mts +10 -0
- package/bridging/chatSession.d.mts.map +1 -0
- package/bridging/chatSession.d.ts +10 -0
- package/bridging/chatSession.d.ts.map +1 -0
- package/bridging/{session.js → chatSession.js} +7 -7
- package/bridging/chatSession.js.map +1 -0
- package/bridging/{session.mjs → chatSession.mjs} +5 -5
- package/bridging/chatSession.mjs.map +1 -0
- package/bridging/engine.d.mts +10 -10
- package/bridging/engine.d.mts.map +1 -1
- package/bridging/engine.d.ts +10 -10
- package/bridging/engine.d.ts.map +1 -1
- package/bridging/engine.js +42 -44
- package/bridging/engine.js.map +1 -1
- package/bridging/engine.mjs +43 -45
- package/bridging/engine.mjs.map +1 -1
- package/bridging/modelType.d.mts +2 -1
- package/bridging/modelType.d.mts.map +1 -1
- package/bridging/modelType.d.ts +2 -1
- package/bridging/modelType.d.ts.map +1 -1
- package/bridging/modelType.js +14 -2
- package/bridging/modelType.js.map +1 -1
- package/bridging/modelType.mjs +12 -1
- package/bridging/modelType.mjs.map +1 -1
- package/error.d.mts +1 -1
- package/error.d.mts.map +1 -1
- package/error.d.ts +1 -1
- package/error.d.ts.map +1 -1
- package/error.js +2 -2
- package/error.js.map +1 -1
- package/error.mjs +2 -2
- package/error.mjs.map +1 -1
- package/index.d.mts +5 -5
- package/index.d.mts.map +1 -1
- package/index.d.ts +5 -5
- package/index.d.ts.map +1 -1
- package/index.js +11 -12
- package/index.js.map +1 -1
- package/index.mjs +5 -5
- package/index.mjs.map +1 -1
- package/interactors/{modelInteractor.d.mts → chatModelInteractor.d.mts} +15 -15
- package/interactors/chatModelInteractor.d.mts.map +1 -0
- package/interactors/{modelInteractor.d.ts → chatModelInteractor.d.ts} +15 -15
- package/interactors/chatModelInteractor.d.ts.map +1 -0
- package/interactors/{modelInteractor.js → chatModelInteractor.js} +13 -13
- package/interactors/chatModelInteractor.js.map +1 -0
- package/interactors/{modelInteractor.mjs → chatModelInteractor.mjs} +11 -11
- package/interactors/chatModelInteractor.mjs.map +1 -0
- package/interactors/chatModelsInteractor.d.mts +12 -0
- package/interactors/chatModelsInteractor.d.mts.map +1 -0
- package/interactors/chatModelsInteractor.d.ts +12 -0
- package/interactors/chatModelsInteractor.d.ts.map +1 -0
- package/interactors/{modelsInteractor.js → chatModelsInteractor.js} +6 -6
- package/interactors/chatModelsInteractor.js.map +1 -0
- package/interactors/{modelsInteractor.mjs → chatModelsInteractor.mjs} +4 -4
- package/interactors/chatModelsInteractor.mjs.map +1 -0
- package/interactors/chatSessionInteractor.d.mts +24 -0
- package/interactors/chatSessionInteractor.d.mts.map +1 -0
- package/interactors/chatSessionInteractor.d.ts +24 -0
- package/interactors/chatSessionInteractor.d.ts.map +1 -0
- package/interactors/{sessionInteractor.js → chatSessionInteractor.js} +8 -8
- package/interactors/chatSessionInteractor.js.map +1 -0
- package/interactors/{sessionInteractor.mjs → chatSessionInteractor.mjs} +6 -6
- package/interactors/chatSessionInteractor.mjs.map +1 -0
- package/interactors/downloadInteractor.d.mts +3 -3
- package/interactors/downloadInteractor.d.mts.map +1 -1
- package/interactors/downloadInteractor.d.ts +3 -3
- package/interactors/downloadInteractor.d.ts.map +1 -1
- package/interactors/downloadInteractor.js.map +1 -1
- package/interactors/downloadInteractor.mjs.map +1 -1
- package/interactors/engineInteractor.d.mts +5 -8
- package/interactors/engineInteractor.d.mts.map +1 -1
- package/interactors/engineInteractor.d.ts +5 -8
- package/interactors/engineInteractor.d.ts.map +1 -1
- package/interactors/engineInteractor.js +8 -12
- package/interactors/engineInteractor.js.map +1 -1
- package/interactors/engineInteractor.mjs +8 -12
- package/interactors/engineInteractor.mjs.map +1 -1
- package/napi/uzu.d.ts +18 -32
- package/napi/uzu.js +4 -6
- package/napi/uzu.mjs +2 -3
- package/napi/uzu.node +0 -0
- package/package.json +1 -1
- package/src/bridging/chatModel.ts +54 -0
- package/src/bridging/{session.ts → chatSession.ts} +6 -6
- package/src/bridging/engine.ts +47 -47
- package/src/bridging/modelType.ts +13 -1
- package/src/error.ts +2 -2
- package/src/index.ts +5 -5
- package/src/interactors/{modelInteractor.ts → chatModelInteractor.ts} +22 -22
- package/src/interactors/{modelsInteractor.ts → chatModelsInteractor.ts} +8 -8
- package/src/interactors/{sessionInteractor.ts → chatSessionInteractor.ts} +19 -15
- package/src/interactors/downloadInteractor.ts +3 -3
- package/src/interactors/engineInteractor.ts +9 -20
- package/src/napi/uzu.d.ts +18 -32
- package/src/napi/uzu.js +4 -6
- package/src/napi/uzu.mjs +2 -3
- package/src/napi/uzu.node +0 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
- package/bridging/model.d.mts +0 -18
- package/bridging/model.d.mts.map +0 -1
- package/bridging/model.d.ts +0 -18
- package/bridging/model.d.ts.map +0 -1
- package/bridging/model.js +0 -27
- package/bridging/model.js.map +0 -1
- package/bridging/model.mjs +0 -23
- package/bridging/model.mjs.map +0 -1
- package/bridging/session.d.mts +0 -10
- package/bridging/session.d.mts.map +0 -1
- package/bridging/session.d.ts +0 -10
- package/bridging/session.d.ts.map +0 -1
- package/bridging/session.js.map +0 -1
- package/bridging/session.mjs.map +0 -1
- package/interactors/modelInteractor.d.mts.map +0 -1
- package/interactors/modelInteractor.d.ts.map +0 -1
- package/interactors/modelInteractor.js.map +0 -1
- package/interactors/modelInteractor.mjs.map +0 -1
- package/interactors/modelsInteractor.d.mts +0 -12
- package/interactors/modelsInteractor.d.mts.map +0 -1
- package/interactors/modelsInteractor.d.ts +0 -12
- package/interactors/modelsInteractor.d.ts.map +0 -1
- package/interactors/modelsInteractor.js.map +0 -1
- package/interactors/modelsInteractor.mjs.map +0 -1
- package/interactors/sessionInteractor.d.mts +0 -24
- package/interactors/sessionInteractor.d.mts.map +0 -1
- package/interactors/sessionInteractor.d.ts +0 -24
- package/interactors/sessionInteractor.d.ts.map +0 -1
- package/interactors/sessionInteractor.js.map +0 -1
- package/interactors/sessionInteractor.mjs.map +0 -1
- package/src/bridging/model.ts +0 -58
package/README.md
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
<a href="https://artifacts.trymirai.com/social/about_us.mp3"><img src="https://img.shields.io/badge/Listen-Podcast-red" alt="Listen to our podcast"></a>
|
|
8
8
|
<a href="https://docsend.com/v/76bpr/mirai2025"><img src="https://img.shields.io/badge/View-Deck-red" alt="View our deck"></a>
|
|
9
|
-
<a href="
|
|
9
|
+
<a href="https://discord.gg/gUhyn6Rb7x"><img src="https://img.shields.io/discord/1377764166764462120?label=Discord" alt="Discord"></a>
|
|
10
|
+
<a href="mailto:contact@getmirai.co?subject=Interested%20in%20Mirai"><img src="https://img.shields.io/badge/Send-Email-green" alt="Contact us"></a>
|
|
10
11
|
<a href="https://docs.trymirai.com/app-integration/overview"><img src="https://img.shields.io/badge/Read-Docs-blue" alt="Read docs"></a>
|
|
11
12
|
[](https://www.npmjs.com/package/@trymirai/uzu)
|
|
12
13
|
[](LICENSE)
|
|
@@ -25,7 +26,7 @@ Add the `uzu` dependency to your project's `package.json`:
|
|
|
25
26
|
|
|
26
27
|
```json
|
|
27
28
|
"dependencies": {
|
|
28
|
-
"@trymirai/uzu": "0.1.
|
|
29
|
+
"@trymirai/uzu": "0.1.42"
|
|
29
30
|
}
|
|
30
31
|
```
|
|
31
32
|
|
|
@@ -34,7 +35,7 @@ Set up your project through [Platform](https://platform.trymirai.com) and obtain
|
|
|
34
35
|
```ts
|
|
35
36
|
const output = await Engine
|
|
36
37
|
.create('API_KEY')
|
|
37
|
-
.
|
|
38
|
+
.chatModel('Qwen/Qwen3-0.6B')
|
|
38
39
|
.reply('Tell me a short, funny story about a robot');
|
|
39
40
|
```
|
|
40
41
|
|
|
@@ -48,6 +49,7 @@ Place the `API_KEY` you obtained earlier in the corresponding example file, and
|
|
|
48
49
|
pnpm run tsn examples/chat.ts
|
|
49
50
|
pnpm run tsn examples/summarization.ts
|
|
50
51
|
pnpm run tsn examples/classification.ts
|
|
52
|
+
pnpm run tsn examples/cloud.ts
|
|
51
53
|
```
|
|
52
54
|
|
|
53
55
|
### Chat
|
|
@@ -59,7 +61,7 @@ import Engine, { Message } from '@trymirai/uzu';
|
|
|
59
61
|
|
|
60
62
|
async function main() {
|
|
61
63
|
const output = await Engine.create('API_KEY')
|
|
62
|
-
.
|
|
64
|
+
.chatModel('Qwen/Qwen3-0.6B')
|
|
63
65
|
.download((update) => {
|
|
64
66
|
console.log('Progress:', update.progress);
|
|
65
67
|
})
|
|
@@ -93,7 +95,7 @@ async function main() {
|
|
|
93
95
|
const prompt = `Text is: "${textToSummarize}". Write only summary itself.`;
|
|
94
96
|
|
|
95
97
|
const output = await Engine.create('API_KEY')
|
|
96
|
-
.
|
|
98
|
+
.chatModel('Qwen/Qwen3-0.6B')
|
|
97
99
|
.download((update) => {
|
|
98
100
|
console.log('Progress:', update.progress);
|
|
99
101
|
})
|
|
@@ -142,7 +144,7 @@ async function main() {
|
|
|
142
144
|
"Answer with one word. Don't add a dot at the end.";
|
|
143
145
|
|
|
144
146
|
const output = await Engine.create('API_KEY')
|
|
145
|
-
.
|
|
147
|
+
.chatModel('Qwen/Qwen3-0.6B')
|
|
146
148
|
.download((update) => {
|
|
147
149
|
console.log('Progress:', update.progress);
|
|
148
150
|
})
|
|
@@ -164,6 +166,28 @@ main().catch((error) => {
|
|
|
164
166
|
|
|
165
167
|
You can view the stats to see that the answer will be ready immediately after the prefill step, and actual generation won’t even start due to speculative decoding, which significantly improves generation speed.
|
|
166
168
|
|
|
169
|
+
### Cloud
|
|
170
|
+
|
|
171
|
+
Sometimes you want to create a complex pipeline where some requests are processed on-device and the more complex ones are handled in the cloud using a larger model. With `uzu`, you can do this easily: just choose the cloud model you want to use and perform all requests through the same API:
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
import Engine from '@trymirai/uzu';
|
|
175
|
+
|
|
176
|
+
async function main() {
|
|
177
|
+
const output = await Engine
|
|
178
|
+
.create('API_KEY')
|
|
179
|
+
.chatModel('openai/gpt-oss-120b')
|
|
180
|
+
.reply('How LLMs work');
|
|
181
|
+
console.log(output.text.original);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
main().catch((error) => {
|
|
185
|
+
console.error(error);
|
|
186
|
+
});
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
> To get access to cloud inference, please contact us via [Discord](https://discord.gg/gUhyn6Rb7x) or [email](mailto:contact@getmirai.co).
|
|
190
|
+
|
|
167
191
|
## License
|
|
168
192
|
|
|
169
193
|
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ChatModel as NapiChatModel } from "../napi/uzu.mjs";
|
|
2
|
+
import { ModelType } from "./modelType.mjs";
|
|
3
|
+
export declare class ChatModel {
|
|
4
|
+
readonly repoId: string;
|
|
5
|
+
readonly type: ModelType;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly vendor: string;
|
|
8
|
+
readonly quantization: string | null;
|
|
9
|
+
readonly outputParserRegex: string | null;
|
|
10
|
+
get isThinking(): boolean;
|
|
11
|
+
private constructor();
|
|
12
|
+
static fromNapiChatModel(napiChatModel: NapiChatModel): ChatModel;
|
|
13
|
+
toNapi(): NapiChatModel;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=chatModel.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatModel.d.mts","sourceRoot":"","sources":["../src/bridging/chatModel.ts"],"names":[],"mappings":"OAAO,EAAE,SAAS,IAAI,aAAa,EAAE;OAC9B,EAAE,SAAS,EAAwD;AAE1E,qBAAa,SAAS;IAClB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IAE1C,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,OAAO;IAgBP,MAAM,CAAC,iBAAiB,CAAC,aAAa,EAAE,aAAa,GAAG,SAAS;IAWjE,MAAM,IAAI,aAAa;CAW1B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ChatModel as NapiChatModel } from "../napi/uzu.js";
|
|
2
|
+
import { ModelType } from "./modelType.js";
|
|
3
|
+
export declare class ChatModel {
|
|
4
|
+
readonly repoId: string;
|
|
5
|
+
readonly type: ModelType;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly vendor: string;
|
|
8
|
+
readonly quantization: string | null;
|
|
9
|
+
readonly outputParserRegex: string | null;
|
|
10
|
+
get isThinking(): boolean;
|
|
11
|
+
private constructor();
|
|
12
|
+
static fromNapiChatModel(napiChatModel: NapiChatModel): ChatModel;
|
|
13
|
+
toNapi(): NapiChatModel;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=chatModel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatModel.d.ts","sourceRoot":"","sources":["../src/bridging/chatModel.ts"],"names":[],"mappings":"OAAO,EAAE,SAAS,IAAI,aAAa,EAAE;OAC9B,EAAE,SAAS,EAAwD;AAE1E,qBAAa,SAAS;IAClB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IAE1C,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,OAAO;IAgBP,MAAM,CAAC,iBAAiB,CAAC,aAAa,EAAE,aAAa,GAAG,SAAS;IAWjE,MAAM,IAAI,aAAa;CAW1B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChatModel = void 0;
|
|
4
|
+
const modelType_1 = require("./modelType.js");
|
|
5
|
+
class ChatModel {
|
|
6
|
+
get isThinking() {
|
|
7
|
+
return this.outputParserRegex !== null;
|
|
8
|
+
}
|
|
9
|
+
constructor(repoId, type, name, vendor, quantization, outputParserRegex) {
|
|
10
|
+
this.repoId = repoId;
|
|
11
|
+
this.type = type;
|
|
12
|
+
this.name = name;
|
|
13
|
+
this.vendor = vendor;
|
|
14
|
+
this.quantization = quantization;
|
|
15
|
+
this.outputParserRegex = outputParserRegex;
|
|
16
|
+
}
|
|
17
|
+
static fromNapiChatModel(napiChatModel) {
|
|
18
|
+
return new ChatModel(napiChatModel.repoId, (0, modelType_1.modelTypeFromNapiModelType)(napiChatModel.type), napiChatModel.name, napiChatModel.vendor, napiChatModel.quantization ?? null, napiChatModel.outputParserRegex ?? null);
|
|
19
|
+
}
|
|
20
|
+
toNapi() {
|
|
21
|
+
const napiChatModel = {
|
|
22
|
+
repoId: this.repoId,
|
|
23
|
+
type: (0, modelType_1.modelTypeToNapiModelType)(this.type),
|
|
24
|
+
name: this.name,
|
|
25
|
+
vendor: this.vendor,
|
|
26
|
+
...(this.quantization !== null && { quantization: this.quantization }),
|
|
27
|
+
...(this.outputParserRegex !== null && { outputParserRegex: this.outputParserRegex }),
|
|
28
|
+
};
|
|
29
|
+
return napiChatModel;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.ChatModel = ChatModel;
|
|
33
|
+
//# sourceMappingURL=chatModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatModel.js","sourceRoot":"","sources":["../src/bridging/chatModel.ts"],"names":[],"mappings":";;;AACA,8CAA8F;AAE9F,MAAa,SAAS;IAQlB,IAAI,UAAU;QACV,OAAO,IAAI,CAAC,iBAAiB,KAAK,IAAI,CAAC;IAC3C,CAAC;IAED,YACI,MAAc,EACd,IAAe,EACf,IAAY,EACZ,MAAc,EACd,YAA2B,EAC3B,iBAAgC;QAEhC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;IAC/C,CAAC;IAED,MAAM,CAAC,iBAAiB,CAAC,aAA4B;QACjD,OAAO,IAAI,SAAS,CAChB,aAAa,CAAC,MAAM,EACpB,IAAA,sCAA0B,EAAC,aAAa,CAAC,IAAI,CAAC,EAC9C,aAAa,CAAC,IAAI,EAClB,aAAa,CAAC,MAAM,EACpB,aAAa,CAAC,YAAY,IAAI,IAAI,EAClC,aAAa,CAAC,iBAAiB,IAAI,IAAI,CAC1C,CAAC;IACN,CAAC;IAED,MAAM;QACF,MAAM,aAAa,GAAkB;YACjC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,IAAA,oCAAwB,EAAC,IAAI,CAAC,IAAI,CAAC;YACzC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,GAAG,CAAC,IAAI,CAAC,YAAY,KAAK,IAAI,IAAI,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC;YACtE,GAAG,CAAC,IAAI,CAAC,iBAAiB,KAAK,IAAI,IAAI,EAAE,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC;SACxF,CAAC;QACF,OAAO,aAAa,CAAC;IACzB,CAAC;CACJ;AAlDD,8BAkDC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { modelTypeFromNapiModelType, modelTypeToNapiModelType } from "./modelType.mjs";
|
|
2
|
+
export class ChatModel {
|
|
3
|
+
get isThinking() {
|
|
4
|
+
return this.outputParserRegex !== null;
|
|
5
|
+
}
|
|
6
|
+
constructor(repoId, type, name, vendor, quantization, outputParserRegex) {
|
|
7
|
+
this.repoId = repoId;
|
|
8
|
+
this.type = type;
|
|
9
|
+
this.name = name;
|
|
10
|
+
this.vendor = vendor;
|
|
11
|
+
this.quantization = quantization;
|
|
12
|
+
this.outputParserRegex = outputParserRegex;
|
|
13
|
+
}
|
|
14
|
+
static fromNapiChatModel(napiChatModel) {
|
|
15
|
+
return new ChatModel(napiChatModel.repoId, modelTypeFromNapiModelType(napiChatModel.type), napiChatModel.name, napiChatModel.vendor, napiChatModel.quantization ?? null, napiChatModel.outputParserRegex ?? null);
|
|
16
|
+
}
|
|
17
|
+
toNapi() {
|
|
18
|
+
const napiChatModel = {
|
|
19
|
+
repoId: this.repoId,
|
|
20
|
+
type: modelTypeToNapiModelType(this.type),
|
|
21
|
+
name: this.name,
|
|
22
|
+
vendor: this.vendor,
|
|
23
|
+
...(this.quantization !== null && { quantization: this.quantization }),
|
|
24
|
+
...(this.outputParserRegex !== null && { outputParserRegex: this.outputParserRegex }),
|
|
25
|
+
};
|
|
26
|
+
return napiChatModel;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=chatModel.mjs.map
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,IAAI,EAAE,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC;SACxF,CAAC;QACF,OAAO,aAAa,CAAC;IACzB,CAAC;CACJ"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ChatSession as NapiChatSession } from "../napi/uzu.mjs";
|
|
2
|
+
import { Input } from "./input.mjs";
|
|
3
|
+
import { Output } from "./output.mjs";
|
|
4
|
+
import { RunConfig } from "./runConfig.mjs";
|
|
5
|
+
export declare class ChatSession {
|
|
6
|
+
private readonly napiChatSession;
|
|
7
|
+
constructor(napiChatSession: NapiChatSession);
|
|
8
|
+
run(input: Input, config?: RunConfig, progress?: (partialOutput: Output) => boolean): Output;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=chatSession.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatSession.d.mts","sourceRoot":"","sources":["../src/bridging/chatSession.ts"],"names":[],"mappings":"OAAO,EAAE,WAAW,IAAI,eAAe,EAAwB;OACxD,EAAE,KAAK,EAAE;OACT,EAAE,MAAM,EAAE;OACV,EAAE,SAAS,EAAE;AAEpB,qBAAa,WAAW;IACpB,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAkB;gBAEtC,eAAe,EAAE,eAAe;IAI5C,GAAG,CACC,KAAK,EAAE,KAAK,EACZ,MAAM,GAAE,SAA+B,EACvC,QAAQ,GAAE,CAAC,aAAa,EAAE,MAAM,KAAK,OAAoB,GAC1D,MAAM;CAOZ"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ChatSession as NapiChatSession } from "../napi/uzu.js";
|
|
2
|
+
import { Input } from "./input.js";
|
|
3
|
+
import { Output } from "./output.js";
|
|
4
|
+
import { RunConfig } from "./runConfig.js";
|
|
5
|
+
export declare class ChatSession {
|
|
6
|
+
private readonly napiChatSession;
|
|
7
|
+
constructor(napiChatSession: NapiChatSession);
|
|
8
|
+
run(input: Input, config?: RunConfig, progress?: (partialOutput: Output) => boolean): Output;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=chatSession.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatSession.d.ts","sourceRoot":"","sources":["../src/bridging/chatSession.ts"],"names":[],"mappings":"OAAO,EAAE,WAAW,IAAI,eAAe,EAAwB;OACxD,EAAE,KAAK,EAAE;OACT,EAAE,MAAM,EAAE;OACV,EAAE,SAAS,EAAE;AAEpB,qBAAa,WAAW;IACpB,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAkB;gBAEtC,eAAe,EAAE,eAAe;IAI5C,GAAG,CACC,KAAK,EAAE,KAAK,EACZ,MAAM,GAAE,SAA+B,EACvC,QAAQ,GAAE,CAAC,aAAa,EAAE,MAAM,KAAK,OAAoB,GAC1D,MAAM;CAOZ"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ChatSession = void 0;
|
|
4
4
|
const output_1 = require("./output.js");
|
|
5
5
|
const runConfig_1 = require("./runConfig.js");
|
|
6
|
-
class
|
|
7
|
-
constructor(
|
|
8
|
-
this.
|
|
6
|
+
class ChatSession {
|
|
7
|
+
constructor(napiChatSession) {
|
|
8
|
+
this.napiChatSession = napiChatSession;
|
|
9
9
|
}
|
|
10
10
|
run(input, config = runConfig_1.RunConfig.default(), progress = () => true) {
|
|
11
11
|
const napiInput = input.toNapi();
|
|
12
12
|
const napiConfig = config.toNapi();
|
|
13
13
|
const napiProgress = (partialOutput) => progress(output_1.Output.fromNapi(partialOutput));
|
|
14
|
-
const napiOutput = this.
|
|
14
|
+
const napiOutput = this.napiChatSession.run(napiInput, napiConfig, napiProgress);
|
|
15
15
|
return output_1.Output.fromNapi(napiOutput);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
exports.
|
|
19
|
-
//# sourceMappingURL=
|
|
18
|
+
exports.ChatSession = ChatSession;
|
|
19
|
+
//# sourceMappingURL=chatSession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatSession.js","sourceRoot":"","sources":["../src/bridging/chatSession.ts"],"names":[],"mappings":";;;AAEA,wCAAkC;AAClC,8CAAwC;AAExC,MAAa,WAAW;IAGpB,YAAY,eAAgC;QACxC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IAC3C,CAAC;IAED,GAAG,CACC,KAAY,EACZ,SAAoB,qBAAS,CAAC,OAAO,EAAE,EACvC,WAA+C,GAAG,EAAE,CAAC,IAAI;QAEzD,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QACjC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QACnC,MAAM,YAAY,GAAG,CAAC,aAAyB,EAAE,EAAE,CAAC,QAAQ,CAAC,eAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;QAC7F,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;QACjF,OAAO,eAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC;CACJ;AAlBD,kCAkBC"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Output } from "./output.mjs";
|
|
2
2
|
import { RunConfig } from "./runConfig.mjs";
|
|
3
|
-
export class
|
|
4
|
-
constructor(
|
|
5
|
-
this.
|
|
3
|
+
export class ChatSession {
|
|
4
|
+
constructor(napiChatSession) {
|
|
5
|
+
this.napiChatSession = napiChatSession;
|
|
6
6
|
}
|
|
7
7
|
run(input, config = RunConfig.default(), progress = () => true) {
|
|
8
8
|
const napiInput = input.toNapi();
|
|
9
9
|
const napiConfig = config.toNapi();
|
|
10
10
|
const napiProgress = (partialOutput) => progress(Output.fromNapi(partialOutput));
|
|
11
|
-
const napiOutput = this.
|
|
11
|
+
const napiOutput = this.napiChatSession.run(napiInput, napiConfig, napiProgress);
|
|
12
12
|
return Output.fromNapi(napiOutput);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
//# sourceMappingURL=
|
|
15
|
+
//# sourceMappingURL=chatSession.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatSession.mjs","sourceRoot":"","sources":["../src/bridging/chatSession.ts"],"names":[],"mappings":"OAEO,EAAE,MAAM,EAAE;OACV,EAAE,SAAS,EAAE;AAEpB,MAAM,OAAO,WAAW;IAGpB,YAAY,eAAgC;QACxC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IAC3C,CAAC;IAED,GAAG,CACC,KAAY,EACZ,SAAoB,SAAS,CAAC,OAAO,EAAE,EACvC,WAA+C,GAAG,EAAE,CAAC,IAAI;QAEzD,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QACjC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QACnC,MAAM,YAAY,GAAG,CAAC,aAAyB,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;QAC7F,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;QACjF,OAAO,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC;CACJ"}
|
package/bridging/engine.d.mts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { EngineInteractor } from "../interactors/engineInteractor.mjs";
|
|
2
|
+
import { ChatModel } from "./chatModel.mjs";
|
|
3
|
+
import { ChatSession } from "./chatSession.mjs";
|
|
2
4
|
import { Config } from "./config.mjs";
|
|
3
5
|
import { DownloadHandle } from "./downloadHandle.mjs";
|
|
4
|
-
import {
|
|
6
|
+
import { DownloadProgressUpdate } from "./downloadProgressUpdate.mjs";
|
|
7
|
+
import { DownloadState } from "./downloadState.mjs";
|
|
5
8
|
import { ModelType } from "./modelType.mjs";
|
|
6
|
-
import { Session } from "./session.mjs";
|
|
7
9
|
export declare class Engine {
|
|
8
10
|
private readonly napiEngine;
|
|
9
11
|
private constructor();
|
|
10
12
|
static load(apiKey?: string | undefined): Promise<Engine>;
|
|
11
13
|
static create(apiKey?: string | undefined): EngineInteractor;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
deleteModel(repoId: string): Promise<void>;
|
|
19
|
-
getState(repoId: string): import("../napi/uzu").ModelDownloadState;
|
|
14
|
+
getDownloadState(repoId: string): DownloadState;
|
|
15
|
+
downloadHandle(repoId: string): DownloadHandle;
|
|
16
|
+
chatModels(types?: ModelType[] | null): Promise<ChatModel[]>;
|
|
17
|
+
chatModel(repoId: string, types?: ModelType[] | null): Promise<ChatModel>;
|
|
18
|
+
downloadChatModel(chatModel: ChatModel, progress?: (progressUpdate: DownloadProgressUpdate) => void): Promise<DownloadState>;
|
|
19
|
+
chatSession(chatModel: ChatModel, config?: Config): ChatSession;
|
|
20
20
|
}
|
|
21
21
|
//# sourceMappingURL=engine.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.mts","sourceRoot":"","sources":["../src/bridging/engine.ts"],"names":[],"mappings":"OACO,EAAE,gBAAgB,EAAE;OAGpB,EAAE,
|
|
1
|
+
{"version":3,"file":"engine.d.mts","sourceRoot":"","sources":["../src/bridging/engine.ts"],"names":[],"mappings":"OACO,EAAE,gBAAgB,EAAE;OAGpB,EAAE,SAAS,EAAE;OACb,EAAE,WAAW,EAAE;OACf,EAAE,MAAM,EAAE;OACV,EAAE,cAAc,EAAE;OAClB,EAAE,sBAAsB,EAAE;OAC1B,EAAiB,aAAa,EAAE;OAEhC,EAAE,SAAS,EAA4B;AAE9C,qBAAa,MAAM;IACf,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IAExC,OAAO;WAIM,IAAI,CAAC,MAAM,GAAE,MAAM,GAAG,SAAqB,GAAG,OAAO,CAAC,MAAM,CAAC;IAqB1E,MAAM,CAAC,MAAM,CAAC,MAAM,GAAE,MAAM,GAAG,SAAqB,GAAG,gBAAgB;IAOvE,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa;IAK/C,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc;IAIxC,UAAU,CAAC,KAAK,GAAE,SAAS,EAAE,GAAG,IAAW,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAQlE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,GAAE,SAAS,EAAE,GAAG,IAAW,GAAG,OAAO,CAAC,SAAS,CAAC;IAM/E,iBAAiB,CACnB,SAAS,EAAE,SAAS,EACpB,QAAQ,GAAE,CAAC,cAAc,EAAE,sBAAsB,KAAK,IAAe,GACtE,OAAO,CAAC,aAAa,CAAC;IAyBzB,WAAW,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,GAAE,MAAyB,GAAG,WAAW;CAKpF"}
|
package/bridging/engine.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { EngineInteractor } from "../interactors/engineInteractor.js";
|
|
2
|
+
import { ChatModel } from "./chatModel.js";
|
|
3
|
+
import { ChatSession } from "./chatSession.js";
|
|
2
4
|
import { Config } from "./config.js";
|
|
3
5
|
import { DownloadHandle } from "./downloadHandle.js";
|
|
4
|
-
import {
|
|
6
|
+
import { DownloadProgressUpdate } from "./downloadProgressUpdate.js";
|
|
7
|
+
import { DownloadState } from "./downloadState.js";
|
|
5
8
|
import { ModelType } from "./modelType.js";
|
|
6
|
-
import { Session } from "./session.js";
|
|
7
9
|
export declare class Engine {
|
|
8
10
|
private readonly napiEngine;
|
|
9
11
|
private constructor();
|
|
10
12
|
static load(apiKey?: string | undefined): Promise<Engine>;
|
|
11
13
|
static create(apiKey?: string | undefined): EngineInteractor;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
deleteModel(repoId: string): Promise<void>;
|
|
19
|
-
getState(repoId: string): import("../napi/uzu").ModelDownloadState;
|
|
14
|
+
getDownloadState(repoId: string): DownloadState;
|
|
15
|
+
downloadHandle(repoId: string): DownloadHandle;
|
|
16
|
+
chatModels(types?: ModelType[] | null): Promise<ChatModel[]>;
|
|
17
|
+
chatModel(repoId: string, types?: ModelType[] | null): Promise<ChatModel>;
|
|
18
|
+
downloadChatModel(chatModel: ChatModel, progress?: (progressUpdate: DownloadProgressUpdate) => void): Promise<DownloadState>;
|
|
19
|
+
chatSession(chatModel: ChatModel, config?: Config): ChatSession;
|
|
20
20
|
}
|
|
21
21
|
//# sourceMappingURL=engine.d.ts.map
|
package/bridging/engine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/bridging/engine.ts"],"names":[],"mappings":"OACO,EAAE,gBAAgB,EAAE;OAGpB,EAAE,
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/bridging/engine.ts"],"names":[],"mappings":"OACO,EAAE,gBAAgB,EAAE;OAGpB,EAAE,SAAS,EAAE;OACb,EAAE,WAAW,EAAE;OACf,EAAE,MAAM,EAAE;OACV,EAAE,cAAc,EAAE;OAClB,EAAE,sBAAsB,EAAE;OAC1B,EAAiB,aAAa,EAAE;OAEhC,EAAE,SAAS,EAA4B;AAE9C,qBAAa,MAAM;IACf,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IAExC,OAAO;WAIM,IAAI,CAAC,MAAM,GAAE,MAAM,GAAG,SAAqB,GAAG,OAAO,CAAC,MAAM,CAAC;IAqB1E,MAAM,CAAC,MAAM,CAAC,MAAM,GAAE,MAAM,GAAG,SAAqB,GAAG,gBAAgB;IAOvE,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa;IAK/C,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc;IAIxC,UAAU,CAAC,KAAK,GAAE,SAAS,EAAE,GAAG,IAAW,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAQlE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,GAAE,SAAS,EAAE,GAAG,IAAW,GAAG,OAAO,CAAC,SAAS,CAAC;IAM/E,iBAAiB,CACnB,SAAS,EAAE,SAAS,EACpB,QAAQ,GAAE,CAAC,cAAc,EAAE,sBAAsB,KAAK,IAAe,GACtE,OAAO,CAAC,aAAa,CAAC;IAyBzB,WAAW,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,GAAE,MAAyB,GAAG,WAAW;CAKpF"}
|
package/bridging/engine.js
CHANGED
|
@@ -5,12 +5,13 @@ const error_1 = require("../error.js");
|
|
|
5
5
|
const engineInteractor_1 = require("../interactors/engineInteractor.js");
|
|
6
6
|
const uzu_1 = require("../napi/uzu.js");
|
|
7
7
|
const env_1 = require("../utilities/env.js");
|
|
8
|
+
const chatModel_1 = require("./chatModel.js");
|
|
9
|
+
const chatSession_1 = require("./chatSession.js");
|
|
8
10
|
const config_1 = require("./config.js");
|
|
9
11
|
const downloadHandle_1 = require("./downloadHandle.js");
|
|
12
|
+
const downloadState_1 = require("./downloadState.js");
|
|
10
13
|
const licenseStatus_1 = require("./licenseStatus.js");
|
|
11
|
-
const model_1 = require("./model.js");
|
|
12
14
|
const modelType_1 = require("./modelType.js");
|
|
13
|
-
const session_1 = require("./session.js");
|
|
14
15
|
class Engine {
|
|
15
16
|
constructor(napiEngine) {
|
|
16
17
|
this.napiEngine = napiEngine;
|
|
@@ -35,54 +36,51 @@ class Engine {
|
|
|
35
36
|
})();
|
|
36
37
|
return new engineInteractor_1.EngineInteractor(enginePromise);
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (isTypeAllowed(modelType_1.ModelType.Cloud) && isKindAllowed(model_1.ModelKind.Text)) {
|
|
51
|
-
const napiCloudModels = await this.napiEngine.getCloudModels();
|
|
52
|
-
results.push(...napiCloudModels.map(model_1.Model.fromNapiCloudModel));
|
|
53
|
-
}
|
|
39
|
+
getDownloadState(repoId) {
|
|
40
|
+
let downloadState = this.napiEngine.getModelDownloadState(repoId);
|
|
41
|
+
return downloadState_1.DownloadState.fromNapi(downloadState);
|
|
42
|
+
}
|
|
43
|
+
downloadHandle(repoId) {
|
|
44
|
+
return new downloadHandle_1.DownloadHandle(this.napiEngine.createModelDownloadHandle(repoId));
|
|
45
|
+
}
|
|
46
|
+
async chatModels(types = null) {
|
|
47
|
+
let typesToFilter = types ?? [modelType_1.ModelType.Local, modelType_1.ModelType.Cloud];
|
|
48
|
+
let napiModelTypes = typesToFilter.map(modelType_1.modelTypeToNapiModelType);
|
|
49
|
+
let napiChatModels = await this.napiEngine.getChatModels(napiModelTypes);
|
|
50
|
+
let results = napiChatModels.map(chatModel_1.ChatModel.fromNapiChatModel);
|
|
54
51
|
return results;
|
|
55
52
|
}
|
|
56
|
-
async
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
return (0, error_1.unwrapOrThrow)(
|
|
53
|
+
async chatModel(repoId, types = null) {
|
|
54
|
+
const chatModels = await this.chatModels(types);
|
|
55
|
+
const chatModel = chatModels.find((model) => model.repoId === repoId);
|
|
56
|
+
return (0, error_1.unwrapOrThrow)(chatModel, error_1.EngineErrorCode.ModelNotFound);
|
|
60
57
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
async downloadChatModel(chatModel, progress = () => { }) {
|
|
59
|
+
switch (chatModel.type) {
|
|
60
|
+
case modelType_1.ModelType.Local:
|
|
61
|
+
break;
|
|
62
|
+
case modelType_1.ModelType.Cloud:
|
|
63
|
+
throw new error_1.EngineError(error_1.EngineErrorCode.UnexpectedModelType);
|
|
64
64
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
const downloadHandle = this.downloadHandle(chatModel.repoId);
|
|
66
|
+
const state = await downloadHandle.state();
|
|
67
|
+
switch (state.phase) {
|
|
68
|
+
case downloadState_1.DownloadPhase.Downloaded:
|
|
69
|
+
break;
|
|
70
|
+
default:
|
|
71
|
+
await downloadHandle.download();
|
|
72
|
+
for await (const progressUpdate of downloadHandle.progressUpdate()) {
|
|
73
|
+
progress(progressUpdate);
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
70
76
|
}
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
return new session_1.Session(this.napiEngine.createSession(model.repoId, napiModelType, napiConfig));
|
|
77
|
+
const finalState = await downloadHandle.state();
|
|
78
|
+
return finalState;
|
|
74
79
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
await this.napiEngine.pauseModel(repoId);
|
|
80
|
-
}
|
|
81
|
-
async deleteModel(repoId) {
|
|
82
|
-
await this.napiEngine.deleteModel(repoId);
|
|
83
|
-
}
|
|
84
|
-
getState(repoId) {
|
|
85
|
-
return this.napiEngine.getState(repoId);
|
|
80
|
+
chatSession(chatModel, config = config_1.Config.default()) {
|
|
81
|
+
const napiChatModel = chatModel.toNapi();
|
|
82
|
+
const napiConfig = config.toNapi();
|
|
83
|
+
return new chatSession_1.ChatSession(this.napiEngine.createChatSession(napiChatModel, napiConfig));
|
|
86
84
|
}
|
|
87
85
|
}
|
|
88
86
|
exports.Engine = Engine;
|
package/bridging/engine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/bridging/engine.ts"],"names":[],"mappings":";;;AAAA,uCAAuE;AACvE,yEAAmE;AACnE,wCAAmD;AACnD,6CAA2C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