暂存
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user