fix empty input handling in embeddings

This commit is contained in:
Sha Zhou 2025-08-21 16:33:47 +08:00
parent 582292ac4b
commit a4cb9139ed

View File

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