Skip to content

Commit da29248

Browse files
committed
Add --service arg
1 parent 8da2869 commit da29248

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/AI/AiClient.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class AiClient {
3535
public function __construct(
3636
private readonly array $tools,
3737
private readonly bool $approval_mode,
38+
private readonly ?string $service,
3839
private readonly ?string $model
3940
) {}
4041

@@ -106,6 +107,7 @@ static function () {
106107
try {
107108
$service = ai_services()->get_available_service(
108109
[
110+
'slugs' => $this->service ? [ $this->service ] : null,
109111
'capabilities' => [
110112
AI_Capability::MULTIMODAL_INPUT,
111113
AI_Capability::TEXT_GENERATION,

src/AiCommand.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ class AiCommand extends WP_CLI_Command {
3939
* [--approval-mode]
4040
* : Approve tool usage before running.
4141
*
42+
* [--service]
43+
* : Manually specify the AI service to use.
44+
* Depends on the available AI services.
45+
* Examples: 'google', 'anthropic', 'openai'.
46+
*
4247
* [--model]
4348
* : Manually specify the LLM model that should be used.
4449
* Depends on the available AI services.
@@ -79,9 +84,10 @@ public function __invoke( array $args, array $assoc_args ): void {
7984
$tools = $this->get_tools( $sessions );
8085

8186
$approval_mode = (bool) Utils\get_flag_value( $assoc_args, 'approval-mode', false );
87+
$service = Utils\get_flag_value( $assoc_args, 'service' );
8288
$model = Utils\get_flag_value( $assoc_args, 'model' );
8389

84-
$ai_client = new AiClient( $tools, $approval_mode, $model );
90+
$ai_client = new AiClient( $tools, $approval_mode, $service, $model );
8591

8692
$ai_client->call_ai_service_with_prompt( $args[0] );
8793
}

0 commit comments

Comments
 (0)