Skip to content

Commit b1976ac

Browse files
committed
Refactor parameter order in OpenAIService methods for consistency and clarity
1 parent bb93376 commit b1976ac

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

app/Http/Controllers/ChatBotController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ public function index(): Response
2828
public function store(ChatBotRequest $request)
2929
{
3030
$this->authorize('makeRequest', auth()->user());
31-
31+
3232
$text = $request->validated()['text'];
3333
$model = $request->validated()['model'];
34-
$prompt = $request->validated()['prompt'];
3534
$temperature = $request->validated()['temperature'];
35+
$prompt = $request->validated()['prompt'];
3636

37-
$response = $this->OpenAIService->conversation($text, $model, $prompt, $temperature);
37+
$response = $this->OpenAIService->conversation($text, $model, $temperature, $prompt);
3838

3939
return response()->json([
4040
'bot_message' => $response['bot_message'],

app/Http/Controllers/ImageController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ public function store(ImageRequest $request)
3535
{
3636
$this->authorize('makeRequest', auth()->user());
3737

38-
$model = $request->validated()['model'];
39-
$quality = $request->validated()['quality'];
4038
$prompt = $request->validated()['prompt'];
4139
$style = $request->validated()['style'];
4240
$size = $request->validated()['size'];
41+
$model = $request->validated()['model'];
42+
$quality = $request->validated()['quality'];
4343

4444
event(new ProcessStatusStarted(auth()->id(), 'Generating image'));
4545
// Dispatch job
46-
ProcessImage::dispatch($model, $prompt, $style, $size, $quality, auth()->id());
46+
ProcessImage::dispatch($prompt, $style, $size, $model, $quality, auth()->id());
4747

4848
return redirect()->route('images.index');
4949
}

app/Jobs/ProcessImage.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@
1515
class ProcessImage implements ShouldQueue
1616
{
1717
use Queueable;
18-
protected $model;
1918
protected $prompt;
2019
protected $style;
2120
protected $size;
21+
protected $model;
2222
protected $quality;
2323
protected $userId;
2424

2525
/**
2626
* Create a new job instance.
2727
*/
28-
public function __construct($model,$prompt, $style, $size, $quality, $userId)
28+
public function __construct($prompt, $style, $size, $model, $quality, $userId)
2929
{
30-
$this->model = $model;
3130
$this->prompt = $prompt;
3231
$this->style = $style;
3332
$this->size = $size;
33+
$this->model = $model;
3434
$this->quality = $quality;
3535
$this->userId = $userId;
3636
}
@@ -41,7 +41,7 @@ public function __construct($model,$prompt, $style, $size, $quality, $userId)
4141
public function handle(OpenAIService $openAIService)
4242
{
4343
// Generate image using OpenAIService
44-
$response = $openAIService->textToImage($this->model, $this->prompt, $this->style, $this->size, $this->quality);
44+
$response = $openAIService->textToImage($this->prompt, $this->style, $this->size,$this->model, $this->quality);
4545

4646
// Extract URL and enhanced prompt from response
4747
$imageUrl = $response['url'];

app/Services/OpenAIService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function textToSpeech($text, $voice, $model = 'tts-1', $responseFormat =
4949
return $response;
5050
}
5151

52-
public function textToImage($model = 'dall-e-2', $prompt, $style, $size, $quality = 'standard')
52+
public function textToImage($prompt, $style, $size, $model = 'dall-e-2', $quality = 'standard')
5353
{
5454
$styleDescriptions = [
5555
'realistic' => 'with photorealistic details and natural lighting',
@@ -77,7 +77,7 @@ public function textToImage($model = 'dall-e-2', $prompt, $style, $size, $qualit
7777
];
7878
}
7979

80-
public function conversation($text, $model, $prompt = 'assistant', $temperature)
80+
public function conversation($text, $model, $temperature, $prompt = 'assistant')
8181
{
8282
$messages = [
8383
['role' => 'system', 'content' => $this->getPromptDescription($prompt)],

0 commit comments

Comments
 (0)