Spaces:
Running
Running
Download app/Services/AiServiceClient.php from Ailixir-AI-Team/ailixir-api: direct link, hf CLI and curl.
- Browser
- Download file 1.3 kB
-
https://huggingface.co/spaces/Ailixir-AI-Team/ailixir-api/resolve/main/app/Services/AiServiceClient.php
- Command line
-
hf download hf://spaces/Ailixir-AI-Team/ailixir-api/app/Services/AiServiceClient.php
-
curl -L -o AiServiceClient.php https://huggingface.co/spaces/Ailixir-AI-Team/ailixir-api/resolve/main/app/Services/AiServiceClient.php
1.3 kB
| 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"); | |
| } | |
| } | |