feat: parallel image generation via curl_multi
Both Image A and Image B now fire concurrently through a single generate_image_batch() call instead of sequentially. Total wall-clock time equals the slowest image (~20s), not the sum (~40s), which eliminates the Image B timeout problem on Hostinger where max_execution_time killed the cron before the second request finished. New files: - class-open-router-image-batch.php — curl_multi orchestrator - generate_image_batch() added to image provider interface Pipeline refactored: prompts built upfront, single batch call, results processed per-key. Cloudflare provider gets a sequential fallback. Tests updated for batch API. All files under 300-line cap. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -174,6 +174,28 @@ class PRAutoBlogger_Cloudflare_Image_Provider implements PRAutoBlogger_Image_Pro
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sequential fallback — Cloudflare Workers AI does not support batching.
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function generate_image_batch( array $requests ): array {
|
||||
$results = [];
|
||||
foreach ( $requests as $key => $req ) {
|
||||
try {
|
||||
$results[ $key ] = $this->generate_image(
|
||||
$req['prompt'],
|
||||
$req['width'],
|
||||
$req['height'],
|
||||
$req['options'] ?? []
|
||||
);
|
||||
} catch ( \Throwable $e ) {
|
||||
$results[ $key ] = [ 'error' => $e->getMessage() ];
|
||||
}
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimate the USD cost of a single generation call.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user