Skip to content

Commit 65636fb

Browse files
committed
fix encoding error for embeddings
1 parent a4cb913 commit 65636fb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/tools/embeddings.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ async function getBatchEmbeddingsWithRetry(
8989
const key = Object.keys(item)[0];
9090
return key === 'text' ? { text: trimSymbols(item[key]) } : item;
9191
}
92-
}); // Copy the original texts
92+
}).filter(item => typeof item !== 'string' || item.trim()); // Copy the original texts
9393
let indexMap = new Map<number, number>(); // Map to keep track of original indices
9494

9595
// Initialize indexMap with original indices
@@ -251,7 +251,7 @@ function truncateInputString(input: string | Record<string, string>): string {
251251
}
252252
}
253253

254-
function trimSymbols(str: string): string {
254+
export function trimSymbols(str: string): string {
255255
const regex = /[\p{S}\p{P}\p{Z}\p{C}\p{Emoji}]+/gu;
256256
return str.replace(regex, ' ');
257257
}

0 commit comments

Comments
 (0)