@browser-ai/core 2.0.4 → 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
@@ -2,6 +2,12 @@ import { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateRes
2
2
  import { TextEmbedder } from '@mediapipe/tasks-text';
3
3
  import { UIMessage } from 'ai';
4
4
 
5
+ /**
6
+ * Callback type for receiving model download/initialization progress updates.
7
+ * @param progress - A value between 0 and 1 indicating completion.
8
+ */
9
+ type DownloadProgressCallback = (progress: number) => void;
10
+
5
11
  type BrowserAIChatModelId = "text";
6
12
  interface BrowserAIChatSettings extends LanguageModelCreateOptions {
7
13
  /**
@@ -63,11 +69,11 @@ declare class BrowserAIChatLanguageModel implements LanguageModelV3 {
63
69
  * );
64
70
  * ```
65
71
  *
66
- * @param onDownloadProgress Optional callback receiving progress values 0-1 during model download
67
- * @returns Promise resolving to a configured LanguageModel session
72
+ * @param onDownloadProgress Optional callback receiving progress values from 0 to 1
73
+ * @returns Promise resolving to the model instance
68
74
  * @throws {LoadSettingError} When the Prompt API is not available or model is unavailable
69
75
  */
70
- createSessionWithProgress(onDownloadProgress?: (progress: number) => void): Promise<LanguageModel>;
76
+ createSessionWithProgress(onDownloadProgress?: DownloadProgressCallback): Promise<BrowserAIChatLanguageModel>;
71
77
  /**
72
78
  * Generates a streaming text response using the browser's built-in Prompt API
73
79
  * @param options
package/dist/index.d.ts CHANGED
@@ -2,6 +2,12 @@ import { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateRes
2
2
  import { TextEmbedder } from '@mediapipe/tasks-text';
3
3
  import { UIMessage } from 'ai';
4
4
 
5
+ /**
6
+ * Callback type for receiving model download/initialization progress updates.
7
+ * @param progress - A value between 0 and 1 indicating completion.
8
+ */
9
+ type DownloadProgressCallback = (progress: number) => void;
10
+
5
11
  type BrowserAIChatModelId = "text";
6
12
  interface BrowserAIChatSettings extends LanguageModelCreateOptions {
7
13
  /**
@@ -63,11 +69,11 @@ declare class BrowserAIChatLanguageModel implements LanguageModelV3 {
63
69
  * );
64
70
  * ```
65
71
  *
66
- * @param onDownloadProgress Optional callback receiving progress values 0-1 during model download
67
- * @returns Promise resolving to a configured LanguageModel session
72
+ * @param onDownloadProgress Optional callback receiving progress values from 0 to 1
73
+ * @returns Promise resolving to the model instance
68
74
  * @throws {LoadSettingError} When the Prompt API is not available or model is unavailable
69
75
  */
70
- createSessionWithProgress(onDownloadProgress?: (progress: number) => void): Promise<LanguageModel>;
76
+ createSessionWithProgress(onDownloadProgress?: DownloadProgressCallback): Promise<BrowserAIChatLanguageModel>;
71
77
  /**
72
78
  * Generates a streaming text response using the browser's built-in Prompt API
73
79
  * @param options
package/dist/index.js CHANGED
@@ -853,7 +853,7 @@ var SessionManager = class {
853
853
  *
854
854
  * This is a convenience method for users who want explicit progress tracking.
855
855
  *
856
- * @param onDownloadProgress - Optional callback receiving progress (0-1) during download
856
+ * @param onDownloadProgress - Optional callback receiving progress values from 0 to 1
857
857
  * @returns Promise resolving to a LanguageModel session
858
858
  * @throws {LoadSettingError} When Prompt API is not available or model is unavailable
859
859
  *
@@ -1224,12 +1224,13 @@ var BrowserAIChatLanguageModel = class {
1224
1224
  * );
1225
1225
  * ```
1226
1226
  *
1227
- * @param onDownloadProgress Optional callback receiving progress values 0-1 during model download
1228
- * @returns Promise resolving to a configured LanguageModel session
1227
+ * @param onDownloadProgress Optional callback receiving progress values from 0 to 1
1228
+ * @returns Promise resolving to the model instance
1229
1229
  * @throws {LoadSettingError} When the Prompt API is not available or model is unavailable
1230
1230
  */
1231
1231
  async createSessionWithProgress(onDownloadProgress) {
1232
- return this.sessionManager.createSessionWithProgress(onDownloadProgress);
1232
+ await this.sessionManager.createSessionWithProgress(onDownloadProgress);
1233
+ return this;
1233
1234
  }
1234
1235
  /**
1235
1236
  * Generates a streaming text response using the browser's built-in Prompt API