feat: 增强 Manticore 向量更新逻辑,记录更新失败的 ID

This commit is contained in:
kuaifan
2026-01-03 21:59:44 +00:00
parent e020a80020
commit 9a8304d595
6 changed files with 70 additions and 6 deletions
+10
View File
@@ -260,6 +260,8 @@ class ManticoreFile
$maxSize = self::getMaxFileSizeByExt($file->ext);
if ($file->size > $maxSize) {
Log::info("Manticore: Skip large file {$file->id} ({$file->size} bytes, max: {$maxSize})");
// 删除可能存在的旧索引(文件更新后可能超限)
self::delete($file->id);
return true;
}
@@ -545,6 +547,7 @@ class ManticoreFile
}
$embeddings = $result['data'];
$failedIds = [];
// 5. 逐个更新向量到 Manticore
foreach ($ids as $index => $fileId) {
@@ -555,8 +558,15 @@ class ManticoreFile
$vectorStr = '[' . implode(',', $embeddings[$index]) . ']';
if (ManticoreBase::updateFileVector($fileId, $vectorStr)) {
$successCount++;
} else {
$failedIds[] = $fileId;
}
}
// 记录更新失败的 ID
if (!empty($failedIds)) {
Log::warning('ManticoreFile: Vector update failed', ['file_ids' => $failedIds]);
}
}
return $successCount;