| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Source view] [Print] [Project Stats]
WP AI Client: WP_AI_Client_Prompt_Builder class
| File Size: | 487 lines (20 kb) |
| Included or required: | 0 times |
| Referenced: | 0 times |
| Includes or requires: | 0 files |
WP_AI_Client_Prompt_Builder:: (8 methods):
__construct()
using_abilities()
__call()
exception_to_wp_error()
is_support_check_method()
is_generating_method()
get_builder_callable()
snake_to_camel_case()
Class: WP_AI_Client_Prompt_Builder - X-Ref
Fluent builder for constructing AI prompts, returning WP_Error on failure.| __construct( ProviderRegistry $registry, $prompt = null ) X-Ref |
| Constructor. param: ProviderRegistry $registry The provider registry for finding suitable models. param: Prompt $prompt Optional. Initial prompt content. |
| using_abilities( ...$abilities ) X-Ref |
| Registers WordPress abilities as function declarations for the AI model. Converts each WP_Ability to a FunctionDeclaration using the wpab__ prefix naming convention and passes them to the underlying prompt builder. return: self The current instance for method chaining. param: WP_Ability|string ...$abilities The abilities to register, either as WP_Ability objects or ability name strings. |
| __call( string $name, array $arguments ) X-Ref |
| Magic method to proxy snake_case method calls to their PHP AI Client camelCase counterparts. This allows WordPress developers to use snake_case naming conventions. It catches any exceptions thrown, stores them, and returns a WP_Error when a terminate method is called. return: mixed The result of the method call. param: string $name The method name in snake_case. param: array<int, mixed> $arguments The method arguments. |
| exception_to_wp_error( Exception $e ) X-Ref |
| Converts an exception into a WP_Error with a structured error code and message. This method maps different exception types to specific WP_Error codes and HTTP status codes. The presence of the status codes means these WP_Error objects can be easily used in REST API responses or other contexts where HTTP semantics are relevant. return: WP_Error The resulting WP_Error object. param: Exception $e The exception to convert. |
| is_support_check_method( string $name ) X-Ref |
| Checks if a method name is a support check method (is_supported*). return: bool True if the method is a support check method, false otherwise. param: string $name The method name. |
| is_generating_method( string $name ) X-Ref |
| Checks if a method name is a generating method (generate_*, convert_text_to_speech*). return: bool True if the method is a generating method, false otherwise. param: string $name The method name. |
| get_builder_callable( string $name ) X-Ref |
| Retrieves a callable for a given PHP AI Client SDK prompt builder method name. return: callable The callable for the specified method. param: string $name The method name in snake_case. |
| snake_to_camel_case( string $snake_case ) X-Ref |
| Converts snake_case to camelCase. return: string The camelCase string. param: string $snake_case The snake_case string. |
| Generated : Sat Jun 13 09:38:55 2026 | Cross-referenced by PHPXref |