@trymirai/uzu 0.1.39 → 0.1.40
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 +5 -5
- 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
|
@@ -25,7 +25,7 @@ Add the `uzu` dependency to your project's `package.json`:
|
|
|
25
25
|
|
|
26
26
|
```json
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@trymirai/uzu": "0.1.
|
|
28
|
+
"@trymirai/uzu": "0.1.40"
|
|
29
29
|
}
|
|
30
30
|
```
|
|
31
31
|
|
|
@@ -34,7 +34,7 @@ Set up your project through [Platform](https://platform.trymirai.com) and obtain
|
|
|
34
34
|
```ts
|
|
35
35
|
const output = await Engine
|
|
36
36
|
.create('API_KEY')
|
|
37
|
-
.
|
|
37
|
+
.chatModel('Qwen/Qwen3-0.6B')
|
|
38
38
|
.reply('Tell me a short, funny story about a robot');
|
|
39
39
|
```
|
|
40
40
|
|
|
@@ -59,7 +59,7 @@ import Engine, { Message } from '@trymirai/uzu';
|
|
|
59
59
|
|
|
60
60
|
async function main() {
|
|
61
61
|
const output = await Engine.create('API_KEY')
|
|
62
|
-
.
|
|
62
|
+
.chatModel('Qwen/Qwen3-0.6B')
|
|
63
63
|
.download((update) => {
|
|
64
64
|
console.log('Progress:', update.progress);
|
|
65
65
|
})
|
|
@@ -93,7 +93,7 @@ async function main() {
|
|
|
93
93
|
const prompt = `Text is: "${textToSummarize}". Write only summary itself.`;
|
|
94
94
|
|
|
95
95
|
const output = await Engine.create('API_KEY')
|
|
96
|
-
.
|
|
96
|
+
.chatModel('Qwen/Qwen3-0.6B')
|
|
97
97
|
.download((update) => {
|
|
98
98
|
console.log('Progress:', update.progress);
|
|
99
99
|
})
|
|
@@ -142,7 +142,7 @@ async function main() {
|
|
|
142
142
|
"Answer with one word. Don't add a dot at the end.";
|
|
143
143
|
|
|
144
144
|
const output = await Engine.create('API_KEY')
|
|
145
|
-
.
|
|
145
|
+
.chatModel('Qwen/Qwen3-0.6B')
|
|
146
146
|
.download((update) => {
|
|
147
147
|
console.log('Progress:', update.progress);
|
|
148
148
|
})
|
|
@@ -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,iBAAi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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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatModel.mjs","sourceRoot":"","sources":["../src/bridging/chatModel.ts"],"names":[],"mappings":"OACO,EAAa,0BAA0B,EAAE,wBAAwB,EAAE;AAE1E,MAAM,OAAO,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,0BAA0B,CAAC,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,wBAAwB,CAAC,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"}
|
|
@@ -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;AAC3C,wCAAkC;AAClC,wDAAkD;
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/bridging/engine.ts"],"names":[],"mappings":";;;AAAA,uCAAuE;AACvE,yEAAmE;AACnE,wCAAmD;AACnD,6CAA2C;AAC3C,8CAAwC;AACxC,kDAA4C;AAC5C,wCAAkC;AAClC,wDAAkD;AAElD,sDAA+D;AAC/D,sDAAoF;AACpF,8CAAkE;AAElE,MAAa,MAAM;IAGf,YAAoB,UAAsB;QACtC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;IAED,MAAM,CAAC,KAA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I,KAAK,EAAE,MAAM,cAAc,IAAI,cAAc,CAAC,cAAc,EAAE,EAAE,CAAC;oBACjE,QAAQ,CAAC,cAAc,CAAC,CAAC;gBAC7B,CAAC;gBACD,MAAM;QACd,CAAC;QAED,MAAM,UAAU,GAAG,MAAM,cAAc,CAAC,KAAK,EAAE,CAAC;QAChD,OAAO,UAAU,CAAC;IACtB,CAAC;IAED,WAAW,CAAC,SAAoB,EAAE,SAAiB,eAAM,CAAC,OAAO,EAAE;QAC/D,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC;QACzC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QACnC,OAAO,IAAI,yBAAW,CAAC,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC,CAAC;IACzF,CAAC;CACJ;AA3FD,wBA2FC"}
|
package/bridging/engine.mjs
CHANGED
|
@@ -2,12 +2,13 @@ import { EngineError, EngineErrorCode, unwrapOrThrow } from "../error.mjs";
|
|
|
2
2
|
import { EngineInteractor } from "../interactors/engineInteractor.mjs";
|
|
3
3
|
import { Engine as NapiEngine } from "../napi/uzu.mjs";
|
|
4
4
|
import { readEnv } from "../utilities/env.mjs";
|
|
5
|
+
import { ChatModel } from "./chatModel.mjs";
|
|
6
|
+
import { ChatSession } from "./chatSession.mjs";
|
|
5
7
|
import { Config } from "./config.mjs";
|
|
6
8
|
import { DownloadHandle } from "./downloadHandle.mjs";
|
|
9
|
+
import { DownloadPhase, DownloadState } from "./downloadState.mjs";
|
|
7
10
|
import { LicenseStatus, licenseStatusFromNapiLicenseStatus } from "./licenseStatus.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import { ModelType, modelTypeToNapi } from "./modelType.mjs";
|
|
10
|
-
import { Session } from "./session.mjs";
|
|
11
|
+
import { ModelType, modelTypeToNapiModelType } from "./modelType.mjs";
|
|
11
12
|
export class Engine {
|
|
12
13
|
constructor(napiEngine) {
|
|
13
14
|
this.napiEngine = napiEngine;
|
|
@@ -32,54 +33,51 @@ export class Engine {
|
|
|
32
33
|
})();
|
|
33
34
|
return new EngineInteractor(enginePromise);
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (isTypeAllowed(ModelType.Cloud) && isKindAllowed(ModelKind.Text)) {
|
|
48
|
-
const napiCloudModels = await this.napiEngine.getCloudModels();
|
|
49
|
-
results.push(...napiCloudModels.map(Model.fromNapiCloudModel));
|
|
50
|
-
}
|
|
36
|
+
getDownloadState(repoId) {
|
|
37
|
+
let downloadState = this.napiEngine.getModelDownloadState(repoId);
|
|
38
|
+
return DownloadState.fromNapi(downloadState);
|
|
39
|
+
}
|
|
40
|
+
downloadHandle(repoId) {
|
|
41
|
+
return new DownloadHandle(this.napiEngine.createModelDownloadHandle(repoId));
|
|
42
|
+
}
|
|
43
|
+
async chatModels(types = null) {
|
|
44
|
+
let typesToFilter = types ?? [ModelType.Local, ModelType.Cloud];
|
|
45
|
+
let napiModelTypes = typesToFilter.map(modelTypeToNapiModelType);
|
|
46
|
+
let napiChatModels = await this.napiEngine.getChatModels(napiModelTypes);
|
|
47
|
+
let results = napiChatModels.map(ChatModel.fromNapiChatModel);
|
|
51
48
|
return results;
|
|
52
49
|
}
|
|
53
|
-
async
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
return unwrapOrThrow(
|
|
50
|
+
async chatModel(repoId, types = null) {
|
|
51
|
+
const chatModels = await this.chatModels(types);
|
|
52
|
+
const chatModel = chatModels.find((model) => model.repoId === repoId);
|
|
53
|
+
return unwrapOrThrow(chatModel, EngineErrorCode.ModelNotFound);
|
|
57
54
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
async downloadChatModel(chatModel, progress = () => { }) {
|
|
56
|
+
switch (chatModel.type) {
|
|
57
|
+
case ModelType.Local:
|
|
58
|
+
break;
|
|
59
|
+
case ModelType.Cloud:
|
|
60
|
+
throw new EngineError(EngineErrorCode.UnexpectedModelType);
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
const downloadHandle = this.downloadHandle(chatModel.repoId);
|
|
63
|
+
const state = await downloadHandle.state();
|
|
64
|
+
switch (state.phase) {
|
|
65
|
+
case DownloadPhase.Downloaded:
|
|
66
|
+
break;
|
|
67
|
+
default:
|
|
68
|
+
await downloadHandle.download();
|
|
69
|
+
for await (const progressUpdate of downloadHandle.progressUpdate()) {
|
|
70
|
+
progress(progressUpdate);
|
|
71
|
+
}
|
|
72
|
+
break;
|
|
67
73
|
}
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
return new Session(this.napiEngine.createSession(model.repoId, napiModelType, napiConfig));
|
|
74
|
+
const finalState = await downloadHandle.state();
|
|
75
|
+
return finalState;
|
|
71
76
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
await this.napiEngine.pauseModel(repoId);
|
|
77
|
-
}
|
|
78
|
-
async deleteModel(repoId) {
|
|
79
|
-
await this.napiEngine.deleteModel(repoId);
|
|
80
|
-
}
|
|
81
|
-
getState(repoId) {
|
|
82
|
-
return this.napiEngine.getState(repoId);
|
|
77
|
+
chatSession(chatModel, config = Config.default()) {
|
|
78
|
+
const napiChatModel = chatModel.toNapi();
|
|
79
|
+
const napiConfig = config.toNapi();
|
|
80
|
+
return new ChatSession(this.napiEngine.createChatSession(napiChatModel, napiConfig));
|
|
83
81
|
}
|
|
84
82
|
}
|
|
85
83
|
//# sourceMappingURL=engine.mjs.map
|
package/bridging/engine.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.mjs","sourceRoot":"","sources":["../src/bridging/engine.ts"],"names":[],"mapp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