@@ -106,16 +106,6 @@ public function chat(array $messages, array $options = []): string
106106
107107 $ logPreview = $ this ->messagesForLog ($ normalizedMessages , 900 );
108108
109- error_log (\sprintf (
110- '[AI][OpenAI][chat] Request: userId=%d url=%s model=%s temperature=%.2f max_tokens=%d messages="%s" ' ,
111- $ userId ,
112- $ url ,
113- $ model ,
114- $ temperature ,
115- $ maxTokens ,
116- $ logPreview
117- ));
118-
119109 try {
120110 $ response = $ this ->httpClient ->request ('POST ' , $ url , [
121111 'headers ' => $ this ->buildAuthHeaders (true ),
@@ -198,16 +188,6 @@ public function generateText(string $prompt, array $options = []): string
198188 'max_tokens ' => $ maxTokens ,
199189 ];
200190
201- error_log (\sprintf (
202- '[AI][OpenAI][generateText] Request: userId=%d url=%s model=%s temperature=%.2f max_tokens=%d prompt="%s" ' ,
203- $ userId ,
204- $ url ,
205- $ model ,
206- $ temperature ,
207- $ maxTokens ,
208- mb_substr ($ prompt , 0 , 200 )
209- ));
210-
211191 try {
212192 $ response = $ this ->httpClient ->request ('POST ' , $ url , [
213193 'headers ' => $ this ->buildAuthHeaders (true ),
@@ -679,18 +659,6 @@ public function generateImage(string $prompt, string $toolName, ?array $options
679659 $ payload ['response_format ' ] = $ responseFormat ;
680660 }
681661
682- error_log (\sprintf (
683- '[AI][OpenAI][image] Request: userId=%d tool=%s url=%s model=%s size=%s quality=%s n=%d prompt="%s" ' ,
684- $ userId ,
685- $ toolName ,
686- $ url ,
687- $ model ,
688- $ size ,
689- $ quality ,
690- $ n ,
691- $ promptForLog
692- ));
693-
694662 try {
695663 $ response = $ this ->httpClient ->request ('POST ' , $ url , [
696664 'headers ' => $ this ->buildAuthHeaders (true ),
@@ -712,39 +680,17 @@ public function generateImage(string $prompt, string $toolName, ?array $options
712680 $ param = $ decoded ['error ' ]['param ' ] ?? null ;
713681
714682 $ finalMsg = $ msg ?: 'OpenAI returned an error response. ' ;
715- error_log (\sprintf (
716- '[AI][OpenAI][image] HTTP %d request_id=%s type=%s code=%s param=%s body=%s ' ,
717- $ status ,
718- (string ) $ requestId ,
719- (string ) $ type ,
720- (string ) $ code ,
721- (string ) $ param ,
722- $ rawForLog
723- ));
724683
725684 return 'Error: ' .$ finalMsg ;
726685 }
727686
728687 $ data = json_decode ((string ) $ raw , true );
729688 if (!\is_array ($ data )) {
730- error_log (\sprintf (
731- '[AI][OpenAI][image] Invalid JSON response. HTTP %d request_id=%s body=%s ' ,
732- $ status ,
733- (string ) $ requestId ,
734- $ rawForLog
735- ));
736689
737690 return 'Error: Invalid JSON response from OpenAI. ' ;
738691 }
739692
740693 if (!isset ($ data ['data ' ][0 ]) || !\is_array ($ data ['data ' ][0 ])) {
741- error_log (\sprintf (
742- '[AI][OpenAI][image] Missing image data[0]. HTTP %d request_id=%s keys=%s body=%s ' ,
743- $ status ,
744- (string ) $ requestId ,
745- implode (', ' , array_keys ($ data )),
746- $ rawForLog
747- ));
748694
749695 return 'Error: OpenAI response missing image data. ' ;
750696 }
@@ -766,12 +712,6 @@ public function generateImage(string $prompt, string $toolName, ?array $options
766712 $ result ['url ' ] = $ item ['url ' ];
767713 $ result ['is_base64 ' ] = false ;
768714 } else {
769- error_log (\sprintf (
770- '[AI][OpenAI][image] Response did not include b64_json or url. HTTP %d request_id=%s body=%s ' ,
771- $ status ,
772- (string ) $ requestId ,
773- $ rawForLog
774- ));
775715
776716 return 'Error: OpenAI response did not include image content. ' ;
777717 }
@@ -786,15 +726,6 @@ public function generateImage(string $prompt, string $toolName, ?array $options
786726 (int ) ($ data ['usage ' ]['total_tokens ' ] ?? 0 )
787727 );
788728
789- error_log (\sprintf (
790- '[AI][OpenAI][image] Success. HTTP %d request_id=%s revised_prompt=%s returned_base64=%s returned_url=%s ' ,
791- $ status ,
792- (string ) $ requestId ,
793- isset ($ result ['revised_prompt ' ]) ? (string ) $ result ['revised_prompt ' ] : '' ,
794- $ result ['is_base64 ' ] ? 'yes ' : 'no ' ,
795- !empty ($ result ['url ' ]) ? 'yes ' : 'no '
796- ));
797-
798729 return $ result ;
799730 } catch (Exception $ e ) {
800731 error_log ('[AI][OpenAI][image] Exception: ' .$ e ->getMessage ());
@@ -835,17 +766,6 @@ public function generateVideo(string $prompt, string $toolName, ?array $options
835766 $ promptTrimmed = trim ($ prompt );
836767 $ promptForLog = mb_substr ($ promptTrimmed , 0 , 200 );
837768
838- error_log (\sprintf (
839- '[AI][OpenAI][video] Request: userId=%d tool=%s url=%s model=%s seconds=%s size=%s prompt="%s" ' ,
840- $ userId ,
841- $ toolName ,
842- $ url ,
843- $ model ,
844- $ seconds ,
845- $ size ,
846- $ promptForLog
847- ));
848-
849769 try {
850770 $ fields = [
851771 'model ' => $ model ,
@@ -901,40 +821,16 @@ public function generateVideo(string $prompt, string $toolName, ?array $options
901821 );
902822 }
903823
904- error_log (\sprintf (
905- '[AI][OpenAI][video] HTTP %d request_id=%s type=%s code=%s param=%s error="%s" body=%s ' ,
906- $ status ,
907- (string ) $ requestId ,
908- (string ) ($ err ['type ' ] ?? '' ),
909- (string ) ($ err ['code ' ] ?? '' ),
910- (string ) ($ err ['param ' ] ?? '' ),
911- $ finalMsg ,
912- '' !== $ rawForLog ? $ rawForLog : '(empty body) '
913- ));
914-
915824 return 'Error: ' .$ finalMsg ;
916825 }
917826
918827 $ data = json_decode ($ raw , true );
919828 if (!\is_array ($ data )) {
920- error_log (\sprintf (
921- '[AI][OpenAI][video] Invalid JSON response. HTTP %d request_id=%s body=%s ' ,
922- $ status ,
923- (string ) $ requestId ,
924- '' !== $ rawForLog ? $ rawForLog : '(empty body) '
925- ));
926829
927830 return 'Error: Invalid JSON response from OpenAI. ' ;
928831 }
929832
930833 if (!isset ($ data ['id ' ]) || !\is_string ($ data ['id ' ]) || '' === trim ($ data ['id ' ])) {
931- error_log (\sprintf (
932- '[AI][OpenAI][video] Missing "id" in response. HTTP %d request_id=%s keys=%s body=%s ' ,
933- $ status ,
934- (string ) $ requestId ,
935- implode (', ' , array_keys ($ data )),
936- $ rawForLog
937- ));
938834
939835 return 'Error: OpenAI response missing "id". ' ;
940836 }
@@ -952,14 +848,6 @@ public function generateVideo(string $prompt, string $toolName, ?array $options
952848
953849 $ this ->saveAiRequest ($ userId , $ toolName , $ promptTrimmed , 'openai ' , 0 , 0 , 0 );
954850
955- error_log (\sprintf (
956- '[AI][OpenAI][video] Job created. HTTP %d request_id=%s id=%s status=%s ' ,
957- $ status ,
958- (string ) $ requestId ,
959- (string ) $ result ['id ' ],
960- (string ) $ result ['status ' ]
961- ));
962-
963851 return $ result ;
964852 } catch (Exception $ e ) {
965853 error_log ('[AI][OpenAI][video] Exception: ' .$ e ->getMessage ());
@@ -987,14 +875,6 @@ public function getVideoJobStatus(string $jobId): ?array
987875
988876 if ($ status >= 400 ) {
989877 $ msg = $ this ->extractOpenAiErrorMessage ($ raw );
990- error_log (\sprintf (
991- '[AI][OpenAI][video] Status HTTP %d request_id=%s id=%s error="%s" body=%s ' ,
992- $ status ,
993- $ requestId ,
994- $ jobId ,
995- $ msg ,
996- $ this ->safeTruncate ($ raw , 2000 )
997- ));
998878
999879 return [
1000880 'id ' => $ jobId ,
@@ -1062,14 +942,6 @@ public function getVideoJobContentAsBase64(string $jobId, int $maxBytes = 157286
1062942
1063943 if ($ status >= 400 ) {
1064944 $ msg = $ this ->extractOpenAiErrorMessage ($ raw );
1065- error_log (\sprintf (
1066- '[AI][OpenAI][video] Content HTTP %d request_id=%s id=%s error="%s" body=%s ' ,
1067- $ status ,
1068- $ requestId ,
1069- $ jobId ,
1070- $ msg ,
1071- $ this ->safeTruncate ($ raw , 2000 )
1072- ));
1073945
1074946 return [
1075947 'is_base64 ' => false ,
0 commit comments