feat: add opik instrumentation to image and content pipeline
- Add optional $trace_context parameter to PRAutoBlogger_Image_Prompt_Builder - Wrap LLM call in image_prompt_rewrite span when trace context available - Pass trace context through from image pipeline - Add $eval_mode parameter to content generator generate() method - Define PRAUTOBLOGGER_EVAL_MODE constant to suppress side effects - Add generate_eval() convenience method - Register WP-CLI hook in main orchestrator - Bump version to 0.13.0
This commit is contained in:
@@ -55,6 +55,7 @@ class PRAutoBlogger {
|
||||
$this->register_cron_hooks();
|
||||
$this->register_frontend_hooks();
|
||||
$this->register_ajax_hooks();
|
||||
$this->register_cli_hooks();
|
||||
|
||||
/** Fires after PRAutoBlogger has finished registering all hooks. */
|
||||
do_action( 'prautoblogger_loaded' );
|
||||
@@ -301,7 +302,12 @@ class PRAutoBlogger {
|
||||
* @param object $transient The update_plugins transient data.
|
||||
* @return object Modified transient.
|
||||
*/
|
||||
public function filter_block_false_updates( $transient ) {
|
||||
/** Register WP-CLI commands. */
|
||||
private function register_cli_hooks(): void {
|
||||
PRAutoBlogger_WP_CLI_Commands::register();
|
||||
}
|
||||
|
||||
public function filter_block_false_updates( $transient ) {
|
||||
if ( isset( $transient->response[ PRAUTOBLOGGER_PLUGIN_BASENAME ] ) ) {
|
||||
unset( $transient->response[ PRAUTOBLOGGER_PLUGIN_BASENAME ] );
|
||||
}
|
||||
|
||||
@@ -29,7 +29,10 @@ class PRAutoBlogger_Content_Generator {
|
||||
* @param PRAutoBlogger_Article_Idea $idea The scored idea to generate content for.
|
||||
* @return string Generated HTML content.
|
||||
*/
|
||||
public function generate( PRAutoBlogger_Article_Idea $idea ): string {
|
||||
public function generate( PRAutoBlogger_Article_Idea $idea, bool $eval_mode = false ): string {
|
||||
// In eval mode, suppress publishing and image generation side effects.
|
||||
define( 'PRAUTOBLOGGER_EVAL_MODE', $eval_mode );
|
||||
|
||||
$mode = get_option( 'prautoblogger_writing_pipeline', 'multi_step' );
|
||||
|
||||
$request = new PRAutoBlogger_Content_Request(
|
||||
@@ -285,4 +288,14 @@ class PRAutoBlogger_Content_Generator {
|
||||
|
||||
return $response['content'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate content in eval mode (no publishing, no image generation).
|
||||
*
|
||||
* @param PRAutoBlogger_Article_Idea $idea The scored idea to generate content for.
|
||||
* @return string Generated HTML content.
|
||||
*/
|
||||
public function generate_eval( PRAutoBlogger_Article_Idea $idea ): string {
|
||||
return $this->generate( $idea, true );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,12 +47,14 @@ class PRAutoBlogger_Image_Pipeline {
|
||||
*/
|
||||
public function __construct(
|
||||
?PRAutoBlogger_Image_Provider_Interface $provider = null,
|
||||
?PRAutoBlogger_Cost_Tracker $cost_tracker = null
|
||||
?PRAutoBlogger_Cost_Tracker $cost_tracker = null,
|
||||
?PRAutoBlogger_Opik_Trace_Context $trace_context = null
|
||||
) {
|
||||
$this->provider = $provider ?? self::create_default_provider();
|
||||
$this->prompt_builder = new PRAutoBlogger_Image_Prompt_Builder();
|
||||
$this->prompt_builder = new PRAutoBlogger_Image_Prompt_Builder( $trace_context );
|
||||
$this->sideloader = new PRAutoBlogger_Image_Media_Sideloader();
|
||||
$this->cost_tracker = $cost_tracker ?? new PRAutoBlogger_Cost_Tracker();
|
||||
$this->trace_context = $trace_context;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* Plugin Name: PRAutoBlogger
|
||||
* Plugin URI: https://peptiderepo.com/prautoblogger
|
||||
* Description: Monitors social media for trending topics, generates SEO-friendly blog posts using AI, and publishes them on a daily schedule with full cost tracking and self-improvement metrics.
|
||||
* Version: 0.12.3
|
||||
* Version: 0.13.0
|
||||
* Requires at least: 6.0
|
||||
* Requires PHP: 7.4
|
||||
* Author: PeptideRepo
|
||||
@@ -35,7 +35,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
| Defined here so every file in the plugin can reference paths, versions,
|
||||
| and limits without magic strings.
|
||||
*/
|
||||
define( 'PRAUTOBLOGGER_VERSION', '0.12.3' );
|
||||
define( 'PRAUTOBLOGGER_VERSION', '0.13.0' );
|
||||
define( 'PRAUTOBLOGGER_DB_VERSION', '1.1.0' );
|
||||
define( 'PRAUTOBLOGGER_PLUGIN_FILE', __FILE__ );
|
||||
define( 'PRAUTOBLOGGER_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
||||
|
||||
Reference in New Issue
Block a user