Skip to content

Commit e8fa887

Browse files
committed
Fix lint errors
1 parent ff16051 commit e8fa887

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

includes/API_Request.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77

88
namespace WordPress\AI;
99

10+
use Throwable;
11+
use WP_Error;
1012
use WordPress\AiClient\AiClient;
1113
use WordPress\AiClient\Providers\Models\DTO\ModelConfig;
12-
use WP_Error;
1314

1415
/**
1516
* Handles API requests to various AI services.
@@ -59,7 +60,7 @@ public function __construct( string $provider = '', string $model = '' ) {
5960
* @param array $options The options to send.
6061
* @return array|\WP_Error The result of the request.
6162
*/
62-
public function generate_text( $prompt = null, $system_instruction = null, array $options = [] ) {
63+
public function generate_text( $prompt = null, $system_instruction = null, array $options = array() ) {
6364
if ( ! $this->is_client_available() ) {
6465
return new WP_Error( 'ai_client_not_available', __( 'AI Client is not available', 'ai' ) );
6566
}
@@ -83,7 +84,7 @@ public function generate_text( $prompt = null, $system_instruction = null, array
8384
* @param array $options The options to send.
8485
* @return \WordPress\AiClient\PromptBuilder|\WP_Error The prompt builder or a WP_Error.
8586
*/
86-
protected function prompt_builder( $prompt = null, $system_instruction = null, array $options = [] ) {
87+
protected function prompt_builder( $prompt = null, $system_instruction = null, array $options = array() ) {
8788
try {
8889
$model_config = $this->process_model_config( $options );
8990
$prompt_builder = AiClient::prompt( $prompt );
@@ -105,8 +106,8 @@ protected function prompt_builder( $prompt = null, $system_instruction = null, a
105106
}
106107

107108
return $prompt_builder;
108-
} catch ( \Exception $e ) {
109-
return new WP_Error( 'ai_client_error', $e->getMessage() );
109+
} catch ( Throwable $t ) {
110+
return new WP_Error( 'ai_client_error', $t->getMessage() );
110111
}
111112
}
112113

@@ -123,7 +124,7 @@ protected function get_result( array $response ) {
123124
return new WP_Error( 'no_choices', __( 'No choices were returned from the AI provider', 'ai' ) );
124125
}
125126

126-
$results = [];
127+
$results = array();
127128
foreach ( $response as $choice ) {
128129
$results[] = $this->sanitize_choice( $choice );
129130
}
@@ -149,11 +150,11 @@ protected function sanitize_choice( string $choice ): string {
149150
* @since 0.1.0
150151
*
151152
* @param array $options The options to add to the model config.
152-
* @return ModelConfig
153+
* @return \WordPress\AiClient\Providers\Models\DTO\ModelConfig
153154
*/
154155
protected function process_model_config( array $options ): ModelConfig {
155156
$schema = ModelConfig::getJsonSchema()['properties'];
156-
$model_config = [];
157+
$model_config = array();
157158

158159
foreach ( $options as $key => $value ) {
159160
if ( ! isset( $schema[ $key ] ) ) {

includes/Abilities/Title_Generation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ protected function execute_callback( $input ) {
130130
}
131131

132132
// Return the titles in the format the Ability expects.
133-
return [ 'titles' => $result ];
133+
return array( 'titles' => $result );
134134
}
135135

136136
/**

includes/Features/Title_Generation/Title_Generation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
namespace WordPress\AI\Features\Title_Generation;
99

10+
use WordPress\AI\API_Request;
1011
use WordPress\AI\Abilities\Title_Generation as Title_Generation_Ability;
1112
use WordPress\AI\Abstracts\Abstract_Feature;
12-
use WordPress\AI\API_Request;
1313

1414
/**
1515
* Title generation feature.
@@ -80,7 +80,7 @@ public function generate_titles( string $content, int $n = 1 ) {
8080
// Make our request.
8181
$request = new API_Request();
8282
$response = $request->generate_text(
83-
'"""'. $content . '"""',
83+
'"""' . $content . '"""',
8484
$this->get_system_instruction(),
8585
array(
8686
'candidateCount' => (int) $n,

0 commit comments

Comments
 (0)