Skip to content

Commit 88aa4e2

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 6cba05e + 2493552 commit 88aa4e2

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/MCP/Client.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,19 @@ static function () {
172172
]
173173
);
174174

175-
\WP_CLI::log( 'Making request...' . print_r( $contents, true ) );
175+
\WP_CLI::log( 'Making request...' . print_r( $contents, true ) );
176+
177+
if ( $service->get_service_slug() === 'openai' ) {
178+
$model = 'gpt-4o';
179+
} else {
180+
$model = 'gemini-2.0-flash';
181+
}
176182

177183
$candidates = $service
178184
->get_model(
179185
[
180186
'feature' => 'text-generation',
187+
'model' => $model,
181188
'tools' => $tools,
182189
'capabilities' => [
183190
AI_Capability::MULTIMODAL_INPUT,
@@ -196,7 +203,6 @@ static function () {
196203
}
197204
$text .= $part->get_text();
198205
} elseif ( $part instanceof Function_Call_Part ) {
199-
var_dump( 'call function', $part );
200206
$function_result = $this->{$part->get_name()}( $part->get_args() );
201207

202208
// Odd limitation of add_function_response_part().
@@ -221,7 +227,15 @@ static function () {
221227
return $this->call_ai_service( $new_contents );
222228
}
223229

224-
return $text;
230+
// Keep the session open to continue chatting.
231+
232+
$response = \cli\prompt( 'Continue' );
233+
234+
$parts = new Parts();
235+
$parts->add_text_part( $response );
236+
$content = new Content( Content_Role::USER, $parts );
237+
$new_contents[] = $content;
238+
return $this->call_ai_service( $new_contents );
225239
} catch ( Exception $e ) {
226240
WP_CLI::error( $e->getMessage() );
227241
}

0 commit comments

Comments
 (0)