fix empty embeddings issue

This commit is contained in:
Sha Zhou 2025-08-21 10:46:58 +08:00
parent a310352d82
commit 831c1f66e3

View File

@ -26,7 +26,7 @@ export async function getEmbeddings(
}
// Handle empty input case
if (texts.length === 0) {
if (texts.length === 0 || texts.every(text => !text || (typeof text === 'object' && !Object.values(text)?.[0]))) {
return { embeddings: [], tokens: 0 };
}