diff --git a/backend/app/Ai/Agents/ContentWriterAgent.php b/backend/app/Ai/Agents/ContentWriterAgent.php index 4df4c6e..9d2fa76 100644 --- a/backend/app/Ai/Agents/ContentWriterAgent.php +++ b/backend/app/Ai/Agents/ContentWriterAgent.php @@ -74,4 +74,3 @@ public function tools(): iterable return []; } } - diff --git a/backend/app/Ai/Agents/CreativeDirectorAgent.php b/backend/app/Ai/Agents/CreativeDirectorAgent.php index 8c3ede3..b01241e 100644 --- a/backend/app/Ai/Agents/CreativeDirectorAgent.php +++ b/backend/app/Ai/Agents/CreativeDirectorAgent.php @@ -22,9 +22,9 @@ class CreativeDirectorAgent implements Agent, Conversational, HasTools */ public function instructions(): Stringable|string { - return "You are a creative director. Read the following social media post and " . - "write a single, vivid, descriptive image prompt (max 30 words) for an " . - "AI image generator. The scene must be visually compelling and directly " . + return 'You are a creative director. Read the following social media post and '. + 'write a single, vivid, descriptive image prompt (max 30 words) for an '. + 'AI image generator. The scene must be visually compelling and directly '. "relevant to the post's topic. Return ONLY the image prompt — nothing else."; } diff --git a/backend/app/Data/SocialMediaPostResponseDto.php b/backend/app/Data/SocialMediaPostResponseDto.php new file mode 100644 index 0000000..952aaf2 --- /dev/null +++ b/backend/app/Data/SocialMediaPostResponseDto.php @@ -0,0 +1,11 @@ +prompt($request->input('prompt')); - $postText = $socialMediaResponse->text; - - $imagePromptResponse = $creativeDirectorAgent->prompt($postText); - $imagePrompt = $imagePromptResponse->text; - + $prompt = $request->input('prompt'); + $response = $socialMediaService->generatePostWithImage($prompt); return response()->json([ - 'post' => $postText, - 'image_prompt' => $imagePrompt, + 'post' => $response->post, + 'image_prompt' => $response->image, ]); } } diff --git a/backend/app/Services/SocialMediaService.php b/backend/app/Services/SocialMediaService.php new file mode 100644 index 0000000..3d01943 --- /dev/null +++ b/backend/app/Services/SocialMediaService.php @@ -0,0 +1,26 @@ +contentWriterAgent->prompt($prompt); + $postText = $socialMediaResponse->text; + + $imagePromptResponse = $this->creativeDirectorAgent->prompt($postText); + $imagePrompt = $imagePromptResponse->text; + + return new SocialMediaPostResponseDto($postText, $imagePrompt); + } +}