purposePresets( $options ); $purpose = $this->resolvePurpose( $options, $presets ); $tone = $this->resolveOptionString( $options, 'tone', 'Professional' ); $language = $this->resolveOptionString( $options, 'language', 'English' ); $length = $this->resolveOptionString( $options, 'length', 'medium' ); $purpose_details = $this->getPurposeDetails( $purpose, $presets, $length ); $product_context_block = $this->buildProductContext( $term_context ); $has_product_context = ( '' !== trim( $product_context_block ) ) && false === strpos( $product_context_block, 'No sampled product context is available' ); $term_data_block = $this->buildTermDataBlock( $term_context ); $task_context_modifier = $has_product_context ? 'Use term metadata together with product context to produce an accurate description.' : 'Product context is empty. Rely on taxonomy metadata and existing term signals only.'; $system_prompt = PromptFormatter::cleanOutboundPrompt( $this->buildSystemPrompt( $tone, $language, $purpose, $purpose_details['rules'], $purpose_details['length_description'] ) ); $user_prompt = PromptFormatter::cleanOutboundPrompt( $term_data_block . "\n\n" . "\n" . $product_context_block . "\n\n\n" . "# Task\n" . $purpose_details['task'] . "\n" . $task_context_modifier ); /** * Filter the parts appended to the user prompt. The Premium build adds * the merchant's additional instructions here. * * @since 2.8.0 * @param string[] $extra_parts Prompt parts (none by default). * @param array $options Prompt options. */ $extra_parts = apply_filters( 'aipt_taxonomy_prompt_parts', array(), $options ); foreach ( is_array( $extra_parts ) ? $extra_parts : array() as $extra_part ) { if ( is_string( $extra_part ) && '' !== trim( $extra_part ) ) { $user_prompt .= "\n\n" . $extra_part; } } return array( 'system' => $system_prompt, 'user' => $user_prompt, ); } private function buildSystemPrompt( string $tone, string $language, string $purpose, string $purpose_rules, string $length_description ): string { return "# Identity You are an expert e-commerce content writer specializing in product category descriptions for WooCommerce stores. # Rules - Output ONLY valid HTML using

,