From f1deaec60b633976af8bda624e4a56b8ee2a94a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alba=20Rinc=C3=B3n?= Date: Wed, 22 Nov 2023 16:12:23 +0100 Subject: [PATCH 1/2] Tweak the product prompt To avoid creating products that are things that cannot be sold in stores (forests, people, etc.) --- src/Patterns/ProductUpdater.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Patterns/ProductUpdater.php b/src/Patterns/ProductUpdater.php index e2b8113e6e6..a8ac75c3d3d 100644 --- a/src/Patterns/ProductUpdater.php +++ b/src/Patterns/ProductUpdater.php @@ -321,9 +321,9 @@ public function assign_ai_generated_content_to_dummy_products( $ai_connection, $ $prompts = []; foreach ( $products_information_list as $product_information ) { if ( ! empty( $product_information['image']['alt'] ) ) { - $prompts[] = sprintf( 'Generate a product name that exactly matches the following image description: "%s" and also is related to the following business description: "%s". Do not include any adjectives or descriptions of the qualities of the product and always refer to objects or services, not humans. The returned result should not refer to people, only objects.', $product_information['image']['alt'], $business_description ); + $prompts[] = sprintf( 'Generate a product name for a product that could be sold in a store and could be associated with the following image description: "%s" and also is related to the following business description: "%s". Do not include any adjectives or descriptions of the qualities of the product and always refer to objects or services, not humans. The returned result should not refer to people, only objects.', $product_information['image']['alt'], $business_description ); } else { - $prompts[] = sprintf( 'Generate a product name that matches the following business description: "%s". Do not include any adjectives or descriptions of the qualities of the product and always refer to objects or services, not humans.', $business_description ); + $prompts[] = sprintf( 'Generate a product name for a product that could be sold in a store and matches the following business description: "%s". Do not include any adjectives or descriptions of the qualities of the product and always refer to objects or services, not humans.', $business_description ); } } From f7a42ee75ca652cd444f2fc10d069535c1159307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alba=20Rinc=C3=B3n?= Date: Thu, 23 Nov 2023 09:55:29 +0100 Subject: [PATCH 2/2] Return error when images are not provided --- src/Patterns/PatternUpdater.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Patterns/PatternUpdater.php b/src/Patterns/PatternUpdater.php index bd9f149e5a3..50265ab743e 100644 --- a/src/Patterns/PatternUpdater.php +++ b/src/Patterns/PatternUpdater.php @@ -43,6 +43,10 @@ class PatternUpdater { * @return bool|WP_Error */ public function generate_content( $ai_connection, $token, $images, $business_description ) { + if ( empty( $images ) ) { + return new \WP_Error( 'images_not_found', __( 'No images provided for generating AI content.', 'woo-gutenberg-products-block' ) ); + } + if ( is_wp_error( $images ) ) { return $images; }