Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Azure Language Services provider #786

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
2 changes: 2 additions & 0 deletions includes/Classifai/Features/ExcerptGeneration.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Classifai\Providers\GoogleAI\GeminiAPI;
use Classifai\Providers\OpenAI\ChatGPT;
use Classifai\Providers\Azure\OpenAI;
use Classifai\Providers\Azure\Language;
use WP_REST_Server;
use WP_REST_Request;
use WP_Error;
Expand Down Expand Up @@ -45,6 +46,7 @@ public function __construct() {
ChatGPT::ID => __( 'OpenAI ChatGPT', 'classifai' ),
GeminiAPI::ID => __( 'Google AI (Gemini API)', 'classifai' ),
OpenAI::ID => __( 'Azure OpenAI', 'classifai' ),
Language::ID => __( 'Azure Language', 'classifai' ),
];
}

Expand Down
24 changes: 24 additions & 0 deletions includes/Classifai/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -661,3 +661,27 @@ function get_classification_mode(): string {

return $value;
}


/**
* Use VIP's `vip_safe_wp_remote_get` if available, otherwise use `wp_remote_get`.
*
* @param string $url URL to fetch.
* @param array $args Optional. Request arguments.
* @return WP_Error|array The response or WP_Error on failure.
*/
function safe_wp_remote_get( string $url, array $args = [] ) {
if ( function_exists( 'vip_safe_wp_remote_get' ) ) {
return vip_safe_wp_remote_get( $url, $args );
}

wp_parse_args(
$args,
[
'timeout' => 20, // phpcs:ignore

]
);

return wp_remote_get( $url, $args ); // phpcs:ignore
}
Loading
Loading