Automattic\WooCommerce\Blocks\AIContent
ContentProcessor::summarize_business_description()
Summarize the business description to ensure better results are returned by AI.
Метод класса: ContentProcessor{}
Хуков нет.
Возвращает
Разное|WP_Error
.
Использование
$result = ContentProcessor::summarize_business_description( $business_description, $ai_connection, $token, $character_limit );
- $business_description(строка) (обязательный)
- The business description.
- $ai_connection(Connection) (обязательный)
- The AI connection.
- $token(строка) (обязательный)
- The JWT token.
- $character_limit(int)
- The character limit for the business description.
По умолчанию: 150
Код ContentProcessor::summarize_business_description() ContentProcessor::summarize business description WC 9.4.2
public static function summarize_business_description( $business_description, $ai_connection, $token, $character_limit = 150 ) { if ( empty( $business_description ) ) { return new WP_Error( 'business_description_not_found', __( 'No business description provided for generating AI content.', 'woocommerce' ) ); } if ( strlen( $business_description ) > $character_limit ) { $prompt = sprintf( 'You are a professional writer. Read the following business description and write a text with less than %s characters to summarize the products the business is selling: "%s". Make sure you do not add double quotes in your response. Do not add any explanations in the response', $character_limit, $business_description ); $response = $ai_connection->fetch_ai_response( $token, $prompt, 30 ); $business_description = $response['completion'] ?? $business_description; } return $business_description; }