@getmikk/intent-engine 2.0.16 → 2.0.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getmikk/intent-engine",
3
- "version": "2.0.16",
3
+ "version": "2.0.17",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"
@@ -41,7 +41,7 @@ export class SemanticSearcher {
41
41
  private pipeline: any = null
42
42
  private cache: EmbeddingCache | null = null
43
43
 
44
- constructor(private readonly projectRoot: string) {
44
+ constructor(private readonly projectRoot: string, private readonly onProgress?: (percent: number) => void) {
45
45
  this.cachePath = path.join(projectRoot, '.mikk', 'embeddings.json')
46
46
  }
47
47
 
@@ -97,12 +97,16 @@ export class SemanticSearcher {
97
97
  await this.ensurePipeline()
98
98
  const embeddings: Record<string, number[]> = {}
99
99
  const BATCH = 64
100
+ const total = fns.length
100
101
  for (let i = 0; i < fns.length; i += BATCH) {
101
102
  const batch = texts.slice(i, i + BATCH)
102
103
  const output = await this.pipeline(batch, { pooling: 'mean', normalize: true })
103
104
  for (let j = 0; j < batch.length; j++) {
104
105
  embeddings[fns[i + j].id] = Array.from(output[j].data as Float32Array)
105
106
  }
107
+ if (this.onProgress) {
108
+ this.onProgress(Math.round(((i + BATCH) / total) * 100))
109
+ }
106
110
  }
107
111
 
108
112
  this.cache = { lockFingerprint: fingerprint, model: SemanticSearcher.MODEL, embeddings }