@@ -19,8 +19,8 @@ public function __construct(modX &$modx)
1919 }
2020
2121 public function generateImage (string $ prompt , ImageConfig $ config ): string {
22- $ chatgptApiKey = $ this ->modx ->getOption ('modai.api.chatgpt.key ' );
23- if (empty ($ chatgptApiKey )) {
22+ $ apiKey = $ this ->modx ->getOption ('modai.api.chatgpt.key ' );
23+ if (empty ($ apiKey )) {
2424 throw new \Exception ('Missing modai.api.chatgpt.key ' );
2525 }
2626
@@ -38,7 +38,7 @@ public function generateImage(string $prompt, ImageConfig $config): string {
3838 curl_setopt ($ ch , CURLOPT_POSTFIELDS , json_encode ($ input ));
3939 curl_setopt ($ ch , CURLOPT_HTTPHEADER , [
4040 'Content-Type: application/json ' ,
41- 'Authorization: Bearer ' . $ chatgptApiKey
41+ 'Authorization: Bearer ' . $ apiKey
4242 ]);
4343
4444 $ response = curl_exec ($ ch );
@@ -71,8 +71,8 @@ public function generateImage(string $prompt, ImageConfig $config): string {
7171 */
7272 public function getCompletions (array $ data , CompletionsConfig $ config ): string
7373 {
74- $ chatgptApiKey = $ this ->modx ->getOption ('modai.api.chatgpt.key ' );
75- if (empty ($ chatgptApiKey )) {
74+ $ apiKey = $ this ->modx ->getOption ('modai.api.chatgpt.key ' );
75+ if (empty ($ apiKey )) {
7676 throw new \Exception ('Missing modai.api.chatgpt.key ' );
7777 }
7878
@@ -105,7 +105,7 @@ public function getCompletions(array $data, CompletionsConfig $config): string
105105 curl_setopt ($ ch , CURLOPT_POSTFIELDS , json_encode ($ input ));
106106 curl_setopt ($ ch , CURLOPT_HTTPHEADER , [
107107 'Content-Type: application/json ' ,
108- 'Authorization: Bearer ' . $ chatgptApiKey
108+ 'Authorization: Bearer ' . $ apiKey
109109 ]);
110110
111111 $ response = curl_exec ($ ch );
@@ -138,8 +138,8 @@ public function getCompletions(array $data, CompletionsConfig $config): string
138138 */
139139 public function getVision (string $ prompt , string $ image , VisionConfig $ config ): string
140140 {
141- $ chatgptApiKey = $ this ->modx ->getOption ('modai.api.chatgpt.key ' );
142- if (empty ($ chatgptApiKey )) {
141+ $ apiKey = $ this ->modx ->getOption ('modai.api.chatgpt.key ' );
142+ if (empty ($ apiKey )) {
143143 throw new \Exception ('Missing modai.api.chatgpt.key ' );
144144 }
145145
@@ -168,7 +168,7 @@ public function getVision(string $prompt, string $image, VisionConfig $config):
168168 curl_setopt ($ ch , CURLOPT_POSTFIELDS , json_encode ($ input ));
169169 curl_setopt ($ ch , CURLOPT_HTTPHEADER , [
170170 'Content-Type: application/json ' ,
171- 'Authorization: Bearer ' . $ chatgptApiKey
171+ 'Authorization: Bearer ' . $ apiKey
172172 ]);
173173
174174 $ response = curl_exec ($ ch );
0 commit comments