This commit is contained in:
2026-05-11 15:23:34 +08:00
parent ed70a140a2
commit 547cbbb4a5
25 changed files with 721 additions and 332 deletions
@@ -22,24 +22,29 @@ class ChunkEmbeddingHandler
$this->retryQueue = $retryQueue ?? new LLMRetryQueue();
}
public function handle(array $task): void
public function handle(array $task): int
{
if (($task['target_type'] ?? null) !== 'archive') {
return;
return 0;
}
$archiveUid = trim((string) ($task['target_uid'] ?? ''));
if ($archiveUid === '') {
return;
return 0;
}
$batchSize = (int) config('LLMapi.embedding.batch_size', 32);
$chunks = $this->chunks->findQueuedChunks($archiveUid, $batchSize);
if ($chunks === []) {
return;
return 0;
}
$chunkUids = array_column($chunks, 'chunk_uid');
if (!$this->client->isConfigured()) {
$this->chunks->markFailed($chunkUids, 'BigModel embedding API is not configured.', false);
return count($chunkUids);
}
$this->chunks->markProcessing($chunkUids);
try {
@@ -52,6 +57,7 @@ class ChunkEmbeddingHandler
);
$this->persistEmbeddings($chunks, $payload);
return count($chunkUids);
} catch (Throwable $exception) {
$this->chunks->markFailed($chunkUids, $exception->getMessage(), $this->isRetryable($exception));
throw $exception;