PluginProbe
Auto Alt Text / 2.5.2
Auto Alt Text v2.5.2
3.0.3 2.8.2 1.3.1 1.3.2 2.0.0 2.1.0 2.1.1 2.2.0 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.7.0 2.8.0 2.8.1 All 28 releases
← All changes | src/App/AIProviders/OpenAI/OpenAIVision.php +2 -24 1.3.22.5.2 View file →
@@ -1,8 +1,9 @@
1 1 <?php
2 2
3 3 namespace AATXT\App\AIProviders\OpenAI;
4 4
5 +use AATXT\App\Admin\PluginOptions;
5 6 use OpenAI;
6 7 use OpenAI\Client;
7 8 use OpenAI\Exceptions\ErrorException;
8 9 use AATXT\App\Exceptions\OpenAI\OpenAIException;
@@ -23,32 +24,9 @@
23 24 */
24 25 public function response(string $imageUrl): string
25 26 {
26 27 $prompt = parent::prompt();
27 -
28 - $requestBody = [
29 - 'model' => Constants::AATXT_OPENAI_VISION_MODEL,
30 - 'messages' => [
31 - [
32 - 'role' => 'user',
33 - 'content' => [
34 - [
35 - "type" => "text",
36 - "text" => $prompt
37 - ],
38 - [
39 - "type" => "image_url",
40 - "image_url" => [
41 - "url" => $imageUrl
42 - ]
43 - ]
44 - ]
45 - ],
46 - ],
47 - 'max_tokens' => Constants::AATXT_OPENAI_MAX_TOKENS,
48 - ];
49 -
28 + $requestBody = parent::prepareRequestBody(PluginOptions::openAiModel(), $prompt, $imageUrl);
50 29 $decodedBody = parent::decodedResponseBody($requestBody, Constants::AATXT_OPENAI_CHAT_COMPLETION_ENDPOINT);
51 -
52 30 return $this->cleanString($decodedBody['choices'][0]['message']['content']);
53 31 }
54 32 }