| @@ -317,12 +317,20 @@ | ||
| 317 | 317 | // `generate_text()` with a JSON schema — same call shape the comment |
| 318 | 318 | // scorer uses. The SDK can throw as well as return a WP_Error, so both |
| 319 | 319 | // paths land on the same 502. |
| 320 | 320 | try { |
| 321 | - $json = wp_ai_client_prompt( openstation_drafts_ai_prompt_text( $post ) ) | |
| 321 | + $builder = wp_ai_client_prompt( openstation_drafts_ai_prompt_text( $post ) ) | |
| 322 | 322 | ->using_system_instruction( openstation_drafts_ai_instructions( $post ) ) |
| 323 | - ->as_json_response( openstation_ai_normalize_response_schema( openstation_drafts_ai_schema( $post ) ) ) | |
| 324 | - ->generate_text(); | |
| 323 | + ->as_json_response( openstation_ai_normalize_response_schema( openstation_drafts_ai_schema( $post ) ) ); | |
| 324 | + | |
| 325 | + $json = openstation_ai_apply_model_config( | |
| 326 | + $builder, | |
| 327 | + array( | |
| 328 | + 'user_id' => get_current_user_id(), | |
| 329 | + 'source' => 'widgets/drafts-suggestions', | |
| 330 | + 'has_schema' => true, | |
| 331 | + ) | |
| 332 | + )->generate_text(); | |
| 325 | 333 | } catch ( \Throwable $e ) { |
| 326 | 334 | $json = new WP_Error( 'openstation_ai_failed', $e->getMessage() ); |
| 327 | 335 | } |
| 328 | 336 | |