@rws-framework/ai-tools 3.9.0 → 3.9.1

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@rws-framework/ai-tools",
3
3
  "private": false,
4
- "version": "3.9.0",
4
+ "version": "3.9.1",
5
5
  "description": "",
6
6
  "main": "src/index.ts",
7
7
  "scripts": {},
@@ -83,7 +83,7 @@ export class LangChainEmbeddingService {
83
83
  // This method is kept for compatibility but doesn't initialize anything
84
84
  }
85
85
 
86
- async embedDocs(docs: Document[], batchCallback?: (fragments:string[], batch: number[][]) => Promise<void>): Promise<number[][]> {
86
+ async embedDocs(docs: Document[], batchCallback?: (fragments:string[], batch: number[][], percentage: number) => Promise<void>): Promise<number[][]> {
87
87
  this.ensureInitialized();
88
88
 
89
89
  if (this.config.rateLimiting) {
@@ -94,7 +94,8 @@ export class LangChainEmbeddingService {
94
94
 
95
95
  if(batchCallback){
96
96
  const fragments = batch.map(d => d.pageContent);
97
- await batchCallback(fragments, embeddings);
97
+ const percentage = (batch.length / docs.length) * 100;
98
+ await batchCallback(fragments, embeddings, percentage);
98
99
  }
99
100
 
100
101
  return embeddings;
@@ -106,7 +107,7 @@ export class LangChainEmbeddingService {
106
107
  return await this.embeddings.embedDocuments(docs.map(d => d.pageContent));
107
108
  }
108
109
 
109
- async embedTexts(texts: string[], batchCallback?: (fragments:string[], batch: number[][]) => Promise<void>): Promise<number[][]> {
110
+ async embedTexts(texts: string[], batchCallback?: (fragments:string[], batch: number[][], percentage: number) => Promise<void>): Promise<number[][]> {
110
111
  this.ensureInitialized();
111
112
 
112
113
  if (this.config.rateLimiting) {
@@ -115,7 +116,8 @@ export class LangChainEmbeddingService {
115
116
  async (batch: string[]) => {
116
117
  const embeddings = await this.embeddings.embedDocuments(batch);
117
118
  if (batchCallback) {
118
- await batchCallback(batch, embeddings);
119
+ const percentage = (batch.length / texts.length) * 100;
120
+ await batchCallback(batch, embeddings, percentage);
119
121
  }
120
122
  return embeddings;
121
123
  },
@@ -98,7 +98,7 @@ export class LangChainRAGService {
98
98
  fileId: string | number,
99
99
  content: string | Record<string, any>[],
100
100
  metadata: Record<string, any> = {},
101
- batchCallback?: (fragments:string[], batch: number[][]) => Promise<void>,
101
+ batchCallback?: (fragments:string[], batch: number[][], percentage: number) => Promise<void>,
102
102
  ragOverride?: IChunkConfig
103
103
  ): Promise<IRAGResponse<{ chunkCount: number }>> {
104
104
  this.log('log', `[INDEXING] Starting indexKnowledge for fileId: ${fileId}`);