Skip to content

Commit 4844b7c

Browse files
committed
Keep prompt open
1 parent 7810221 commit 4844b7c

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/MCP/Client.php

Lines changed: 18 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,7 @@ static function () {
196203
}
197204
$text .= $part->get_text();
198205
} elseif ( $part instanceof Function_Call_Part ) {
199-
var_dump( 'call function', $part );
206+
// var_dump( 'call function', $part );
200207
$function_result = $this->{$part->get_name()}( $part->get_args() );
201208

202209
// Odd limitation of add_function_response_part().
@@ -221,7 +228,15 @@ static function () {
221228
return $this->call_ai_service( $new_contents );
222229
}
223230

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

0 commit comments

Comments
 (0)