diff --git a/src/CoreBundle/AiProvider/AiProviderFactory.php b/src/CoreBundle/AiProvider/AiProviderFactory.php index e02f6ee96af..ca21d362921 100644 --- a/src/CoreBundle/AiProvider/AiProviderFactory.php +++ b/src/CoreBundle/AiProvider/AiProviderFactory.php @@ -124,10 +124,6 @@ public function __construct( if (!$obj) { if ($baseObject && ($baseObject instanceof $iface)) { $obj = $baseObject; - - if ($typeClass !== $baseClass && !class_exists($typeClass)) { - error_log('[AI] Provider "'.$providerName.'" uses base provider for type "'.$type.'" (no dedicated type class found).'); - } } else { error_log('[AI] Provider "'.$providerName.'" is configured for type "'.$type.'" but no usable implementation was found (expected '.$iface.').'); diff --git a/src/CoreBundle/AiProvider/OpenAiProvider.php b/src/CoreBundle/AiProvider/OpenAiProvider.php index 0fb8fbec6a4..05c4e956529 100644 --- a/src/CoreBundle/AiProvider/OpenAiProvider.php +++ b/src/CoreBundle/AiProvider/OpenAiProvider.php @@ -106,16 +106,6 @@ public function chat(array $messages, array $options = []): string $logPreview = $this->messagesForLog($normalizedMessages, 900); - error_log(\sprintf( - '[AI][OpenAI][chat] Request: userId=%d url=%s model=%s temperature=%.2f max_tokens=%d messages="%s"', - $userId, - $url, - $model, - $temperature, - $maxTokens, - $logPreview - )); - try { $response = $this->httpClient->request('POST', $url, [ 'headers' => $this->buildAuthHeaders(true), @@ -198,16 +188,6 @@ public function generateText(string $prompt, array $options = []): string 'max_tokens' => $maxTokens, ]; - error_log(\sprintf( - '[AI][OpenAI][generateText] Request: userId=%d url=%s model=%s temperature=%.2f max_tokens=%d prompt="%s"', - $userId, - $url, - $model, - $temperature, - $maxTokens, - mb_substr($prompt, 0, 200) - )); - try { $response = $this->httpClient->request('POST', $url, [ 'headers' => $this->buildAuthHeaders(true), @@ -679,18 +659,6 @@ public function generateImage(string $prompt, string $toolName, ?array $options $payload['response_format'] = $responseFormat; } - error_log(\sprintf( - '[AI][OpenAI][image] Request: userId=%d tool=%s url=%s model=%s size=%s quality=%s n=%d prompt="%s"', - $userId, - $toolName, - $url, - $model, - $size, - $quality, - $n, - $promptForLog - )); - try { $response = $this->httpClient->request('POST', $url, [ 'headers' => $this->buildAuthHeaders(true), @@ -712,39 +680,17 @@ public function generateImage(string $prompt, string $toolName, ?array $options $param = $decoded['error']['param'] ?? null; $finalMsg = $msg ?: 'OpenAI returned an error response.'; - error_log(\sprintf( - '[AI][OpenAI][image] HTTP %d request_id=%s type=%s code=%s param=%s body=%s', - $status, - (string) $requestId, - (string) $type, - (string) $code, - (string) $param, - $rawForLog - )); return 'Error: '.$finalMsg; } $data = json_decode((string) $raw, true); if (!\is_array($data)) { - error_log(\sprintf( - '[AI][OpenAI][image] Invalid JSON response. HTTP %d request_id=%s body=%s', - $status, - (string) $requestId, - $rawForLog - )); return 'Error: Invalid JSON response from OpenAI.'; } if (!isset($data['data'][0]) || !\is_array($data['data'][0])) { - error_log(\sprintf( - '[AI][OpenAI][image] Missing image data[0]. HTTP %d request_id=%s keys=%s body=%s', - $status, - (string) $requestId, - implode(',', array_keys($data)), - $rawForLog - )); return 'Error: OpenAI response missing image data.'; } @@ -766,12 +712,6 @@ public function generateImage(string $prompt, string $toolName, ?array $options $result['url'] = $item['url']; $result['is_base64'] = false; } else { - error_log(\sprintf( - '[AI][OpenAI][image] Response did not include b64_json or url. HTTP %d request_id=%s body=%s', - $status, - (string) $requestId, - $rawForLog - )); return 'Error: OpenAI response did not include image content.'; } @@ -786,15 +726,6 @@ public function generateImage(string $prompt, string $toolName, ?array $options (int) ($data['usage']['total_tokens'] ?? 0) ); - error_log(\sprintf( - '[AI][OpenAI][image] Success. HTTP %d request_id=%s revised_prompt=%s returned_base64=%s returned_url=%s', - $status, - (string) $requestId, - isset($result['revised_prompt']) ? (string) $result['revised_prompt'] : '', - $result['is_base64'] ? 'yes' : 'no', - !empty($result['url']) ? 'yes' : 'no' - )); - return $result; } catch (Exception $e) { error_log('[AI][OpenAI][image] Exception: '.$e->getMessage()); @@ -835,17 +766,6 @@ public function generateVideo(string $prompt, string $toolName, ?array $options $promptTrimmed = trim($prompt); $promptForLog = mb_substr($promptTrimmed, 0, 200); - error_log(\sprintf( - '[AI][OpenAI][video] Request: userId=%d tool=%s url=%s model=%s seconds=%s size=%s prompt="%s"', - $userId, - $toolName, - $url, - $model, - $seconds, - $size, - $promptForLog - )); - try { $fields = [ 'model' => $model, @@ -901,40 +821,16 @@ public function generateVideo(string $prompt, string $toolName, ?array $options ); } - error_log(\sprintf( - '[AI][OpenAI][video] HTTP %d request_id=%s type=%s code=%s param=%s error="%s" body=%s', - $status, - (string) $requestId, - (string) ($err['type'] ?? ''), - (string) ($err['code'] ?? ''), - (string) ($err['param'] ?? ''), - $finalMsg, - '' !== $rawForLog ? $rawForLog : '(empty body)' - )); - return 'Error: '.$finalMsg; } $data = json_decode($raw, true); if (!\is_array($data)) { - error_log(\sprintf( - '[AI][OpenAI][video] Invalid JSON response. HTTP %d request_id=%s body=%s', - $status, - (string) $requestId, - '' !== $rawForLog ? $rawForLog : '(empty body)' - )); return 'Error: Invalid JSON response from OpenAI.'; } if (!isset($data['id']) || !\is_string($data['id']) || '' === trim($data['id'])) { - error_log(\sprintf( - '[AI][OpenAI][video] Missing "id" in response. HTTP %d request_id=%s keys=%s body=%s', - $status, - (string) $requestId, - implode(',', array_keys($data)), - $rawForLog - )); return 'Error: OpenAI response missing "id".'; } @@ -952,14 +848,6 @@ public function generateVideo(string $prompt, string $toolName, ?array $options $this->saveAiRequest($userId, $toolName, $promptTrimmed, 'openai', 0, 0, 0); - error_log(\sprintf( - '[AI][OpenAI][video] Job created. HTTP %d request_id=%s id=%s status=%s', - $status, - (string) $requestId, - (string) $result['id'], - (string) $result['status'] - )); - return $result; } catch (Exception $e) { error_log('[AI][OpenAI][video] Exception: '.$e->getMessage()); @@ -987,14 +875,6 @@ public function getVideoJobStatus(string $jobId): ?array if ($status >= 400) { $msg = $this->extractOpenAiErrorMessage($raw); - error_log(\sprintf( - '[AI][OpenAI][video] Status HTTP %d request_id=%s id=%s error="%s" body=%s', - $status, - $requestId, - $jobId, - $msg, - $this->safeTruncate($raw, 2000) - )); return [ 'id' => $jobId, @@ -1062,14 +942,6 @@ public function getVideoJobContentAsBase64(string $jobId, int $maxBytes = 157286 if ($status >= 400) { $msg = $this->extractOpenAiErrorMessage($raw); - error_log(\sprintf( - '[AI][OpenAI][video] Content HTTP %d request_id=%s id=%s error="%s" body=%s', - $status, - $requestId, - $jobId, - $msg, - $this->safeTruncate($raw, 2000) - )); return [ 'is_base64' => false,