plugin updates

This commit is contained in:
Tony Volpe
2024-02-21 16:19:46 +00:00
parent c72f206574
commit 21d4c85c00
1214 changed files with 102269 additions and 179257 deletions

View File

@@ -3,7 +3,8 @@
namespace Automattic\WooCommerce\Blocks\Images;
use Automattic\WooCommerce\Blocks\AI\Connection;
use Automattic\WooCommerce\Blocks\Patterns\PatternUpdater;
use Automattic\WooCommerce\Blocks\AIContent\ContentProcessor;
use Automattic\WooCommerce\Blocks\AIContent\UpdatePatterns;
/**
* Pexels API client.
@@ -27,6 +28,8 @@ class Pexels {
* @return array|\WP_Error Array of images, or WP_Error if the request failed.
*/
public function get_images( $ai_connection, $token, $business_description ) {
$business_description = ContentProcessor::summarize_business_description( $business_description, $ai_connection, $token );
if ( str_word_count( $business_description ) === 1 ) {
$search_term = $business_description;
} else {
@@ -111,6 +114,7 @@ class Pexels {
* @return mixed|\WP_Error
*/
private function define_search_term( $ai_connection, $token, $business_description ) {
$prompt = sprintf( 'You are a teacher. Based on the following business description, \'%s\', describe to a child exactly what this store is selling in one or two words and be as precise as you can possibly be. Do not reply with generic words that could cause confusion and be associated with other businesses as a response. Make sure you do not add double quotes in your response. Do not add any explanations in the response', $business_description );
$response = $ai_connection->fetch_ai_response( $token, $prompt, 30 );
@@ -119,6 +123,10 @@ class Pexels {
return $response;
}
if ( isset( $response['code'] ) && 'completion_error' === $response['code'] ) {
return new \WP_Error( 'search_term_definition_failed', __( 'The search term definition failed.', 'woocommerce' ) );
}
if ( ! isset( $response['completion'] ) ) {
return new \WP_Error( 'search_term_definition_failed', __( 'The search term definition failed.', 'woocommerce' ) );
}
@@ -222,7 +230,7 @@ class Pexels {
* @return array|\WP_Error The total number of required images, or WP_Error if the request failed.
*/
private function total_number_required_images() {
$patterns_dictionary = PatternUpdater::get_patterns_dictionary();
$patterns_dictionary = UpdatePatterns::get_patterns_dictionary();
if ( is_wp_error( $patterns_dictionary ) ) {
return $patterns_dictionary;