] * : Number of articles to process. Defaults to 15 in CLI mode. * * [--force] * : Ignore the admin max articles per cycle limit. * * ## EXAMPLES * * wp peptide-news process-llm --batch=20 --force * * @when after_wp_load */ public function process_llm( array $args = array(), array $assoc_args = array() ): void { if ( ! Peptide_News_LLM::is_enabled() ) { if ( class_exists( 'WP_CLI' ) && method_exists( 'WP_CLI', 'error' ) ) { WP_CLI::error( 'LLM processing is disabled or missing an API key.' ); } return; } $batch_size = isset( $assoc_args['batch'] ) ? absint( $assoc_args['batch'] ) : 15; if ( $batch_size < 1 ) { $batch_size = 15; } $force = isset( $assoc_args['force'] ); if ( class_exists( 'WP_CLI' ) && method_exists( 'WP_CLI', 'log' ) ) { WP_CLI::log( sprintf( 'Processing up to %d unanalyzed articles through 3-Step AI Pipeline...', $batch_size ) ); } $start = microtime( true ); $processed = Peptide_News_LLM::process_unanalyzed( $batch_size, $force ); $duration = round( microtime( true ) - $start, 2 ); if ( class_exists( 'WP_CLI' ) && method_exists( 'WP_CLI', 'success' ) ) { WP_CLI::success( sprintf( 'Successfully generated AI summaries for %d articles in %s seconds.', $processed, $duration ) ); } } /** * Resolve Google News redirect URLs and update database sources. * * ## OPTIONS * * [--limit=] * : Maximum number of unresolved URLs to resolve. Default 20. * * ## EXAMPLES * * wp peptide-news backfill-sources --limit=50 * * @when after_wp_load */ public function backfill_sources( array $args = array(), array $assoc_args = array() ): void { $limit = isset( $assoc_args['limit'] ) ? absint( $assoc_args['limit'] ) : 20; if ( $limit < 1 ) { $limit = 20; } if ( class_exists( 'WP_CLI' ) && method_exists( 'WP_CLI', 'log' ) ) { WP_CLI::log( sprintf( 'Resolving up to %d redirect URLs...', $limit ) ); } $start = microtime( true ); $resolved = Peptide_News_Source_Resolver::backfill( $limit ); $duration = round( microtime( true ) - $start, 2 ); if ( class_exists( 'WP_CLI' ) && method_exists( 'WP_CLI', 'success' ) ) { WP_CLI::success( sprintf( 'Resolved %d URLs in %s seconds.', $resolved, $duration ) ); } } }