@browser-ai/web-llm 2.0.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +12 -6
- package/dist/index.d.ts +12 -6
- package/dist/index.js +364 -254
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +364 -254
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamResult } from '@ai-sdk/provider';
|
|
2
|
-
import { AppConfig, InitProgressReport, MLCEngineConfig
|
|
2
|
+
import { AppConfig, InitProgressReport, MLCEngineConfig } from '@mlc-ai/web-llm';
|
|
3
3
|
export { InitProgressReport as WebLLMProgress, WebWorkerMLCEngineHandler } from '@mlc-ai/web-llm';
|
|
4
4
|
import { UIMessage } from 'ai';
|
|
5
5
|
|
|
@@ -64,6 +64,12 @@ type Availability =
|
|
|
64
64
|
| "downloading"
|
|
65
65
|
| "available";
|
|
66
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Callback type for receiving model download/initialization progress updates.
|
|
69
|
+
* @param progress - A value between 0 and 1 indicating completion.
|
|
70
|
+
*/
|
|
71
|
+
type DownloadProgressCallback = (progress: number) => void;
|
|
72
|
+
|
|
67
73
|
declare global {
|
|
68
74
|
interface Navigator {
|
|
69
75
|
gpu?: GPU;
|
|
@@ -134,18 +140,18 @@ declare class WebLLMLanguageModel implements LanguageModelV3 {
|
|
|
134
140
|
*
|
|
135
141
|
* @example
|
|
136
142
|
* ```typescript
|
|
137
|
-
* const
|
|
143
|
+
* const model = await model.createSessionWithProgress(
|
|
138
144
|
* (progress) => {
|
|
139
|
-
* console.log(`Download progress: ${Math.round(progress
|
|
145
|
+
* console.log(`Download progress: ${Math.round(progress * 100)}%`);
|
|
140
146
|
* }
|
|
141
147
|
* );
|
|
142
148
|
* ```
|
|
143
149
|
*
|
|
144
|
-
* @param
|
|
145
|
-
* @returns Promise resolving to
|
|
150
|
+
* @param onDownloadProgress Optional callback receiving progress values from 0 to 1
|
|
151
|
+
* @returns Promise resolving to the model instance
|
|
146
152
|
* @throws {LoadSettingError} When WebLLM is not available or model is unavailable
|
|
147
153
|
*/
|
|
148
|
-
createSessionWithProgress(
|
|
154
|
+
createSessionWithProgress(onDownloadProgress?: DownloadProgressCallback): Promise<WebLLMLanguageModel>;
|
|
149
155
|
/**
|
|
150
156
|
* Generates a streaming text response using WebLLM
|
|
151
157
|
* @param options
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamResult } from '@ai-sdk/provider';
|
|
2
|
-
import { AppConfig, InitProgressReport, MLCEngineConfig
|
|
2
|
+
import { AppConfig, InitProgressReport, MLCEngineConfig } from '@mlc-ai/web-llm';
|
|
3
3
|
export { InitProgressReport as WebLLMProgress, WebWorkerMLCEngineHandler } from '@mlc-ai/web-llm';
|
|
4
4
|
import { UIMessage } from 'ai';
|
|
5
5
|
|
|
@@ -64,6 +64,12 @@ type Availability =
|
|
|
64
64
|
| "downloading"
|
|
65
65
|
| "available";
|
|
66
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Callback type for receiving model download/initialization progress updates.
|
|
69
|
+
* @param progress - A value between 0 and 1 indicating completion.
|
|
70
|
+
*/
|
|
71
|
+
type DownloadProgressCallback = (progress: number) => void;
|
|
72
|
+
|
|
67
73
|
declare global {
|
|
68
74
|
interface Navigator {
|
|
69
75
|
gpu?: GPU;
|
|
@@ -134,18 +140,18 @@ declare class WebLLMLanguageModel implements LanguageModelV3 {
|
|
|
134
140
|
*
|
|
135
141
|
* @example
|
|
136
142
|
* ```typescript
|
|
137
|
-
* const
|
|
143
|
+
* const model = await model.createSessionWithProgress(
|
|
138
144
|
* (progress) => {
|
|
139
|
-
* console.log(`Download progress: ${Math.round(progress
|
|
145
|
+
* console.log(`Download progress: ${Math.round(progress * 100)}%`);
|
|
140
146
|
* }
|
|
141
147
|
* );
|
|
142
148
|
* ```
|
|
143
149
|
*
|
|
144
|
-
* @param
|
|
145
|
-
* @returns Promise resolving to
|
|
150
|
+
* @param onDownloadProgress Optional callback receiving progress values from 0 to 1
|
|
151
|
+
* @returns Promise resolving to the model instance
|
|
146
152
|
* @throws {LoadSettingError} When WebLLM is not available or model is unavailable
|
|
147
153
|
*/
|
|
148
|
-
createSessionWithProgress(
|
|
154
|
+
createSessionWithProgress(onDownloadProgress?: DownloadProgressCallback): Promise<WebLLMLanguageModel>;
|
|
149
155
|
/**
|
|
150
156
|
* Generates a streaming text response using WebLLM
|
|
151
157
|
* @param options
|