@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.
Files changed (143) hide show
  1. package/README.md +30 -6
  2. package/bridging/chatModel.d.mts +15 -0
  3. package/bridging/chatModel.d.mts.map +1 -0
  4. package/bridging/chatModel.d.ts +15 -0
  5. package/bridging/chatModel.d.ts.map +1 -0
  6. package/bridging/chatModel.js +33 -0
  7. package/bridging/chatModel.js.map +1 -0
  8. package/bridging/chatModel.mjs +29 -0
  9. package/bridging/chatModel.mjs.map +1 -0
  10. package/bridging/chatSession.d.mts +10 -0
  11. package/bridging/chatSession.d.mts.map +1 -0
  12. package/bridging/chatSession.d.ts +10 -0
  13. package/bridging/chatSession.d.ts.map +1 -0
  14. package/bridging/{session.js → chatSession.js} +7 -7
  15. package/bridging/chatSession.js.map +1 -0
  16. package/bridging/{session.mjs → chatSession.mjs} +5 -5
  17. package/bridging/chatSession.mjs.map +1 -0
  18. package/bridging/engine.d.mts +10 -10
  19. package/bridging/engine.d.mts.map +1 -1
  20. package/bridging/engine.d.ts +10 -10
  21. package/bridging/engine.d.ts.map +1 -1
  22. package/bridging/engine.js +42 -44
  23. package/bridging/engine.js.map +1 -1
  24. package/bridging/engine.mjs +43 -45
  25. package/bridging/engine.mjs.map +1 -1
  26. package/bridging/modelType.d.mts +2 -1
  27. package/bridging/modelType.d.mts.map +1 -1
  28. package/bridging/modelType.d.ts +2 -1
  29. package/bridging/modelType.d.ts.map +1 -1
  30. package/bridging/modelType.js +14 -2
  31. package/bridging/modelType.js.map +1 -1
  32. package/bridging/modelType.mjs +12 -1
  33. package/bridging/modelType.mjs.map +1 -1
  34. package/error.d.mts +1 -1
  35. package/error.d.mts.map +1 -1
  36. package/error.d.ts +1 -1
  37. package/error.d.ts.map +1 -1
  38. package/error.js +2 -2
  39. package/error.js.map +1 -1
  40. package/error.mjs +2 -2
  41. package/error.mjs.map +1 -1
  42. package/index.d.mts +5 -5
  43. package/index.d.mts.map +1 -1
  44. package/index.d.ts +5 -5
  45. package/index.d.ts.map +1 -1
  46. package/index.js +11 -12
  47. package/index.js.map +1 -1
  48. package/index.mjs +5 -5
  49. package/index.mjs.map +1 -1
  50. package/interactors/{modelInteractor.d.mts → chatModelInteractor.d.mts} +15 -15
  51. package/interactors/chatModelInteractor.d.mts.map +1 -0
  52. package/interactors/{modelInteractor.d.ts → chatModelInteractor.d.ts} +15 -15
  53. package/interactors/chatModelInteractor.d.ts.map +1 -0
  54. package/interactors/{modelInteractor.js → chatModelInteractor.js} +13 -13
  55. package/interactors/chatModelInteractor.js.map +1 -0
  56. package/interactors/{modelInteractor.mjs → chatModelInteractor.mjs} +11 -11
  57. package/interactors/chatModelInteractor.mjs.map +1 -0
  58. package/interactors/chatModelsInteractor.d.mts +12 -0
  59. package/interactors/chatModelsInteractor.d.mts.map +1 -0
  60. package/interactors/chatModelsInteractor.d.ts +12 -0
  61. package/interactors/chatModelsInteractor.d.ts.map +1 -0
  62. package/interactors/{modelsInteractor.js → chatModelsInteractor.js} +6 -6
  63. package/interactors/chatModelsInteractor.js.map +1 -0
  64. package/interactors/{modelsInteractor.mjs → chatModelsInteractor.mjs} +4 -4
  65. package/interactors/chatModelsInteractor.mjs.map +1 -0
  66. package/interactors/chatSessionInteractor.d.mts +24 -0
  67. package/interactors/chatSessionInteractor.d.mts.map +1 -0
  68. package/interactors/chatSessionInteractor.d.ts +24 -0
  69. package/interactors/chatSessionInteractor.d.ts.map +1 -0
  70. package/interactors/{sessionInteractor.js → chatSessionInteractor.js} +8 -8
  71. package/interactors/chatSessionInteractor.js.map +1 -0
  72. package/interactors/{sessionInteractor.mjs → chatSessionInteractor.mjs} +6 -6
  73. package/interactors/chatSessionInteractor.mjs.map +1 -0
  74. package/interactors/downloadInteractor.d.mts +3 -3
  75. package/interactors/downloadInteractor.d.mts.map +1 -1
  76. package/interactors/downloadInteractor.d.ts +3 -3
  77. package/interactors/downloadInteractor.d.ts.map +1 -1
  78. package/interactors/downloadInteractor.js.map +1 -1
  79. package/interactors/downloadInteractor.mjs.map +1 -1
  80. package/interactors/engineInteractor.d.mts +5 -8
  81. package/interactors/engineInteractor.d.mts.map +1 -1
  82. package/interactors/engineInteractor.d.ts +5 -8
  83. package/interactors/engineInteractor.d.ts.map +1 -1
  84. package/interactors/engineInteractor.js +8 -12
  85. package/interactors/engineInteractor.js.map +1 -1
  86. package/interactors/engineInteractor.mjs +8 -12
  87. package/interactors/engineInteractor.mjs.map +1 -1
  88. package/napi/uzu.d.ts +18 -32
  89. package/napi/uzu.js +4 -6
  90. package/napi/uzu.mjs +2 -3
  91. package/napi/uzu.node +0 -0
  92. package/package.json +1 -1
  93. package/src/bridging/chatModel.ts +54 -0
  94. package/src/bridging/{session.ts → chatSession.ts} +6 -6
  95. package/src/bridging/engine.ts +47 -47
  96. package/src/bridging/modelType.ts +13 -1
  97. package/src/error.ts +2 -2
  98. package/src/index.ts +5 -5
  99. package/src/interactors/{modelInteractor.ts → chatModelInteractor.ts} +22 -22
  100. package/src/interactors/{modelsInteractor.ts → chatModelsInteractor.ts} +8 -8
  101. package/src/interactors/{sessionInteractor.ts → chatSessionInteractor.ts} +19 -15
  102. package/src/interactors/downloadInteractor.ts +3 -3
  103. package/src/interactors/engineInteractor.ts +9 -20
  104. package/src/napi/uzu.d.ts +18 -32
  105. package/src/napi/uzu.js +4 -6
  106. package/src/napi/uzu.mjs +2 -3
  107. package/src/napi/uzu.node +0 -0
  108. package/src/version.ts +1 -1
  109. package/version.d.mts +1 -1
  110. package/version.d.ts +1 -1
  111. package/version.js +1 -1
  112. package/version.mjs +1 -1
  113. package/bridging/model.d.mts +0 -18
  114. package/bridging/model.d.mts.map +0 -1
  115. package/bridging/model.d.ts +0 -18
  116. package/bridging/model.d.ts.map +0 -1
  117. package/bridging/model.js +0 -27
  118. package/bridging/model.js.map +0 -1
  119. package/bridging/model.mjs +0 -23
  120. package/bridging/model.mjs.map +0 -1
  121. package/bridging/session.d.mts +0 -10
  122. package/bridging/session.d.mts.map +0 -1
  123. package/bridging/session.d.ts +0 -10
  124. package/bridging/session.d.ts.map +0 -1
  125. package/bridging/session.js.map +0 -1
  126. package/bridging/session.mjs.map +0 -1
  127. package/interactors/modelInteractor.d.mts.map +0 -1
  128. package/interactors/modelInteractor.d.ts.map +0 -1
  129. package/interactors/modelInteractor.js.map +0 -1
  130. package/interactors/modelInteractor.mjs.map +0 -1
  131. package/interactors/modelsInteractor.d.mts +0 -12
  132. package/interactors/modelsInteractor.d.mts.map +0 -1
  133. package/interactors/modelsInteractor.d.ts +0 -12
  134. package/interactors/modelsInteractor.d.ts.map +0 -1
  135. package/interactors/modelsInteractor.js.map +0 -1
  136. package/interactors/modelsInteractor.mjs.map +0 -1
  137. package/interactors/sessionInteractor.d.mts +0 -24
  138. package/interactors/sessionInteractor.d.mts.map +0 -1
  139. package/interactors/sessionInteractor.d.ts +0 -24
  140. package/interactors/sessionInteractor.d.ts.map +0 -1
  141. package/interactors/sessionInteractor.js.map +0 -1
  142. package/interactors/sessionInteractor.mjs.map +0 -1
  143. 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="mailto:alexey@getmirai.co,dima@getmirai.co,aleksei@getmirai.co?subject=Interested%20in%20Mirai"><img src="https://img.shields.io/badge/Send-Email-green" alt="Contact us"></a>
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
  [![npm (scoped)](https://img.shields.io/npm/v/%40trymirai%2Fuzu)](https://www.npmjs.com/package/@trymirai/uzu)
12
13
  [![License](https://img.shields.io/badge/License-MIT-blue)](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.39"
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
- .model('Qwen/Qwen3-0.6B')
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
- .model('Qwen/Qwen3-0.6B')
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
- .model('Qwen/Qwen3-0.6B')
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
- .model('Qwen/Qwen3-0.6B')
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
@@ -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.Session = void 0;
3
+ exports.ChatSession = void 0;
4
4
  const output_1 = require("./output.js");
5
5
  const runConfig_1 = require("./runConfig.js");
6
- class Session {
7
- constructor(napiSession) {
8
- this.napiSession = napiSession;
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.napiSession.run(napiInput, napiConfig, napiProgress);
14
+ const napiOutput = this.napiChatSession.run(napiInput, napiConfig, napiProgress);
15
15
  return output_1.Output.fromNapi(napiOutput);
16
16
  }
17
17
  }
18
- exports.Session = Session;
19
- //# sourceMappingURL=session.js.map
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 Session {
4
- constructor(napiSession) {
5
- this.napiSession = napiSession;
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.napiSession.run(napiInput, napiConfig, napiProgress);
11
+ const napiOutput = this.napiChatSession.run(napiInput, napiConfig, napiProgress);
12
12
  return Output.fromNapi(napiOutput);
13
13
  }
14
14
  }
15
- //# sourceMappingURL=session.mjs.map
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"}
@@ -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 { Model, ModelKind } from "./model.mjs";
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
- models(types?: ModelType[] | null, kinds?: ModelKind[] | null): Promise<Model[]>;
13
- model(repoId: string): Promise<Model>;
14
- downloadHandle(model: Model): DownloadHandle;
15
- session(model: Model, config?: Config): Session;
16
- downloadModel(repoId: string): Promise<void>;
17
- pauseModel(repoId: string): Promise<void>;
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,MAAM,EAAE;OACV,EAAE,cAAc,EAAE;OAElB,EAAE,KAAK,EAAE,SAAS,EAAE;OACpB,EAAE,SAAS,EAAmB;OAC9B,EAAE,OAAO,EAAE;AAElB,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,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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"}
@@ -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 { Model, ModelKind } from "./model.js";
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
- models(types?: ModelType[] | null, kinds?: ModelKind[] | null): Promise<Model[]>;
13
- model(repoId: string): Promise<Model>;
14
- downloadHandle(model: Model): DownloadHandle;
15
- session(model: Model, config?: Config): Session;
16
- downloadModel(repoId: string): Promise<void>;
17
- pauseModel(repoId: string): Promise<void>;
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
@@ -1 +1 @@
1
- {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/bridging/engine.ts"],"names":[],"mappings":"OACO,EAAE,gBAAgB,EAAE;OAGpB,EAAE,MAAM,EAAE;OACV,EAAE,cAAc,EAAE;OAElB,EAAE,KAAK,EAAE,SAAS,EAAE;OACpB,EAAE,SAAS,EAAmB;OAC9B,EAAE,OAAO,EAAE;AAElB,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;IAOjE,MAAM,CAAC,KAAK,GAAE,SAAS,EAAE,GAAG,IAAW,EAAE,KAAK,GAAE,SAAS,EAAE,GAAG,IAAW,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAqB5F,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAM3C,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,cAAc;IAO5C,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,GAAE,MAAyB,GAAG,OAAO;IAS3D,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5C,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzC,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhD,QAAQ,CAAC,MAAM,EAAE,MAAM;CAG1B"}
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"}
@@ -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
- async models(types = null, kinds = null) {
39
- function isTypeAllowed(type) {
40
- return types === null || types.includes(type);
41
- }
42
- function isKindAllowed(kind) {
43
- return kinds === null || kinds.includes(kind);
44
- }
45
- let results = [];
46
- if (isTypeAllowed(modelType_1.ModelType.Local) && isKindAllowed(model_1.ModelKind.Text)) {
47
- const napiLocalModels = this.napiEngine.getLocalModels();
48
- results.push(...napiLocalModels.map(model_1.Model.fromNapiLocalModel));
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 model(repoId) {
57
- const models = await this.models();
58
- const model = models.find((model) => model.repoId === repoId);
59
- return (0, error_1.unwrapOrThrow)(model, error_1.EngineErrorCode.ModelNotFound);
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
- downloadHandle(model) {
62
- if (model.type !== modelType_1.ModelType.Local) {
63
- throw new error_1.EngineError(error_1.EngineErrorCode.ExpectedLocalModel);
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
- return new downloadHandle_1.DownloadHandle(this.napiEngine.downloadHandle(model.repoId));
66
- }
67
- session(model, config = config_1.Config.default()) {
68
- if (model.kind !== model_1.ModelKind.Text) {
69
- throw new error_1.EngineError(error_1.EngineErrorCode.ExpectedTextModel);
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 napiModelType = (0, modelType_1.modelTypeToNapi)(model.type);
72
- const napiConfig = config.toNapi();
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
- async downloadModel(repoId) {
76
- await this.napiEngine.downloadModel(repoId);
77
- }
78
- async pauseModel(repoId) {
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;
@@ -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;AAClD,sDAAoF;AACpF,sCAA2C;AAC3C,8CAAyD;AACzD,0CAAoC;AAEpC,MAAa,MAAM;IAGf,YAAoB,UAAsB;QACtC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAA6B,SAAS;QACpD,MAAM,cAAc,GAAG,IAAA,qBAAa,EAChC,MAAM,IAAI,IAAA,aAAO,EAAC,eAAe,CAAC,EAClC,uBAAe,CAAC,cAAc,CACjC,CAAC;QAEF,MAAM,UAAU,GAAG,IAAI,YAAU,EAAE,CAAC;QAEpC,MAAM,iBAAiB,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;QACpE,MAAM,aAAa,GAAG,IAAA,kDAAkC,EAAC,iBAAiB,CAAC,CAAC;QAC5E,QAAQ,aAAa,EAAE,CAAC;YACpB,KAAK,6BAAa,CAAC,SAAS,CAAC;YAC7B,KAAK,6BAAa,CAAC,iBAAiB;gBAChC,MAAM;YACV;gBACI,MAAM,IAAI,mBAAW,CAAC,uBAAe,CAAC,mBAAmB,CAAC,CAAC;QACnE,CAAC;QAED,OAAO,IAAI,MAAM,CAAC,UAAU,CAAC,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,SAA6B,SAAS;QAChD,MAAM,aAAa,GAAG,CAAC,KAAK,IAAI,EAAE;YAC9B,OAAO,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CA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