mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
fix: handle partial success in embedding generation by filling missing results with errors
This commit is contained in:
1 parent
8e4770e19e
commit
805bfd04e3
1 file changed
+8
@@ -105,6 +105,14 @@ class Create extends CreateDocumentAction
|
||||
foreach ($embedResult['embeddings'] as $embedding) {
|
||||
$results[] = $this->embeddingResult($model, $dimension, $embedding);
|
||||
}
|
||||
|
||||
// Partial success: backend returned fewer embeddings than inputs.
|
||||
// Fill the gap with error results so the response stays 1:1 with texts.
|
||||
$missing = \count($batch) - \count($embedResult['embeddings']);
|
||||
for ($i = 0; $i < $missing; $i++) {
|
||||
$totalErrors++;
|
||||
$results[] = $this->embeddingResult($model, $dimension, [], 'Error while generating embedding');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$totalErrors += \count($batch);
|
||||
$this->logError($e, $model, $project, $log, $logger);
|
||||
|
||||
Reference in new issue
Block a user