@@ -72,8 +72,6 @@ public function suppressAjaxWarnings() {
7272 * @return void
7373 */
7474 public function generateConfiguration () {
75- error_log ( 'Visualizer AI: generateConfiguration called ' );
76-
7775 // Verify nonce
7876 if ( ! isset ( $ _POST ['nonce ' ] ) || ! wp_verify_nonce ( $ _POST ['nonce ' ], 'visualizer-ai-generate ' ) ) {
7977 error_log ( 'Visualizer AI: Invalid nonce ' );
@@ -93,31 +91,19 @@ public function generateConfiguration() {
9391 $ chat_history = isset ( $ _POST ['chat_history ' ] ) ? json_decode ( stripslashes ( $ _POST ['chat_history ' ] ), true ) : array ();
9492 $ current_config = isset ( $ _POST ['current_config ' ] ) ? sanitize_textarea_field ( $ _POST ['current_config ' ] ) : '' ;
9593
96- error_log ( '=== Visualizer AI Request === ' );
97- error_log ( 'Visualizer AI: Model: ' . $ model );
98- error_log ( 'Visualizer AI: Prompt: ' . $ prompt );
99- error_log ( 'Visualizer AI: Chart Type: ' . $ chart_type );
100- error_log ( 'Visualizer AI: Chart Library RAW from POST: ' . ( isset ( $ _POST ['chart_library ' ] ) ? $ _POST ['chart_library ' ] : 'NOT SET ' ) );
101- error_log ( 'Visualizer AI: Chart Library (sanitized): ' . $ chart_library );
102- error_log ( 'Visualizer AI: Chart Library (lowercase check): ' . strtolower ( $ chart_library ) );
103- error_log ( 'Visualizer AI: Is ChartJS?: ' . ( strtolower ( $ chart_library ) === 'chartjs ' ? 'YES ' : 'NO ' ) );
104- error_log ( 'Visualizer AI: Chat History Items: ' . count ( $ chat_history ) );
105-
10694 if ( empty ( $ prompt ) ) {
10795 error_log ( 'Visualizer AI: Empty prompt ' );
10896 wp_send_json_error ( array ( 'message ' => esc_html__ ( 'Please provide a prompt. ' , 'visualizer ' ) ) );
10997 }
11098
11199 // Generate configuration based on selected model
112- error_log ( 'Visualizer AI: Calling AI model ' );
113100 $ result = $ this ->_callAIModel ( $ model , $ prompt , $ chart_type , $ chart_library , $ chat_history , $ current_config );
114101
115102 if ( is_wp_error ( $ result ) ) {
116103 error_log ( 'Visualizer AI: Error: ' . $ result ->get_error_message () );
117104 wp_send_json_error ( array ( 'message ' => $ result ->get_error_message () ) );
118105 }
119106
120- error_log ( 'Visualizer AI: Success ' );
121107 wp_send_json_success ( $ result );
122108 }
123109
@@ -137,8 +123,6 @@ public function analyzeChartImage() {
137123 }
138124 ob_start ();
139125
140- error_log ( 'Visualizer AI: analyzeChartImage called ' );
141-
142126 // Verify nonce
143127 if ( ! isset ( $ _POST ['nonce ' ] ) || ! wp_verify_nonce ( $ _POST ['nonce ' ], 'visualizer-ai-image ' ) ) {
144128 error_log ( 'Visualizer AI: Invalid nonce ' );
@@ -222,13 +206,10 @@ private function _callAIModel( $model, $prompt, $chart_type, $chart_library = 'G
222206 * @return string The system prompt.
223207 */
224208 private function _createSystemPrompt ( $ chart_type , $ chart_library = 'Google Charts ' ) {
225- error_log ( 'Creating system prompt for library: ' . $ chart_library . ' (lowercase: ' . strtolower ( $ chart_library ) . ') ' );
226-
227209 $ chart_options = $ this ->_getChartTypeOptions ( $ chart_type , $ chart_library );
228210 $ library_name = strtolower ( $ chart_library ) === 'chartjs ' ? 'Chart.js ' : 'Google Charts ' ;
229211
230212 if ( strtolower ( $ chart_library ) === 'chartjs ' ) {
231- error_log ( 'Using ChartJS prompt! ' );
232213 return 'You are a helpful Chart.js (ChartJS) v3+ API expert assistant. You help users customize their ' . $ chart_type . ' charts through conversation.
233214
234215IMPORTANT CHARTJS STRUCTURE:
@@ -271,7 +252,6 @@ private function _createSystemPrompt( $chart_type, $chart_library = 'Google Char
271252Remember: Be conversational, provide context, and only include the properties that need to change! ' ;
272253 }
273254
274- error_log ( 'Using Google Charts prompt! ' );
275255 return 'You are a helpful ' . $ library_name . ' API expert assistant. You help users customize their ' . $ chart_type . ' charts through conversation.
276256
277257IMPORTANT INSTRUCTIONS:
@@ -481,8 +461,6 @@ private function _getChartJSOptions( $chart_type ) {
481461 * @return array<string, mixed>|WP_Error The response with message and optional configuration.
482462 */
483463 private function _callOpenAI ( $ prompt , $ chart_type , $ chart_library = 'Google Charts ' , $ chat_history = array (), $ current_config = '' ) {
484- error_log ( 'Visualizer AI: Calling OpenAI API ' );
485-
486464 $ api_key = get_option ( 'visualizer_openai_api_key ' , '' );
487465
488466 if ( empty ( $ api_key ) ) {
0 commit comments