Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/MCP/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,19 @@ static function () {
]
);

\WP_CLI::log( 'Making request...' . print_r( $contents, true ) );
\WP_CLI::log( 'Making request...' . print_r( $contents, true ) );

if ( $service->get_service_slug() === 'openai' ) {
$model = 'gpt-4o';
} else {
$model = 'gemini-2.0-flash';
}

$candidates = $service
->get_model(
[
'feature' => 'text-generation',
'model' => $model,
'tools' => $tools,
'capabilities' => [
AI_Capability::MULTIMODAL_INPUT,
Expand All @@ -196,7 +203,6 @@ static function () {
}
$text .= $part->get_text();
} elseif ( $part instanceof Function_Call_Part ) {
var_dump( 'call function', $part );
$function_result = $this->{$part->get_name()}( $part->get_args() );

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

return $text;
// Keep the session open to continue chatting.

$response = \cli\prompt( 'Continue' );

$parts = new Parts();
$parts->add_text_part( $response );
$content = new Content( Content_Role::USER, $parts );
$new_contents[] = $content;
return $this->call_ai_service( $new_contents );
} catch ( Exception $e ) {
WP_CLI::error( $e->getMessage() );
}
Expand Down