Spaces:
Running
Running
File size: 1,299 Bytes
907b200 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | <?php
namespace App\Services;
use Illuminate\Support\Facades\Http;
use Illuminate\Http\Client\Response;
class AiServiceClient
{
private string $baseUrl;
public function __construct()
{
$this->baseUrl = rtrim(config('services.generation.url', 'http://generation:8000'), '/');
}
public function startGeneration(array $params): Response
{
return Http::timeout(30)
->retry(5, 1000)
->post($this->baseUrl . '/generate', $params);
}
public function getJobStatus(string $jobId): Response
{
return Http::timeout(30)
->retry(5, 1000)
->get($this->baseUrl . "/jobs/{$jobId}");
}
public function fetchResults(string $jobId): Response
{
return Http::timeout(60)
->retry(5, 1000)
->get($this->baseUrl . "/jobs/{$jobId}/result");
}
public function downloadFile(string $jobId, string $filename): Response
{
return Http::timeout(120)
->retry(5, 1000)
->get($this->baseUrl . "/files/jobs/{$jobId}/{$filename}");
}
public function cancelJob(string $jobId): Response
{
return Http::timeout(30)
->retry(5, 1000)
->post($this->baseUrl . "/jobs/{$jobId}/cancel");
}
}
|