model search for runware.ai implemented, added app logo and dashboard stats

This commit is contained in:
2025-08-08 14:56:39 +02:00
parent cfceaed08f
commit 543127d339
13 changed files with 317 additions and 30 deletions

View File

@@ -106,10 +106,9 @@ class RunwareAi implements ApiPluginInterface
'Content-Type' => 'application/json',
'Accept' => 'application/json',
])->timeout(5)->post($apiUrl, [
[
'taskType' => 'authentication',
'apiKey' => $token,
]
'taskUUID' => (string) Str::uuid(),
]);
$responseData = $response->json();
@@ -135,6 +134,62 @@ class RunwareAi implements ApiPluginInterface
}
}
public function searchModels(string $searchTerm): array
{
$this->logInfo('Attempting model search on RunwareAI.', ['searchTerm' => $searchTerm]);
if (!$this->apiProvider->api_url || !$this->apiProvider->token) {
$this->logError('RunwareAI API URL or Token not configured for model search.', ['provider_name' => $this->apiProvider->name]);
return [];
}
$apiUrl = rtrim($this->apiProvider->api_url, '/');
$token = $this->apiProvider->token;
try {
$response = Http::withHeaders([
'Authorization' => 'Bearer ' . $token,
'Accept' => 'application/json',
'Content-Type' => 'application/json',
])->timeout(10)->post($apiUrl, [
[
'taskType' => 'modelSearch',
'search' => $searchTerm,
'type' => 'base',
'category' => 'checkpoint',
'limit' => 100,
'taskUUID' => (string) Str::uuid(),
]
]);
$responseData = $response->json();
if ($response->successful() && isset($responseData['data'][0]['results']) && !isset($responseData['error'])) {
$models = [];
foreach ($responseData['data'][0]['results'] as $model) {
$models[] = [
'name' => $model['name'] ?? 'Unknown',
'id' => $model['air'] ?? 'Unknown',
'type' => $model['type'] ?? null,
];
}
$this->logInfo('Model search successful on RunwareAI.', ['searchTerm' => $searchTerm, 'modelsFound' => count($models)]);
return $models;
} else {
$errorMessage = $responseData['error'] ?? 'Unknown error';
$this->logError('Model search failed on RunwareAI: Unsuccessful response.', [
'status' => $response->status(),
'response' => $responseData,
'error_message' => $errorMessage,
]);
return [];
}
} catch (\Exception $e) {
$this->logError('Model search failed on RunwareAI: Exception caught.', ['error' => $e->getMessage()]);
return [];
}
}
private function upload(string $imagePath): array
{
$this->logInfo('Attempting to upload image to RunwareAI.', ['image_path' => $imagePath]);