request_handler = new ChatGPT_Request_Handler( $api_key ); $this->response_processor = new ChatGPT_Response_Processor(); } /** * Make API request to ChatGPT. * * @param string $text Text to process. * @param string $prompt System prompt. * @param array $options Request options (model, temperature, etc.). * @return array API response with success status and data. */ public function make_request( string $text, string $prompt, array $options = array() ): array { // Execute request through handler. $raw_response = $this->request_handler->execute_request( $text, $prompt, $options ); // Process response. $processed_response = $this->response_processor->process_response( $raw_response ); // Validate content quality if successful. if ( $processed_response['success'] && isset( $processed_response['content'] ) ) { $quality_check = $this->response_processor->validate_content_quality( $processed_response['content'], $text ); $processed_response['quality'] = $quality_check; if ( ! $quality_check['valid'] ) { if ( function_exists( 'accessibility_audio_tts_debug_log' ) ) { accessibility_audio_tts_debug_log( '[ChatGPT_API_Client] Content quality validation failed: ' . implode( ', ', $quality_check['warnings'] ) ); } } } return $processed_response; } /** * Test API connection. * * @return array Connection test results. */ public function test_connection(): array { return $this->request_handler->test_connection(); } /** * Get request handler instance. * * @return ChatGPT_Request_Handler Request handler. */ public function get_request_handler(): ChatGPT_Request_Handler { return $this->request_handler; } /** * Get response processor instance. * * @return ChatGPT_Response_Processor Response processor. */ public function get_response_processor(): ChatGPT_Response_Processor { return $this->response_processor; } }