Skip to content

Commit a36cbff

Browse files
Merge pull request #28 from WordPress/update/php-ai-client-0.3
2 parents 3c1f14f + de34772 commit a36cbff

File tree

5 files changed

+58
-73
lines changed

5 files changed

+58
-73
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"php": ">=7.4",
3737
"ext-json": "*",
3838
"nyholm/psr7": "^1.5",
39-
"wordpress/php-ai-client": "^0.2"
39+
"wordpress/php-ai-client": "^0.3"
4040
},
4141
"require-dev": {
4242
"automattic/vipwpcs": "^3.0",

composer.lock

Lines changed: 50 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/API_Credentials/API_Credentials_Manager.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
* id: string,
3333
* name: string,
3434
* type: string,
35+
* credentialsUrl?: ?string,
3536
* ai_client_classnames: array<string, bool>
3637
* }
3738
*/

includes/API_Credentials/API_Credentials_Settings_Screen.php

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -111,28 +111,9 @@ function () {
111111
);
112112

113113
foreach ( $this->providers_metadata as $provider_metadata ) {
114-
$provider_id = $provider_metadata->getId();
115-
$provider_name = $provider_metadata->getName();
116-
117-
/*
118-
* This is a temporary hard-coded mapping of provider IDs to their API credentials URL.
119-
* Instead, this should become an optional field during provider registration in the PHP AI Client SDK.
120-
*
121-
* TODO: Remove this eventually once the PHP AI Client SDK supports this natively.
122-
*/
123-
switch ( $provider_id ) {
124-
case 'anthropic':
125-
$provider_credentials_url = 'https://console.anthropic.com/settings/keys';
126-
break;
127-
case 'google':
128-
$provider_credentials_url = 'https://aistudio.google.com/app/api-keys';
129-
break;
130-
case 'openai':
131-
$provider_credentials_url = 'https://platform.openai.com/api-keys';
132-
break;
133-
default:
134-
$provider_credentials_url = '';
135-
}
114+
$provider_id = $provider_metadata->getId();
115+
$provider_name = $provider_metadata->getName();
116+
$provider_credentials_url = $provider_metadata->getCredentialsUrl();
136117

137118
$field_id = "wp-ai-client-provider-api-key-{$provider_id}";
138119
$field_args = array(

includes/Builders/Prompt_Builder.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use WordPress\AiClient\Messages\DTO\Message;
1616
use WordPress\AiClient\Messages\DTO\MessagePart;
1717
use WordPress\AiClient\Messages\Enums\ModalityEnum;
18+
use WordPress\AiClient\Providers\Http\DTO\RequestOptions;
1819
use WordPress\AiClient\Providers\Models\Contracts\ModelInterface;
1920
use WordPress\AiClient\Providers\Models\DTO\ModelConfig;
2021
use WordPress\AiClient\Providers\Models\Enums\CapabilityEnum;
@@ -57,12 +58,14 @@
5758
* @method self using_presence_penalty(float $presencePenalty) Sets the presence penalty for generation.
5859
* @method self using_frequency_penalty(float $frequencyPenalty) Sets the frequency penalty for generation.
5960
* @method self using_web_search(WebSearch $webSearch) Sets the web search configuration.
61+
* @method self using_request_options(RequestOptions $options) Sets the request options for HTTP transport.
6062
* @method self using_top_logprobs(?int $topLogprobs = null) Sets the top log probabilities configuration.
6163
* @method self as_output_mime_type(string $mimeType) Sets the output MIME type.
6264
* @method self as_output_schema(array<string, mixed> $schema) Sets the output schema.
6365
* @method self as_output_modalities(ModalityEnum ...$modalities) Sets the output modalities.
6466
* @method self as_output_file_type(FileTypeEnum $fileType) Sets the output file type.
6567
* @method self as_json_response(?array<string, mixed> $schema = null) Configures the prompt for JSON response output.
68+
* @method bool is_supported(?CapabilityEnum $capability = null) Checks if the prompt is supported for the given capability.
6669
* @method bool is_supported_for_text_generation() Checks if the prompt is supported for text generation.
6770
* @method bool is_supported_for_image_generation() Checks if the prompt is supported for image generation.
6871
* @method bool is_supported_for_text_to_speech_conversion() Checks if the prompt is supported for text to speech conversion.

0 commit comments

Comments
 (0)