Spaces:
Sleeping
Sleeping
| from formulas import offer_formulas | |
| from sophistication.generator import create_sophistication_instruction | |
| offer_system_prompt = """You are a world-class expert copywriter, experienced in creating compelling offers that connect emotionally with the target audience. | |
| OBJECTIVE: | |
| - Generate 3 COMPLETELY DIFFERENT versions of a convincing offer in Spanish | |
| - Each version must be CLEAR, CONCISE and FOCUSED on a SINGLE transformation | |
| - Connect emotionally with the audience's core desire | |
| - Use natural and conversational language | |
| CRITICAL OUTPUT RULES: | |
| - Create 3 DISTINCT versions with different angles and emotional appeals | |
| - Each version must focus on ONE problem/vision, ONE transformation, and ONE proof element | |
| - Number each version clearly as "VERSI脫N 1:", "VERSI脫N 2:", and "VERSI脫N 3:" | |
| - Output ONLY the offers themselves with NO explanations or commentary | |
| - Start each version directly with its corresponding formula structure | |
| - Present all 3 versions one after another, clearly separated | |
| FORMULA-SPECIFIC FOCUS: | |
| 1. Oferta Dorada: ONE specific problem, ONE clear transformation, ONE proof element | |
| 2. Contraste Revelador: ONE inspiring vision, ONE transformative solution, ONE emotional result | |
| 3. Propuesta 脷nica de Valor: ONE powerful transformation, ONE emotional objection handler | |
| """ | |
| def create_offer_instruction(target_audience=None, product_service=None, selected_formula_name=None, file_content=None, skills=None, sophistication_level=None): | |
| """ | |
| Creates the instruction for generating an offer based on the selected formula. | |
| Args: | |
| target_audience: Description of the target audience | |
| product_service: Product/service information | |
| selected_formula_name: Name of the selected formula | |
| file_content: Content from uploaded files (if any) | |
| skills: User's skills and expertise | |
| sophistication_level: String key for the market sophistication level | |
| Returns: | |
| str: The complete instruction for generating the offer | |
| """ | |
| # Get the selected formula | |
| selected_formula = offer_formulas[selected_formula_name] | |
| # Get formula-specific instructions (fixed the get method usage) | |
| additional_instructions = selected_formula.get("instructions", "") | |
| # Create the base instruction | |
| instruction = f"""{offer_system_prompt} | |
| FORMULA TO USE: | |
| {selected_formula["description"]} | |
| {additional_instructions} | |
| PRODUCT/SERVICE: | |
| {product_service} | |
| TARGET AUDIENCE: | |
| {target_audience} | |
| ADDITIONAL INFORMATION: | |
| {file_content} | |
| Create a compelling offer following the formula structure exactly, adapting it to the sophistication level provided. | |
| """ | |
| # Add examples if available | |
| if selected_formula.get("sophistication_examples") and sophistication_level: | |
| # Extract the sophistication level key (e.g., "nivel_1", "nivel_2", etc.) | |
| sophistication_key = sophistication_level.split(":")[0].lower().replace(" ", "_") | |
| # Map to the correct key format used in the examples | |
| if "nivel" not in sophistication_key: | |
| sophistication_key = f"nivel_{sophistication_key[0]}" | |
| # Get all examples for the specific sophistication level | |
| examples = [] | |
| for key, example in selected_formula["sophistication_examples"].items(): | |
| # Check if the key starts with the sophistication level (to include nivel_1, nivel_1_ejemplo2, etc.) | |
| if key.startswith(sophistication_key): | |
| examples.append(example) | |
| # Format all examples based on the formula type | |
| if examples: | |
| instruction += "\n\n### EXAMPLES FOR YOUR REFERENCE:\n" | |
| for i, example in enumerate(examples): | |
| instruction += f"\n#### Example {i+1}:\n" | |
| # Format based on formula type | |
| if selected_formula_name == "Oferta Dorada": | |
| instruction += f"Headline: {example.get('headline', '')}\n" | |
| instruction += f"Promise: {example.get('promise', '')}\n" | |
| instruction += f"Subtitle: {example.get('subtitle', '')}\n" | |
| elif selected_formula_name == "Contraste Revelador": | |
| instruction += f"Situaci贸n: {example.get('situacion', '')}\n" | |
| instruction += f"Soluci贸n: {example.get('solucion', '')}\n" | |
| instruction += f"Resultado: {example.get('resultado', '')}\n" | |
| elif selected_formula_name == "Propuesta 脷nica de Valor": | |
| instruction += f"Transformaci贸n: {example.get('transformacion', '')}\n" | |
| instruction += f"Objeciones: {example.get('objeciones', '')}\n" | |
| # Add more formula types as needed | |
| # Original code for general examples (keep as fallback) | |
| elif selected_formula.get("examples") and len(selected_formula["examples"]) > 0: | |
| examples_text = "\n\n".join([f"Example {i+1}:\n{example}" for i, example in enumerate(selected_formula["examples"])]) | |
| instruction += f"\n\nGet inspired by these examples:\n{examples_text}" | |
| # Add sophistication level guidance using the dedicated function | |
| if sophistication_level: | |
| # Get basic sophistication guidance | |
| base_sophistication_guidance = create_sophistication_instruction(sophistication_level) | |
| # Create concise formula-specific guidance based on sophistication level | |
| formula_specific_guidance = "" | |
| level_num = sophistication_level.split(":")[0].replace("Nivel ", "") | |
| if selected_formula_name == "Oferta Dorada": | |
| formula_specific_guidance = f""" | |
| For Oferta Dorada (Nivel {level_num}): | |
| - Headline: {get_headline_guidance(level_num)} | |
| - Promise: {get_promise_guidance(level_num)} | |
| - Subtitle: {get_subtitle_guidance(level_num)}""" | |
| elif selected_formula_name == "Contraste Revelador": | |
| formula_specific_guidance = f""" | |
| For Contraste Revelador (Nivel {level_num}): | |
| - Visi贸n: {get_vision_guidance(level_num)} | |
| - Soluci贸n: {get_solution_guidance(level_num)} | |
| - Resultado: {get_result_guidance(level_num)}""" | |
| elif selected_formula_name == "Propuesta 脷nica de Valor": | |
| formula_specific_guidance = f""" | |
| For Propuesta 脷nica de Valor (Nivel {level_num}): | |
| - Transformaci贸n: {get_transformation_guidance(level_num)} | |
| - Objeciones: {get_objection_guidance(level_num)}""" | |
| # Add the concise guidance to the instruction | |
| instruction += f"\n\nSOPHISTICATION GUIDANCE (NIVEL {level_num}):{formula_specific_guidance}" | |
| return instruction | |
| # Helper functions for concise sophistication guidance | |
| def get_headline_guidance(level): | |
| guidance = { | |
| "1": "Educational, introduce the concept as new", | |
| "2": "Differentiate from competitors, add specific benefits", | |
| "3": "Highlight unique mechanism or approach", | |
| "4": "Use data, research or challenge beliefs", | |
| "5": "Focus on identity and emotional transformation" | |
| } | |
| return guidance.get(level, "Match market awareness level") | |
| def get_promise_guidance(level): | |
| guidance = { | |
| "1": "Direct and clear benefit without comparisons", | |
| "2": "Quantified benefit with specific advantage", | |
| "3": "Unique mechanism or proprietary method", | |
| "4": "Evidence-backed transformation with specifics", | |
| "5": "Identity shift and deeper meaning beyond results" | |
| } | |
| return guidance.get(level, "Focus on transformation") | |
| def get_subtitle_guidance(level): | |
| guidance = { | |
| "1": "Simple proof with basic numbers", | |
| "2": "Comparative results with timeframes", | |
| "3": "Specific mechanism results with details", | |
| "4": "Research-backed evidence and guarantees", | |
| "5": "Community and movement-based validation" | |
| } | |
| return guidance.get(level, "Provide appropriate proof") | |
| def get_vision_guidance(level): | |
| guidance = { | |
| "1": "Simple, aspirational future state", | |
| "2": "Specific vision with clear advantages", | |
| "3": "Unique approach to achieving desires", | |
| "4": "Evidence-based optimal state", | |
| "5": "Transcendent vision beyond conventional goals" | |
| } | |
| return guidance.get(level, "Create inspiring vision") | |
| def get_solution_guidance(level): | |
| guidance = { | |
| "1": "Clear, straightforward solution", | |
| "2": "Solution with specific advantages", | |
| "3": "Unique mechanism or proprietary method", | |
| "4": "Validated solution with research backing", | |
| "5": "Paradigm-shifting approach" | |
| } | |
| return guidance.get(level, "Offer transformative solution") | |
| def get_result_guidance(level): | |
| guidance = { | |
| "1": "Simple emotional outcome with basic proof", | |
| "2": "Specific results with comparative advantages", | |
| "3": "Detailed outcomes from unique approach", | |
| "4": "Evidence-backed results with specifics", | |
| "5": "Identity-level transformation stories" | |
| } | |
| return guidance.get(level, "Show emotional transformation") | |
| def get_transformation_guidance(level): | |
| guidance = { | |
| "1": "Clear, direct transformation", | |
| "2": "Specific, quantified transformation", | |
| "3": "Unique mechanism transformation", | |
| "4": "Evidence-backed, validated transformation", | |
| "5": "Identity-level, paradigm-shifting transformation" | |
| } | |
| return guidance.get(level, "Focus on key transformation") | |
| def get_objection_guidance(level): | |
| guidance = { | |
| "1": "Address basic concerns simply", | |
| "2": "Counter specific objections with advantages", | |
| "3": "Handle objections with unique approach", | |
| "4": "Evidence-based objection handling", | |
| "5": "Transform objections into strengths" | |
| } | |
| return guidance.get(level, "Handle emotional objections") |