fix: Optimize Outreach - Generate Top 1 initially, list others for on-demand generation to prevent timeouts
This commit is contained in:
@@ -552,11 +552,11 @@ def generate_outreach_campaign(company_data_json, knowledge_base_content, refere
|
||||
logger.info(f"--- STARTING OUTREACH GENERATION FOR: {company_name} (Role: {specific_role if specific_role else 'Top 5'}) ---")
|
||||
|
||||
api_key = load_gemini_api_key()
|
||||
# Switch to stable, super-fast gemini-1.5-flash to prevent timeouts
|
||||
GEMINI_API_URL = f"https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key={api_key}"
|
||||
# Back to high-quality 2.5-pro, but generating only 1 campaign to be fast
|
||||
GEMINI_API_URL = f"https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-pro:generateContent?key={api_key}"
|
||||
|
||||
if specific_role:
|
||||
# --- MODE B: SINGLE ROLE GENERATION ---
|
||||
# --- MODE B: SINGLE ROLE GENERATION (On Demand) ---
|
||||
task_description = f"""
|
||||
--- TASK ---
|
||||
1. **Focus**: Create a highly specific 3-step email campaign ONLY for the role: '{specific_role}'.
|
||||
@@ -572,14 +572,15 @@ def generate_outreach_campaign(company_data_json, knowledge_base_content, refere
|
||||
}
|
||||
"""
|
||||
else:
|
||||
# --- MODE A: INITIAL BATCH (TOP 5 + SUGGESTIONS) ---
|
||||
# --- MODE A: INITIAL START (TOP 1 + SUGGESTIONS) ---
|
||||
# We only generate 1 campaign to ensure the request finishes quickly (< 20s).
|
||||
task_description = f"""
|
||||
--- TASK ---
|
||||
1. **Analyze**: Match the Target Company (Input 2) to the most relevant 'Zielbranche/Segment' from the Knowledge Base (Input 1).
|
||||
2. **Identify Roles**: Identify ALL relevant 'Rollen' (Personas) from the Knowledge Base that fit this company.
|
||||
3. **Select Top 5**: Choose the 5 most promising roles for immediate outreach based on the Audit findings.
|
||||
4. **Draft Campaigns**: For EACH of the Top 5 roles, write a 3-step email sequence.
|
||||
5. **List Others**: List the names of the other relevant roles that you identified but did NOT generate campaigns for yet.
|
||||
3. **Select Best**: Choose the SINGLE most promising role for immediate outreach based on the Audit findings.
|
||||
4. **Draft Campaign**: Write a 3-step email sequence for this ONE role.
|
||||
5. **List Others**: List ALL other relevant roles (including the other top candidates) in 'available_roles' so the user can generate them later.
|
||||
"""
|
||||
output_format = """
|
||||
--- OUTPUT FORMAT (Strictly JSON) ---
|
||||
@@ -589,10 +590,9 @@ def generate_outreach_campaign(company_data_json, knowledge_base_content, refere
|
||||
"target_role": "Role Name",
|
||||
"rationale": "Why selected...",
|
||||
"emails": [ ... ]
|
||||
},
|
||||
... (Top 5)
|
||||
}
|
||||
],
|
||||
"available_roles": [ "Role 6", "Role 7", ... ]
|
||||
"available_roles": [ "Role 2", "Role 3", "Role 4", "Role 5", ... ]
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user