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/OpenAIResponse.php +27 -12 1.3.22.5.2 View file →
@@ -28,8 +28,9 @@
28 28 ];
29 29
30 30 $args = [
31 31 'headers' => $headers,
32 + 'timeout' => 90,
32 33 'body' => json_encode($requestBody),
33 34 'method' => 'POST',
34 35 'data_format' => 'body',
35 36 ];
@@ -57,23 +58,12 @@
57 58 * @return string
58 59 */
59 60 protected function prompt(): string
60 61 {
61 - return PluginOptions::prompt() ?: Constants::AATXT_OPENAI_DEFAULT_PROMPT;
62 + return PluginOptions::openAiPrompt() ?: Constants::AATXT_OPENAI_DEFAULT_PROMPT;
62 63 }
63 64
64 65 /**
65 - * Compute the fallback prompt based on the template saved in the options and the imageUrl passed
66 - * @param string $imageUrl
67 - * @return string
68 - */
69 - protected function fallbackPrompt(string $imageUrl): string
70 - {
71 - $prompt = PluginOptions::fallbackPrompt() ?: Constants::AATXT_OPENAI_DEFAULT_FALLBACK_PROMPT;
72 - return str_replace(Constants::AATXT_IMAGE_URL_TAG, $imageUrl, $prompt);
73 - }
74 -
75 - /**
76 66 * @param string $text
77 67 * @return string
78 68 */
79 69 protected function cleanString(string $text): string
@@ -84,6 +74,31 @@
84 74 '/"/' // HTML sequence for double quotes
85 75 );
86 76
87 77 return trim(preg_replace($patterns, '', $text));
78 + }
79 +
80 + protected function prepareRequestBody(string $model, string $prompt, string $imageUrl): array
81 + {
82 + return [
83 + 'model' => Constants::AATXT_OPENAI_VISION_MODEL,
84 + 'messages' => [
85 + [
86 + 'role' => 'user',
87 + 'content' => [
88 + [
89 + "type" => "text",
90 + "text" => $prompt
91 + ],
92 + [
93 + "type" => "image_url",
94 + "image_url" => [
95 + "url" => $imageUrl
96 + ]
97 + ]
98 + ]
99 + ],
100 + ],
101 + 'max_tokens' => Constants::AATXT_OPENAI_MAX_TOKENS,
102 + ];
88 103 }
89 104 }