Verfügbarkeitstest für API Provider ergänzt.
This commit is contained in:
@@ -139,6 +139,84 @@ class RunwareAi implements ApiPluginInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function checkAvailability(): array
|
||||
{
|
||||
$this->logInfo('Checking RunwareAI availability.');
|
||||
|
||||
if (!$this->apiProvider->enabled) {
|
||||
$this->logDebug('RunwareAI provider is disabled.');
|
||||
return [
|
||||
'available' => false,
|
||||
'reason' => 'Provider is disabled',
|
||||
'provider_id' => $this->apiProvider->id,
|
||||
'provider_name' => $this->apiProvider->name
|
||||
];
|
||||
}
|
||||
|
||||
if (empty($this->apiProvider->api_url)) {
|
||||
$this->logDebug('RunwareAI API URL is not configured.');
|
||||
return [
|
||||
'available' => false,
|
||||
'reason' => 'API URL not configured',
|
||||
'provider_id' => $this->apiProvider->id,
|
||||
'provider_name' => $this->apiProvider->name
|
||||
];
|
||||
}
|
||||
|
||||
if (empty($this->apiProvider->token)) {
|
||||
$this->logDebug('RunwareAI API token is not configured.');
|
||||
return [
|
||||
'available' => false,
|
||||
'reason' => 'API token not configured',
|
||||
'provider_id' => $this->apiProvider->id,
|
||||
'provider_name' => $this->apiProvider->name
|
||||
];
|
||||
}
|
||||
|
||||
try {
|
||||
$response = Http::withHeaders([
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json',
|
||||
])->timeout(5)->post(rtrim($this->apiProvider->api_url, '/'), [
|
||||
'taskType' => 'authentication',
|
||||
'apiKey' => $this->apiProvider->token,
|
||||
'taskUUID' => (string) Str::uuid(),
|
||||
]);
|
||||
|
||||
$responseData = $response->json();
|
||||
|
||||
if ($response->successful() && isset($responseData['data']) && !isset($responseData['error'])) {
|
||||
$this->logInfo('RunwareAI is available.');
|
||||
return [
|
||||
'available' => true,
|
||||
'reason' => 'Connection successful',
|
||||
'provider_id' => $this->apiProvider->id,
|
||||
'provider_name' => $this->apiProvider->name
|
||||
];
|
||||
} else {
|
||||
$errorMessage = $responseData['error'] ?? 'Unknown error';
|
||||
$this->logError('RunwareAI connection failed.', [
|
||||
'status' => $response->status(),
|
||||
'error_message' => $errorMessage
|
||||
]);
|
||||
return [
|
||||
'available' => false,
|
||||
'reason' => 'Connection failed: ' . $errorMessage,
|
||||
'provider_id' => $this->apiProvider->id,
|
||||
'provider_name' => $this->apiProvider->name
|
||||
];
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->logError('RunwareAI availability check failed.', ['error' => $e->getMessage()]);
|
||||
return [
|
||||
'available' => false,
|
||||
'reason' => 'Connection error: ' . $e->getMessage(),
|
||||
'provider_id' => $this->apiProvider->id,
|
||||
'provider_name' => $this->apiProvider->name
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function searchModels(string $searchTerm): array
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user