diff --git a/prompts/src/services/jimeng.service.ts b/prompts/src/services/jimeng.service.ts index e4835dc..6f6c18a 100644 --- a/prompts/src/services/jimeng.service.ts +++ b/prompts/src/services/jimeng.service.ts @@ -80,7 +80,7 @@ export class JimengService { } } - async downloadImage(url: string): Promise { + async downloadImage(url: string): Promise { const controller = new AbortController(); const timeoutId = setTimeout(() => controller.abort(), this.timeout); @@ -96,7 +96,7 @@ export class JimengService { } const arrayBuffer = await response.arrayBuffer(); - return Buffer.from(arrayBuffer); + return new Uint8Array(arrayBuffer); } catch (error: any) { clearTimeout(timeoutId); if (error.name === 'AbortError') { diff --git a/prompts/src/task/image-creator.job.ts b/prompts/src/task/image-creator.job.ts index 0e87723..e7745ba 100644 --- a/prompts/src/task/image-creator.job.ts +++ b/prompts/src/task/image-creator.job.ts @@ -95,7 +95,7 @@ export async function addImageDownloadJob( attempts: DOWNLOAD_MAX_RETRIES, backoff: { type: 'exponential', - delay: 2000, // 初始 2 秒 + delay: 200, // 初始 200 毫秒 }, removeOnComplete: 100, removeOnFail: 100, @@ -147,7 +147,7 @@ export async function runImageDownloadWorker(): Promise { }, { connection, - concurrency: 3, + concurrency: 1, // 避免更新冲突 lockDuration: 60000 * 5, // 锁持续时间 5分钟 stalledInterval: 30000, // 每30秒检查一次 stalled } as any @@ -162,7 +162,7 @@ export async function runImageDownloadWorker(): Promise { notify.notify(`[ImageDownload] \nJob failed: ${job?.id}, error: ${err.message}\n Job data: ${JSON.stringify(job?.data)}`); }); - console.log('[ImageDownload] Worker started'); + console.log('[ImageDownload] Worker 开始运行'); } /** @@ -226,7 +226,7 @@ export async function runImageGenerateWorker(): Promise { } }); - console.log('[ImageGenerate] Worker started'); + console.log('[ImageGenerate] Worker 开始运行'); } export { updateItemStatus }; diff --git a/prompts/src/task/perfect-sentence.job.ts b/prompts/src/task/perfect-sentence.job.ts index 61a83ed..657226b 100644 --- a/prompts/src/task/perfect-sentence.job.ts +++ b/prompts/src/task/perfect-sentence.job.ts @@ -79,7 +79,7 @@ export const runPerfectSentencePromptWorker = () => { const perfectPrompt = perfect.clearPerfectTags(ai.responseText!) || ''; console.log(`[Sentence] 提示词优化 ${itemId}:\n`, perfectPrompt); - await updateItemStatus(itemId, '提示词优化完成',{ + await updateItemStatus(itemId, '提示词优化完成', { description: perfectPrompt }); await sleep(500); // 确保数据已保存 @@ -116,6 +116,6 @@ export const runPerfectSentencePromptWorker = () => { notify.notify(`[Sentence] 提示词优化工作者在条目 ${job.data.itemId} 达到最大重试次数后停止`); } }); - + console.log('[Sentence] Worker 开始运行'); return worker; }; \ No newline at end of file