WP_AI_Client_Ability_Function_Resolver::execute_abilities( WordPressAiClientMessagesDTOMessage $message ): WordPressAiClientMessagesDTOMessage

In this article

Executes all ability function calls in a message.

Parameters

$messageWordPressAiClientMessagesDTOMessagerequired
The message containing function calls.

Return

WordPressAiClientMessagesDTOMessage A new message with function responses.

Source

public function execute_abilities( Message $message ): Message {
	$response_parts = array();

	foreach ( $message->getParts() as $part ) {
		if ( $part->getType()->isFunctionCall() ) {
			$function_call = $part->getFunctionCall();
			if ( $function_call instanceof FunctionCall ) {
				$function_response = $this->execute_ability( $function_call );
				$response_parts[]  = new MessagePart( $function_response );
			}
		}
	}

	return new UserMessage( $response_parts );
}

Changelog

VersionDescription
7.0.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.