Skip to content

Commit 639cb38

Browse files
authored
Merge pull request #1001 from 10up/update/azure-openai-api
Update Azure OpenAI to the latest GA API version
2 parents 6dd02f2 + f3f2c1c commit 639cb38

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

includes/Classifai/Providers/Azure/OpenAI.php

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ class OpenAI extends Provider {
4646
*
4747
* @var string
4848
*/
49-
protected $chat_completion_api_version = '2023-05-15';
49+
protected $chat_completion_api_version = '2024-10-21';
5050

5151
/**
5252
* Completion API version.
5353
*
5454
* @var string
5555
*/
56-
protected $completion_api_version = '2023-05-15';
56+
protected $completion_api_version = '2024-10-21';
5757

5858
/**
5959
* GeminiAPI constructor.
@@ -64,6 +64,25 @@ public function __construct( $feature_instance = null ) {
6464
$this->feature_instance = $feature_instance;
6565
}
6666

67+
/**
68+
* Get the API version.
69+
*
70+
* @return string
71+
*/
72+
public function get_api_version(): string {
73+
/**
74+
* Filter the API version.
75+
*
76+
* @since x.x.x
77+
* @hook classifai_azure_openai_api_version
78+
*
79+
* @param string $version The default API version.
80+
*
81+
* @return string The API version.
82+
*/
83+
return apply_filters( 'classifai_azure_openai_api_version', $this->chat_completion_api_version );
84+
}
85+
6786
/**
6887
* Render the provider fields.
6988
*/
@@ -254,11 +273,12 @@ protected function prep_api_url( ?\Classifai\Features\Feature $feature = null ):
254273
( $feature instanceof ContentResizing ||
255274
$feature instanceof ExcerptGeneration ||
256275
$feature instanceof TitleGeneration ||
257-
$feature instanceof KeyTakeaways ) &&
276+
$feature instanceof KeyTakeaways ||
277+
$feature instanceof ContentGeneration ) &&
258278
$deployment
259279
) {
260280
$endpoint = trailingslashit( $endpoint ) . str_replace( '{deployment-id}', $deployment, $this->chat_completion_url );
261-
$endpoint = add_query_arg( 'api-version', $this->chat_completion_api_version, $endpoint );
281+
$endpoint = add_query_arg( 'api-version', $this->get_api_version(), $endpoint );
262282
}
263283

264284
return $endpoint;

0 commit comments

Comments
 (0)