Commit
·
c9d2117
1
Parent(s):
9a399eb
feat(strategist): Mock campaign brief generation for reliability
Browse files- core/strategist.py +33 -51
core/strategist.py
CHANGED
|
@@ -23,64 +23,46 @@ class AIStrategist:
|
|
| 23 |
|
| 24 |
def generate_campaign_brief(self, brand_name: str, campaign_goal: str, target_audience: str, budget_range: str) -> Dict[str, Any]:
|
| 25 |
"""
|
| 26 |
-
Generates a
|
|
|
|
| 27 |
"""
|
| 28 |
-
print(f"--- Strategist Skill: Generating campaign brief for brand '{brand_name}'.")
|
| 29 |
-
|
| 30 |
-
prompt = f"""
|
| 31 |
-
[SYSTEM]
|
| 32 |
-
You are an expert campaign strategist. Your task is to generate a creative and actionable campaign brief in a valid JSON object format. Do not add any text before or after the JSON object.
|
| 33 |
-
|
| 34 |
-
[CLIENT INPUT]
|
| 35 |
-
- Brand Name: {brand_name}
|
| 36 |
-
- Primary Goal: {campaign_goal}
|
| 37 |
-
- Target Audience: {target_audience}
|
| 38 |
-
- Budget: {budget_range}
|
| 39 |
-
|
| 40 |
-
[YOUR TASK]
|
| 41 |
-
Generate a JSON object with keys: "title", "description", "goal_kpi", and "content_guidelines" (as a list of strings).
|
| 42 |
-
- "title": A short, catchy campaign title.
|
| 43 |
-
- "description": A one-paragraph summary of the campaign's core idea.
|
| 44 |
-
- "goal_kpi": The single most important Key Performance Indicator (KPI) for this goal.
|
| 45 |
-
- "content_guidelines": A list of 3 creative content ideas for influencers.
|
| 46 |
-
|
| 47 |
-
[JSON OUTPUT]
|
| 48 |
-
"""
|
| 49 |
try:
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
if
|
| 59 |
-
|
| 60 |
-
elif
|
| 61 |
-
|
| 62 |
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
|
|
|
| 74 |
return json_response
|
| 75 |
|
| 76 |
-
except (json.JSONDecodeError, KeyError) as e:
|
| 77 |
-
response_content = locals().get('raw_text', 'No raw text available')
|
| 78 |
-
print(f"--- Strategist Skill FATAL ERROR: Failed to decode/parse JSON from model. Error: {e}. Raw output: '{response_content}'")
|
| 79 |
-
return {"error": "The AI model returned an invalid format. Please try again."}
|
| 80 |
except Exception as e:
|
| 81 |
-
print(f"--- Strategist Skill
|
| 82 |
-
|
| 83 |
-
return {"error": "An internal error occurred in the AI model."}
|
| 84 |
|
| 85 |
def generate_strategy_from_prompt(self, user_prompt: str) -> str:
|
| 86 |
"""
|
|
|
|
| 23 |
|
| 24 |
def generate_campaign_brief(self, brand_name: str, campaign_goal: str, target_audience: str, budget_range: str) -> Dict[str, Any]:
|
| 25 |
"""
|
| 26 |
+
[MOCK MODE] Generates a reliable, high-quality campaign brief.
|
| 27 |
+
Bypasses the unreliable small LLM to ensure a professional UI experience.
|
| 28 |
"""
|
| 29 |
+
print(f"--- Strategist Skill (MOCK MODE): Generating static campaign brief for brand '{brand_name}'.")
|
| 30 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
try:
|
| 32 |
+
# Create a dynamic but predictable title
|
| 33 |
+
title = f"{brand_name}'s {campaign_goal.split(' ')[-1].capitalize()} Campaign"
|
| 34 |
+
|
| 35 |
+
# Create a description based on the goal
|
| 36 |
+
description = f"A targeted campaign to {campaign_goal.lower()}, aimed at {target_audience}. The focus will be on authentic, engaging content that resonates with the core demographic."
|
| 37 |
+
|
| 38 |
+
# Determine a simple KPI
|
| 39 |
+
goal_kpi = "Engagement Rate"
|
| 40 |
+
if "sales" in campaign_goal.lower() or "conversions" in campaign_goal.lower():
|
| 41 |
+
goal_kpi = "Conversion Rate"
|
| 42 |
+
elif "awareness" in campaign_goal.lower() or "reach" in campaign_goal.lower():
|
| 43 |
+
goal_kpi = "Total Reach & Impressions"
|
| 44 |
|
| 45 |
+
# Static but high-quality content ideas
|
| 46 |
+
content_guidelines = [
|
| 47 |
+
f"Create a short-form video (e.g., Reel/TikTok) showcasing the product in a real-life scenario.",
|
| 48 |
+
f"Publish an authentic photo carousel with a caption that tells a personal story related to the product.",
|
| 49 |
+
f"Engage with the community by running an interactive poll or Q&A in Stories."
|
| 50 |
+
]
|
| 51 |
+
|
| 52 |
+
# Construct the final JSON object
|
| 53 |
+
json_response = {
|
| 54 |
+
"title": title,
|
| 55 |
+
"description": description,
|
| 56 |
+
"goal_kpi": goal_kpi,
|
| 57 |
+
"content_guidelines": content_guidelines
|
| 58 |
+
}
|
| 59 |
|
| 60 |
+
print("--- Strategist Skill (MOCK MODE): Successfully generated static brief.")
|
| 61 |
return json_response
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
except Exception as e:
|
| 64 |
+
print(f"--- Strategist Skill MOCK ERROR: {e}")
|
| 65 |
+
return {"error": "An internal error occurred in the mock data generator."}
|
|
|
|
| 66 |
|
| 67 |
def generate_strategy_from_prompt(self, user_prompt: str) -> str:
|
| 68 |
"""
|