@@ -110,6 +110,7 @@ static function () {
110110 file_put_contents ( $ filename , $ image_blob ->get_binary_data () );
111111
112112 $ image_url = $ filename ;
113+ $ image_id = \WP_CLI \AiCommand \MediaManager::upload_to_media_library ($ image_url );
113114 }
114115
115116 break ;
@@ -120,6 +121,8 @@ static function () {
120121 // TODO: Save as file or so.
121122 break ;
122123 }
124+
125+ return $ image_id || 'no image found ' ;
123126 }
124127
125128 // See https://github.com/felixarntz/ai-services/blob/main/docs/Accessing-AI-Services-in-PHP.md for further processing.
@@ -188,17 +191,17 @@ static function () {
188191
189192 \WP_CLI ::debug ( 'Making request... ' . print_r ( $ contents , true ), 'ai ' );
190193
191- if ( $ service ->get_service_slug () === 'openai ' ) {
192- $ model = 'gpt-4o ' ;
193- } else {
194- $ model = 'gemini-2.0-flash ' ;
195- }
194+ // if ( $service->get_service_slug() === 'openai' ) {
195+ // $model = 'gpt-4o';
196+ // } else {
197+ // $model = 'gemini-2.0-flash';
198+ // }
196199
197200 $ candidates = $ service
198201 ->get_model (
199202 [
200203 'feature ' => 'text-generation ' ,
201- 'model ' => $ model ,
204+ // 'model' => $model,
202205 'tools ' => $ tools ,
203206 'capabilities ' => [
204207 AI_Capability::MULTIMODAL_INPUT ,
@@ -227,9 +230,7 @@ static function () {
227230 } elseif ( $ part instanceof Function_Call_Part ) {
228231 $ function_result = $ this ->{$ part ->get_name ()}( $ part ->get_args () );
229232
230- // Capture the function name here
231- $ function_name = $ part ->get_name ();
232- echo "Output generated with the ' $ function_name' tool: \n" ; // Log the function name
233+ WP_CLI ::debug ( 'Calling Tool: ' . $ part ->get_name (), 'mcp_server ' );
233234
234235 // Odd limitation of add_function_response_part().
235236 if ( ! is_array ( $ function_result ) ) {
0 commit comments