ConnectionTest im Backend funktioniert jetzt
This commit is contained in:
@@ -12,4 +12,5 @@ interface ApiPluginInterface
|
||||
public function getStatus(string $imageUUID): array;
|
||||
public function getProgress(string $imageUUID): array;
|
||||
public function processImageStyleChange(\App\Models\Image $image, \App\Models\Style $style): array;
|
||||
public function testConnection(array $data): bool;
|
||||
}
|
||||
@@ -227,4 +227,16 @@ class ComfyUi implements ApiPluginInterface
|
||||
usleep(500000); // Wait for 0.5 seconds before polling again
|
||||
}
|
||||
}
|
||||
|
||||
public function testConnection(array $data): bool
|
||||
{
|
||||
$apiUrl = rtrim($data['api_url'], '/');
|
||||
try {
|
||||
$response = Http::timeout(5)->get($apiUrl . '/queue');
|
||||
return $response->successful();
|
||||
} catch (\Exception $e) {
|
||||
$this->logError('ComfyUI connection test failed.', ['error' => $e->getMessage()]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,6 +91,33 @@ class RunwareAi implements ApiPluginInterface
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function testConnection(array $data): bool
|
||||
{
|
||||
$apiUrl = rtrim($data['api_url'], '/');
|
||||
$token = $data['token'] ?? null;
|
||||
|
||||
if (!$apiUrl || !$token) {
|
||||
$this->logError('RunwareAI connection test failed: API URL or Token missing.');
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$response = Http::withHeaders([
|
||||
'Authorization' => 'Bearer ' . $token,
|
||||
'Accept' => 'application/json',
|
||||
])->timeout(5)->post($apiUrl, [
|
||||
[
|
||||
'taskType' => 'ping',
|
||||
]
|
||||
]);
|
||||
|
||||
return $response->successful();
|
||||
} catch (\Exception $e) {
|
||||
$this->logError('RunwareAI connection test failed.', ['error' => $e->getMessage()]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private function upload(string $imagePath): array
|
||||
{
|
||||
$this->logInfo('Attempting to upload image to RunwareAI.', ['image_path' => $imagePath]);
|
||||
|
||||
Reference in New Issue
Block a user