'' // Custom feedback/instructions from user )); } /** * Check if this step can be executed * * @param AIGH_Pipeline_Context $context * @return bool|WP_Error */ public function can_execute($context) { $parent_check = parent::can_execute($context); if (is_wp_error($parent_check)) { return $parent_check; } // Get feedback from config or context $feedback = $this->get_feedback($context); if (empty($feedback)) { return $this->create_error( 'no_feedback', 'Custom feedback is required for custom refinement' ); } return true; } /** * Get the refinement instruction * * @return string */ protected function get_refinement_instruction() { return $this->get_config_value('feedback', ''); } /** * Get feedback from config or context * * @param AIGH_Pipeline_Context $context * @return string */ private function get_feedback($context) { // First check config $feedback = $this->get_config_value('feedback', ''); // If empty, check context if (empty($feedback)) { $feedback = $this->get_from_context($context, 'custom_feedback', ''); } return trim($feedback); } /** * Build the user prompt * * @param string $original_content * @param string $research_context * @param AIGH_Pipeline_Context $context * @return string */ protected function build_user_prompt($original_content, $research_context, $context) { $feedback = $this->get_feedback($context); $prompt = "Here is the original article:\n\n{$original_content}\n\n"; if (!empty($research_context)) { $prompt .= "\n{$research_context}\n\n"; $prompt .= "IMPORTANT: Use the specific data, statistics, and examples from the research above to improve the article.\n\n"; } $prompt .= "Refinement Task: {$feedback}\n"; if (!empty($research_context)) { $prompt .= "\nUSE THE RESEARCH FINDINGS to support your improvements.\n"; } $prompt .= "\n"; $prompt .= $this->get_standard_requirements(!empty($research_context)); return $prompt; } /** * Get configuration schema * * @return array */ public function get_config_schema() { return array_merge(parent::get_config_schema(), array( 'feedback' => array( 'type' => 'textarea', 'label' => 'Custom Feedback', 'description' => 'Provide specific instructions for how to refine the content', 'placeholder' => "E.g., 'Add more statistics about social media marketing' or 'Make the tone more friendly'", 'rows' => 4, 'required' => true ) )); } }