4 Commits

Author SHA1 Message Date
Weston Ruter dde3a47f0b AI: Validate filtered default request timeout in WP_AI_Client_Prompt_Builder.
This checks that the return value of the `wp_ai_client_default_request_timeout` filter is a non-negative number before passing it to `RequestOptions`. If the filtered value is invalid, it is discarded in favor of the original default of `30.0` and a `_doing_it_wrong()` notice is issued. Without this check, a fatal error would ensue from the exception thrown in `\WordPress\AiClient\Providers\Http\DTO\RequestOptions::validateTimeout()`.

The following static analysis issues are addressed:

* Use `float` instead of `int` for the `wp_ai_client_default_request_timeout` filter parameter.
* Add missing PHP imports for `Message` and `MessagePart` in the PHPDoc for `wp_ai_client_prompt()`.
* Add PHP return type hints for `wp_ai_client_prompt()` and `WP_AI_Client_Cache::getMultiple()`.
* Use native property type hints in `WP_AI_Client_HTTP_Client`.

Developed in https://github.com/WordPress/wordpress-develop/pull/11596

Props westonruter, justlevine, flixos90, khushdoms, darshitrajyaguru97, adrmf25, jarodortegaaraya, tusharaddweb, gaurangsondagar.
Fixes #65094.

Built from https://develop.svn.wordpress.org/trunk@62255


git-svn-id: http://core.svn.wordpress.org/trunk@61535 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2026-04-22 18:14:46 +00:00
gziolo 2ae77c3be3 AI: Prevent wp_supports_ai filter from overriding the WP_AI_SUPPORT constant.
When `WP_AI_SUPPORT` is explicitly set to `false`, `wp_supports_ai()` now returns early before the filter runs. This ensures the site owner's explicit preference to disable AI cannot be overridden by a plugin via the `wp_supports_ai` filter.

The filter default is now always `true`, since the constant check happens beforehand.

Developed in: https://github.com/WordPress/wordpress-develop/pull/11295

Follow-up to [62067].

Props justlevine, westonruter, gziolo, mindctrl, adamsilverstein, johnjamesjacoby, ahortin, nilambar, ozgursar, audrasjb, jeffpaul.
Fixes #64706.


Built from https://develop.svn.wordpress.org/trunk@62239


git-svn-id: http://core.svn.wordpress.org/trunk@61519 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2026-04-16 07:38:44 +00:00
Sergey Biryukov 14e6c3409c AI: Introduce wp_supports_ai() function to control LLM-related features.
This includes a `WP_AI_SUPPORT` constant and a `wp_supports_ai` filter.

When false,
- `_wp_connectors_get_provider_settings()` will return an empty array (short-circuiting the other functionality).
- `WP_AI_Client_Prompt_Builder()` will short-circuit the construction with a `WP_Error()`. `wp_ai_client_prompt()` will still return an instance, to allow for fluidity to remain intact.

Priority: `WP_AI_SUPPORT` > `add_filter( 'wp_supports_ai', ...) > (default: true)` 

Follow-up to [61943], [61749], [61943].

Props justlevine, westonruter, gziolo, flixos90, romainmrhenry, ahortin, chrismcelroyseo, SergeyBiryukov.
See #64706.
Built from https://develop.svn.wordpress.org/trunk@62067


git-svn-id: http://core.svn.wordpress.org/trunk@61349 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2026-03-19 13:56:50 +00:00
Felix Arntz 56ad39db67 AI: Add the WordPress AI Client.
The WordPress AI Client is a provider-agnostic API for WordPress code to call generative AI models via a consistent interface. Plugins and Core can use it to provide AI driven features for users, while users maintain full autonomy in choosing which AI provider(s) they want to rely on and how they configure them.

This changeset merges the technical foundation for the WordPress AI Client into Core. This foundation was originally implemented in the https://github.com/WordPress/wp-ai-client package, which will be sunset going forward. The underlying https://github.com/WordPress/php-ai-client package is bundled with this changeset and will remain a separate library maintained by the WordPress project, for WordPress Core and the PHP ecosystem.

No AI providers are bundled out of the box. Without explicit configuration and explicit calling code, WordPress will not send prompts or data to any external service. Site owners will be able to install plugins to enable usage of specific AI providers, built on top of this foundation.

This is the first changeset of two that are most relevant for the AI Client feature. The subsequent change will introduce a configuration screen for different AI providers, where users can install provider plugins, configure their credentials, and enable the canonical WordPress AI plugin. Together, this infrastructure and UI will enable the WordPress ecosystem to build AI features in a seamless and interoperable way.

Original merge proposal: https://make.wordpress.org/core/2026/02/03/proposal-for-merging-wp-ai-client-into-wordpress-7-0/

Props jason_the_adams, flixos90, desrosj, dkotter, jorgefilipecosta, peterwilsoncc, johnbillion, jorbin, swissspidy, isotropic.
See #64591.

Built from https://develop.svn.wordpress.org/trunk@61700


git-svn-id: http://core.svn.wordpress.org/trunk@61008 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2026-02-20 08:42:48 +00:00