parameter für Modelle eingeführt, Beschreibung aktualisiert

This commit is contained in:
2025-08-06 09:08:07 +02:00
parent 4a45738b9b
commit 57f3dbc402
16 changed files with 581 additions and 34 deletions

View File

@@ -71,10 +71,10 @@ class RunwareAi implements ApiPluginInterface
return ['progress' => 0];
}
public function processImageStyleChange(string $imagePath, string $prompt, string $modelId, ?string $parameters = null): array
public function processImageStyleChange(\App\Models\Image $image, \App\Models\Style $style): array
{
// Step 1: Upload the original image
$uploadResult = $this->upload($imagePath);
$uploadResult = $this->upload(public_path('storage/' . $image->path));
if (!isset($uploadResult['data'][0]['imageUUID'])) {
throw new \Exception('Image upload to AI service failed or returned no UUID.');
@@ -82,7 +82,7 @@ class RunwareAi implements ApiPluginInterface
$seedImageUUID = $uploadResult['data'][0]['imageUUID'];
// Step 2: Request style change using the uploaded image's UUID
$result = $this->styleChangeRequest($prompt, $seedImageUUID, $modelId, $parameters);
$result = $this->styleChangeRequest($style, $seedImageUUID);
if (!isset($result['base64Data'])) {
throw new \Exception('AI service did not return base64 image data.');
@@ -127,9 +127,9 @@ class RunwareAi implements ApiPluginInterface
}
}
private function styleChangeRequest(string $prompt, string $seedImageUUID, string $modelId, ?string $parameters = null): array
private function styleChangeRequest(\App\Models\Style $style, string $seedImageUUID): array
{
$this->logInfo('Attempting style change request to RunwareAI.', ['prompt' => $prompt, 'seed_image_uuid' => $seedImageUUID]);
$this->logInfo('Attempting style change request to RunwareAI.', ['style_id' => $style->id, 'seed_image_uuid' => $seedImageUUID]);
if (!$this->apiProvider->api_url || !$this->apiProvider->token) {
$this->logError('RunwareAI API URL or Token not configured for style change.', ['provider_name' => $this->apiProvider->name]);
throw new \Exception('RunwareAI API URL or Token not configured.');
@@ -139,17 +139,20 @@ class RunwareAi implements ApiPluginInterface
$token = $this->apiProvider->token;
$taskUUID = (string) Str::uuid();
$modelParams = $style->aiModel->parameters ?? [];
$styleParams = $style->parameters ?? [];
$mergedParams = array_replace_recursive($modelParams, $styleParams);
$data = [
'taskType' => 'imageInference',
'taskUUID' => $taskUUID,
'positivePrompt' => $prompt,
'positivePrompt' => $style->prompt,
'seedImage' => $seedImageUUID,
'outputType' => 'base64Data',
'model' => $modelId,
'model' => $style->aiModel->model_id,
];
$decodedParameters = json_decode($parameters, true) ?? [];
foreach ($decodedParameters as $key => $value) {
foreach ($mergedParams as $key => $value) {
$data[$key] = $value;
}