@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 CHANGED
@@ -1,5 +1,5 @@
1
1
  import { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamResult } from '@ai-sdk/provider';
2
- import { AppConfig, InitProgressReport, MLCEngineConfig, MLCEngineInterface } from '@mlc-ai/web-llm';
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 engine = await model.createSessionWithProgress(
143
+ * const model = await model.createSessionWithProgress(
138
144
  * (progress) => {
139
- * console.log(`Download progress: ${Math.round(progress.loaded * 100)}%`);
145
+ * console.log(`Download progress: ${Math.round(progress * 100)}%`);
140
146
  * }
141
147
  * );
142
148
  * ```
143
149
  *
144
- * @param onInitProgress Optional callback receiving progress reports during model download
145
- * @returns Promise resolving to a configured WebLLM engine
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(onInitProgress?: (progress: InitProgressReport) => void): Promise<MLCEngineInterface>;
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, MLCEngineInterface } from '@mlc-ai/web-llm';
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 engine = await model.createSessionWithProgress(
143
+ * const model = await model.createSessionWithProgress(
138
144
  * (progress) => {
139
- * console.log(`Download progress: ${Math.round(progress.loaded * 100)}%`);
145
+ * console.log(`Download progress: ${Math.round(progress * 100)}%`);
140
146
  * }
141
147
  * );
142
148
  * ```
143
149
  *
144
- * @param onInitProgress Optional callback receiving progress reports during model download
145
- * @returns Promise resolving to a configured WebLLM engine
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(onInitProgress?: (progress: InitProgressReport) => void): Promise<MLCEngineInterface>;
154
+ createSessionWithProgress(onDownloadProgress?: DownloadProgressCallback): Promise<WebLLMLanguageModel>;
149
155
  /**
150
156
  * Generates a streaming text response using WebLLM
151
157
  * @param options