|
|
@@ -565,7 +565,7 @@ class GeminiAttributeService:
|
|
|
scores: Dict
|
|
|
) -> str:
|
|
|
"""Build comprehensive prompt for all quality aspects"""
|
|
|
-
|
|
|
+ print("_build_comprehensive_prompt",product,issues,rules,scores)
|
|
|
mandatory_attrs = [r['attribute_name'] for r in rules if r.get('is_mandatory')]
|
|
|
valid_values_map = {
|
|
|
r['attribute_name']: r.get('valid_values', [])[:5]
|
|
|
@@ -581,70 +581,70 @@ class GeminiAttributeService:
|
|
|
import random
|
|
|
|
|
|
a = random.uniform(90.2,95.9)
|
|
|
-
|
|
|
+ print("prompt start")
|
|
|
prompt = f"""Analyze this e-commerce product and provide comprehensive quality improvements.
|
|
|
|
|
|
Note: quality_score_prediction should be in range of 90 to 95
|
|
|
|
|
|
-PRODUCT DATA:
|
|
|
-SKU: {product.get('sku')}
|
|
|
-Category: {product.get('category')}
|
|
|
-Title: {product.get('title', '')[:250]}
|
|
|
-Description: {product.get('description', '')[:400]}
|
|
|
-Attributes: {json.dumps(product.get('attributes', {}), ensure_ascii=False)}
|
|
|
-
|
|
|
-QUALITY SCORES (out of 100):
|
|
|
-- Mandatory Fields: {scores.get('mandatory_fields', 0):.1f}
|
|
|
-- Standardization: {scores.get('standardization', 0):.1f}
|
|
|
-- Missing Values: {scores.get('missing_values', 0):.1f}
|
|
|
-- Consistency: {scores.get('consistency', 0):.1f}
|
|
|
-- SEO: {scores.get('seo_discoverability', 0):.1f}
|
|
|
-- Title Quality: {scores.get('title_quality', 0):.1f}
|
|
|
-- Description Quality: {scores.get('description_quality', 0):.1f}
|
|
|
-
|
|
|
-CATEGORY RULES:
|
|
|
-Mandatory Attributes: {', '.join(mandatory_attrs)}
|
|
|
-Valid Values: {json.dumps(valid_values_map, ensure_ascii=False)}
|
|
|
-
|
|
|
-ISSUES FOUND:
|
|
|
-Attributes ({len(attribute_issues)}):
|
|
|
-{chr(10).join(f" • {i}" for i in attribute_issues[:8])}
|
|
|
-
|
|
|
-Title ({len(title_issues)}):
|
|
|
-{chr(10).join(f" • {i}" for i in title_issues[:5])}
|
|
|
-
|
|
|
-Description ({len(desc_issues)}):
|
|
|
-{chr(10).join(f" • {i}" for i in desc_issues[:5])}
|
|
|
-
|
|
|
-SEO ({len(seo_issues)}):
|
|
|
-{chr(10).join(f" • {i}" for i in seo_issues[:5])}
|
|
|
-
|
|
|
-Return ONLY this JSON structure:
|
|
|
-{{
|
|
|
- "corrected_attributes": {{
|
|
|
- "attr_name": "corrected_value"
|
|
|
- }},
|
|
|
- "missing_attributes": {{
|
|
|
- "attr_name": "suggested_value"
|
|
|
- }},
|
|
|
- "improved_title": "optimized title (50-100 chars, includes brand, model, key features)",
|
|
|
- "improved_description": "enhanced description (50-150 words, features, benefits, specs, use cases)",
|
|
|
- "seo_keywords": ["keyword1", "keyword2", "keyword3"],
|
|
|
- "improvements": [
|
|
|
- {{
|
|
|
- "component": "attributes/title/description/seo",
|
|
|
- "issue": "specific issue",
|
|
|
- "suggestion": "how to fix",
|
|
|
- "priority": "high/medium/low",
|
|
|
- "confidence": "high/medium/low"
|
|
|
- }}
|
|
|
- ],
|
|
|
- "quality_score_prediction": {a:.1f},
|
|
|
- "summary": "Brief 2-3 sentence summary of key improvements needed"
|
|
|
-}}
|
|
|
-
|
|
|
-CRITICAL: Keep response under 7000 tokens. Focus on top 5 most impactful improvements."""
|
|
|
-
|
|
|
+ PRODUCT DATA:
|
|
|
+ SKU: {product.get('sku')}
|
|
|
+ Category: {product.get('category')}
|
|
|
+ Title: {product.get('title', '')[:250]}
|
|
|
+ Description: {product.get('description', '')[:400]}
|
|
|
+ Attributes: {json.dumps(product.get('attributes', {}), ensure_ascii=False)}
|
|
|
+
|
|
|
+ QUALITY SCORES (out of 100):
|
|
|
+ - Mandatory Fields: {scores.get('mandatory_fields', 0):.1f}
|
|
|
+ - Standardization: {scores.get('standardization', 0):.1f}
|
|
|
+ - Missing Values: {scores.get('missing_values', 0):.1f}
|
|
|
+ - Consistency: {scores.get('consistency', 0):.1f}
|
|
|
+ - SEO: {scores.get('seo_discoverability', 0):.1f}
|
|
|
+ - Title Quality: {scores.get('title_quality', 0):.1f}
|
|
|
+ - Description Quality: {scores.get('description_quality', 0):.1f}
|
|
|
+
|
|
|
+ CATEGORY RULES:
|
|
|
+ Mandatory Attributes: {', '.join(mandatory_attrs)}
|
|
|
+ Valid Values: {json.dumps(valid_values_map, ensure_ascii=False)}
|
|
|
+
|
|
|
+ ISSUES FOUND:
|
|
|
+ Attributes ({len(attribute_issues)}):
|
|
|
+ {chr(10).join(f" • {i}" for i in attribute_issues[:8])}
|
|
|
+
|
|
|
+ Title ({len(title_issues)}):
|
|
|
+ {chr(10).join(f" • {i}" for i in title_issues[:5])}
|
|
|
+
|
|
|
+ Description ({len(desc_issues)}):
|
|
|
+ {chr(10).join(f" • {i}" for i in desc_issues[:5])}
|
|
|
+
|
|
|
+ SEO ({len(seo_issues)}):
|
|
|
+ {chr(10).join(f" • {i}" for i in seo_issues[:5])}
|
|
|
+
|
|
|
+ Return ONLY this JSON structure:
|
|
|
+ {{
|
|
|
+ "corrected_attributes": {{
|
|
|
+ "attr_name": "corrected_value"
|
|
|
+ }},
|
|
|
+ "missing_attributes": {{
|
|
|
+ "attr_name": "suggested_value"
|
|
|
+ }},
|
|
|
+ "improved_title": "optimized title (50-100 chars, includes brand, model, key features)",
|
|
|
+ "improved_description": "enhanced description (50-150 words, features, benefits, specs, use cases)",
|
|
|
+ "seo_keywords": ["keyword1", "keyword2", "keyword3"],
|
|
|
+ "improvements": [
|
|
|
+ {{
|
|
|
+ "component": "attributes/title/description/seo",
|
|
|
+ "issue": "specific issue",
|
|
|
+ "suggestion": "how to fix",
|
|
|
+ "priority": "high/medium/low",
|
|
|
+ "confidence": "high/medium/low"
|
|
|
+ }}
|
|
|
+ ],
|
|
|
+ "quality_score_prediction": {a:.1f},
|
|
|
+ "summary": "Brief 2-3 sentence summary of key improvements needed"
|
|
|
+ }}
|
|
|
+
|
|
|
+ CRITICAL: Keep response under 7000 tokens. Focus on top 5 most impactful improvements."""
|
|
|
+ print("prompt",prompt)
|
|
|
return prompt
|
|
|
|
|
|
def _parse_response(self, response_text: str) -> Dict:
|