@eclipse-lyra/extension-webllm 0.7.22 → 0.7.23
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/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ extensionRegistry.registerExtension({
|
|
|
5
5
|
id: pkg.name,
|
|
6
6
|
name: t.EXT_WEBLLM_NAME,
|
|
7
7
|
description: t.EXT_WEBLLM_DESC,
|
|
8
|
-
loader: () => import("./webllmservice-
|
|
8
|
+
loader: () => import("./webllmservice-Birv3OKf.js"),
|
|
9
9
|
icon: "robot",
|
|
10
10
|
experimental: true
|
|
11
11
|
});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { MLCEngine } from "@mlc-ai/web-llm";
|
|
2
|
+
import { createLogger } from "@eclipse-lyra/core";
|
|
2
3
|
import { aiService } from "@eclipse-lyra/extension-ai-system/api";
|
|
4
|
+
const logger = createLogger("WebLLM");
|
|
3
5
|
class WebLLMProvider {
|
|
4
6
|
constructor() {
|
|
5
7
|
this.name = "webllm";
|
|
@@ -10,7 +12,7 @@ class WebLLMProvider {
|
|
|
10
12
|
async init(model, parameters) {
|
|
11
13
|
if (this.engine) return;
|
|
12
14
|
const initProgressCallback = (progress) => {
|
|
13
|
-
|
|
15
|
+
logger.debug("Model loading progress:", progress);
|
|
14
16
|
};
|
|
15
17
|
this.engine = new MLCEngine({ initProgressCallback });
|
|
16
18
|
await this.engine.reload(model, parameters);
|
|
@@ -58,4 +60,4 @@ const webllmservice = () => {
|
|
|
58
60
|
export {
|
|
59
61
|
webllmservice as default
|
|
60
62
|
};
|
|
61
|
-
//# sourceMappingURL=webllmservice-
|
|
63
|
+
//# sourceMappingURL=webllmservice-Birv3OKf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webllmservice-Birv3OKf.js","sources":["../src/webllmservice.ts"],"sourcesContent":["import {ChatCompletionMessageParam, MLCEngine} from \"@mlc-ai/web-llm\";\nimport { createLogger } from \"@eclipse-lyra/core\";\nimport type {ChatMessage, ChatProvider, StreamChunk} from \"@eclipse-lyra/extension-ai-system/api\";\n\nconst logger = createLogger('WebLLM');\nimport type {IProvider, StreamingParams, CompletionParams} from \"@eclipse-lyra/extension-ai-system/api\";\nimport {aiService} from \"@eclipse-lyra/extension-ai-system/api\";\n\nclass WebLLMProvider implements IProvider {\n name = \"webllm\";\n private engine?: MLCEngine;\n\n canHandle(chatProvider: ChatProvider): boolean {\n return chatProvider.name === \"webllm\";\n }\n\n private async init(model: string, parameters?: any): Promise<void> {\n if (this.engine) return;\n \n const initProgressCallback = (progress: any) => {\n logger.debug(\"Model loading progress:\", progress);\n };\n\n this.engine = new MLCEngine({initProgressCallback});\n await this.engine.reload(model, parameters);\n }\n\n async *stream(params: StreamingParams): AsyncIterable<StreamChunk> {\n if (!this.engine) {\n await this.init(params.model, params.chatConfig.parameters);\n }\n \n const internalMessages = params.messages.map((message) => {\n return {...message} as ChatCompletionMessageParam;\n });\n \n const result = await this.engine!.chat.completions.create({\n messages: internalMessages\n });\n \n const message = result.choices[0].message as ChatMessage;\n \n if (message.content) {\n for (const char of message.content) {\n yield {\n type: 'token',\n content: char\n };\n }\n }\n \n yield {\n type: 'done',\n content: ''\n };\n }\n\n async complete(params: CompletionParams): Promise<ChatMessage> {\n if (!this.engine) {\n await this.init(params.model, params.chatConfig.parameters);\n }\n \n const internalMessages = params.messages.map((message) => {\n return {...message} as ChatCompletionMessageParam;\n });\n \n const result = await this.engine!.chat.completions.create({\n messages: internalMessages\n });\n \n return result.choices[0].message as ChatMessage;\n }\n}\n\nexport default () => {\n aiService.registerStreamingFetcher(new WebLLMProvider());\n}"],"names":["message"],"mappings":";;;AAIA,MAAM,SAAS,aAAa,QAAQ;AAIpC,MAAM,eAAoC;AAAA,EAA1C,cAAA;AACI,SAAA,OAAO;AAAA,EAAA;AAAA,EAGP,UAAU,cAAqC;AAC3C,WAAO,aAAa,SAAS;AAAA,EACjC;AAAA,EAEA,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gBAAgB;AAC3D;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webllmservice.d.ts","sourceRoot":"","sources":["../src/webllmservice.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"webllmservice.d.ts","sourceRoot":"","sources":["../src/webllmservice.ts"],"names":[],"mappings":";AA0EA,wBAEC"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"webllmservice-BEqHp69F.js","sources":["../src/webllmservice.ts"],"sourcesContent":["import {ChatCompletionMessageParam, MLCEngine} from \"@mlc-ai/web-llm\";\nimport type {ChatMessage, ChatProvider, StreamChunk} from \"@eclipse-lyra/extension-ai-system/api\";\nimport type {IProvider, StreamingParams, CompletionParams} from \"@eclipse-lyra/extension-ai-system/api\";\nimport {aiService} from \"@eclipse-lyra/extension-ai-system/api\";\n\nclass WebLLMProvider implements IProvider {\n name = \"webllm\";\n private engine?: MLCEngine;\n\n canHandle(chatProvider: ChatProvider): boolean {\n return chatProvider.name === \"webllm\";\n }\n\n private async init(model: string, parameters?: any): Promise<void> {\n if (this.engine) return;\n \n const initProgressCallback = (progress: any) => {\n console.log(\"Model loading progress:\", progress);\n };\n\n this.engine = new MLCEngine({initProgressCallback});\n await this.engine.reload(model, parameters);\n }\n\n async *stream(params: StreamingParams): AsyncIterable<StreamChunk> {\n if (!this.engine) {\n await this.init(params.model, params.chatConfig.parameters);\n }\n \n const internalMessages = params.messages.map((message) => {\n return {...message} as ChatCompletionMessageParam;\n });\n \n const result = await this.engine!.chat.completions.create({\n messages: internalMessages\n });\n \n const message = result.choices[0].message as ChatMessage;\n \n if (message.content) {\n for (const char of message.content) {\n yield {\n type: 'token',\n content: char\n };\n }\n }\n \n yield {\n type: 'done',\n content: ''\n };\n }\n\n async complete(params: CompletionParams): Promise<ChatMessage> {\n if (!this.engine) {\n await this.init(params.model, params.chatConfig.parameters);\n }\n \n const internalMessages = params.messages.map((message) => {\n return {...message} as ChatCompletionMessageParam;\n });\n \n const result = await this.engine!.chat.completions.create({\n messages: internalMessages\n });\n \n return result.choices[0].message as ChatMessage;\n }\n}\n\nexport default () => {\n aiService.registerStreamingFetcher(new WebLLMProvider());\n}"],"names":["message"],"mappings":";;AAKA,MAAM,eAAoC;AAAA,EAA1C,cAAA;AACI,SAAA,OAAO;AAAA,EAAA;AAAA,EAGP,UAAU,cAAqC;AAC3C,WAAO,aAAa,SAAS;AAAA,EACjC;AAAA,EAEA,MAAc,KAAK,OAAe,YAAiC;AAC/D,QAAI,KAAK,OAAQ;AAEjB,UAAM,uBAAuB,CAAC,aAAkB;AAC5C,cAAQ,IAAI,2BAA2B,QAAQ;AAAA,IACnD;AAEA,SAAK,SAAS,IAAI,UAAU,EAAC,sBAAqB;AAClD,UAAM,KAAK,OAAO,OAAO,OAAO,UAAU;AAAA,EAC9C;AAAA,EAEA,OAAO,OAAO,QAAqD;AAC/D,QAAI,CAAC,KAAK,QAAQ;AACd,YAAM,KAAK,KAAK,OAAO,OAAO,OAAO,WAAW,UAAU;AAAA,IAC9D;AAEA,UAAM,mBAAmB,OAAO,SAAS,IAAI,CAACA,aAAY;AACtD,aAAO,EAAC,GAAGA,SAAAA;AAAAA,IACf,CAAC;AAED,UAAM,SAAS,MAAM,KAAK,OAAQ,KAAK,YAAY,OAAO;AAAA,MACtD,UAAU;AAAA,IAAA,CACb;AAED,UAAM,UAAU,OAAO,QAAQ,CAAC,EAAE;AAElC,QAAI,QAAQ,SAAS;AACjB,iBAAW,QAAQ,QAAQ,SAAS;AAChC,cAAM;AAAA,UACF,MAAM;AAAA,UACN,SAAS;AAAA,QAAA;AAAA,MAEjB;AAAA,IACJ;AAEA,UAAM;AAAA,MACF,MAAM;AAAA,MACN,SAAS;AAAA,IAAA;AAAA,EAEjB;AAAA,EAEA,MAAM,SAAS,QAAgD;AAC3D,QAAI,CAAC,KAAK,QAAQ;AACd,YAAM,KAAK,KAAK,OAAO,OAAO,OAAO,WAAW,UAAU;AAAA,IAC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