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 | |
- Connect emotionally with the audience | |
- Address real desires, problems, and motivations | |
- Maintain natural and conversational language | |
CRITICAL OUTPUT RULES: | |
- Create 3 RADICALLY DIFFERENT versions of the offer, each with a unique approach, angle, and structure | |
- Each version MUST use different vocabulary, sentence structures, and emotional appeals | |
- Ensure NO repetition of key phrases or selling points between versions | |
- Number each version clearly as "VERSI脫N 1:", "VERSI脫N 2:", and "VERSI脫N 3:" | |
- Each version should be completely independent with different wording, focus, and benefits highlighted | |
- Output ONLY the offers themselves with NO introductory text, explanations, or additional commentary | |
- Start each version directly with its corresponding formula structure | |
- Do not include phrases like "Aqu铆 tienes una oferta convincente" or "Esta es tu oferta" | |
- Present all 3 versions one after another, clearly separated | |
""" | |
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 and sophistication_level == "Nivel 1: Primera promesa fuerte": | |
# Get basic sophistication guidance | |
base_sophistication_guidance = create_sophistication_instruction(sophistication_level) | |
# Add formula-specific guidance for Nivel 1 | |
formula_specific_guidance = f"\n\nFor this Level 1 market sophistication:\n- Make the hook educational or introduce the concept as new\n- Keep the promise direct, clear and impactful without comparisons\n- Focus on explaining what it is and how it works\n- Avoid complicated mechanisms or advanced explanations\n- Present the solution as if it's the first of its kind" | |
# Combine the base guidance with formula-specific guidance | |
instruction += f"\n\nMARKET SOPHISTICATION GUIDANCE:\n{base_sophistication_guidance}{formula_specific_guidance}\n\nEnsure the entire offer maintains consistency with this Level 1 sophistication while following the formula structure." | |
elif sophistication_level and sophistication_level == "Nivel 2: Competencia aparece con la misma promesa": | |
# Get basic sophistication guidance | |
base_sophistication_guidance = create_sophistication_instruction(sophistication_level) | |
# Add formula-specific guidance for Nivel 2 | |
formula_specific_guidance = f"\n\nFor this Level 2 market sophistication:\n- Make the hook acknowledge that the solution exists but position yours as better\n- Add quantitative or qualitative differentiators to your promise (faster, easier, cheaper, more effective)\n- Include specific numbers or percentages when possible to strengthen your claims\n- Compare your solution favorably to alternatives without naming competitors\n- Focus on what makes your solution stand out from others in the market" | |
# Combine the base guidance with formula-specific guidance | |
instruction += f"\n\nMARKET SOPHISTICATION GUIDANCE:\n{base_sophistication_guidance}{formula_specific_guidance}\n\nEnsure the entire offer maintains consistency with this Level 2 sophistication while following the formula structure." | |
elif sophistication_level and sophistication_level == "Nivel 3: Mercado saturado de la misma promesa": | |
# Get basic sophistication guidance | |
base_sophistication_guidance = create_sophistication_instruction(sophistication_level) | |
# Add formula-specific guidance for Nivel 3 | |
formula_specific_guidance = f"\n\nFor this Level 3 market sophistication:\n- Make the hook acknowledge market saturation and introduce a unique angle\n- Focus on a specific mechanism, method, or system that makes your solution different\n- Emphasize HOW your solution works, not just what it does\n- Introduce proprietary terminology or branded concepts\n- Present a new approach to solving the same problem\n- Highlight a unique feature or process that competitors don't have" | |
# Combine the base guidance with formula-specific guidance | |
instruction += f"\n\nMARKET SOPHISTICATION GUIDANCE:\n{base_sophistication_guidance}{formula_specific_guidance}\n\nEnsure the entire offer maintains consistency with this Level 3 sophistication while following the formula structure." | |
elif sophistication_level and sophistication_level == "Nivel 4: Mercado esc茅ptico y desconfiado": | |
# Get basic sophistication guidance | |
base_sophistication_guidance = create_sophistication_instruction(sophistication_level) | |
# Add formula-specific guidance for Nivel 4 | |
formula_specific_guidance = f"\n\nFor this Level 4 market sophistication:\n- Make the hook directly challenge established beliefs with a provocative tone\n- Include specific research, verifiable data, and concrete evidence\n- Reference exact numbers, studies, or expert endorsements\n- Address deep objections that a skeptical audience would have\n- Add elements of exclusivity or limited access\n- Use language that makes the customer feel part of a select group\n- Highlight tangible and diversified results in multiple areas\n- Provide guarantees backed by concrete evidence\n- Use a tone that encourages immediate action" | |
# Combine the base guidance with formula-specific guidance | |
instruction += f"\n\nMARKET SOPHISTICATION GUIDANCE:\n{base_sophistication_guidance}{formula_specific_guidance}\n\nEnsure the entire offer maintains consistency with this Level 4 sophistication while following the formula structure." | |
elif sophistication_level and sophistication_level == "Nivel 5: Mercado insensibilizado y hastiado": | |
# Get basic sophistication guidance | |
base_sophistication_guidance = create_sophistication_instruction(sophistication_level) | |
# Add formula-specific guidance for Nivel 5 | |
formula_specific_guidance = f"\n\nFor this Level 5 market sophistication:\n- Focus on emotional connection and values rather than product features\n- Convey a purpose or philosophy that resonates with the audience\n- Use storytelling that creates identity and belonging\n- Minimize direct selling or product mentions\n- Emphasize lifestyle and emotional experience\n- Use inspirational tone that transcends the product category\n- Focus on transformation of identity, not just results\n- Invite the audience to join a movement or philosophy\n- Use language that empowers and elevates the customer\n- Emphasize the journey and emotional transformation" | |
# Combine the base guidance with formula-specific guidance | |
instruction += f"\n\nMARKET SOPHISTICATION GUIDANCE:\n{base_sophistication_guidance}{formula_specific_guidance}\n\nEnsure the entire offer maintains consistency with this Level 5 sophistication while following the formula structure." | |
elif sophistication_level: | |
# Original code for other sophistication levels | |
# Get basic sophistication guidance | |
base_sophistication_guidance = create_sophistication_instruction(sophistication_level) | |
# Add formula-specific sophistication guidance | |
formula_specific_guidance = "" | |
# Apply conditional logic based on formula name | |
if selected_formula_name == "Oferta Dorada": | |
formula_specific_guidance = f"\n\nFor the Oferta Dorada formula specifically:\n- Gancho: Create a hook that matches {sophistication_level} awareness level. For higher sophistication, use more specific data or challenge established beliefs.\n- Promesa: Craft a promise that addresses the skepticism level of this market. For higher sophistication, focus on unique mechanisms or emotional transformation.\n- Beneficio con Autoridad: Provide proof elements appropriate for this sophistication level. For higher sophistication, include more specific data, studies, or transparent evidence." | |
elif selected_formula_name == "F贸rmula Sue帽o-Obst谩culo": | |
formula_specific_guidance = f"\n\nFor the F贸rmula Sue帽o-Obst谩culo specifically:\n- Type: Select a solution type that resonates with {sophistication_level} markets.\n- Dream: For higher sophistication levels, make the dream more specific and emotionally resonant rather than generic.\n- Obstacle: For higher sophistication, address more complex or specific obstacles that show deep understanding of the market's challenges." | |
# Add more conditionals for other formulas as they are added to the system | |
# Combine the base guidance with formula-specific guidance | |
instruction += f"\n\nMARKET SOPHISTICATION GUIDANCE:\n{base_sophistication_guidance}{formula_specific_guidance}\n\nEnsure the entire offer maintains consistency with this sophistication level while following the formula structure." | |
return instruction |