update cta hooks
This commit is contained in:
+25
-12
@@ -28,14 +28,34 @@ def get_dynamic_hook(article_title):
|
||||
except Exception as e:
|
||||
logging.error(f"Dynamic hook generation failed: {e}")
|
||||
return "This food scoop will blow your mind!"
|
||||
|
||||
def get_viral_share_prompt(article_title, content):
|
||||
try:
|
||||
prompt = (
|
||||
"Generate a short, viral share prompt (under 40 characters) to encourage sharing a food-related article on social media. "
|
||||
"Make it bold, quirky, and engaging with a Buzzfeed/Upworthy flair (e.g., 'Obsessed? Share Now'). "
|
||||
"Avoid clichés like 'game-changer' and words like 'elevate'. "
|
||||
"Do not include emojis, the platform name (e.g., Twitter, Facebook), or any HTML. "
|
||||
"Return only the prompt text."
|
||||
)
|
||||
response = client.chat.completions.create(
|
||||
model=LIGHT_TASK_MODEL,
|
||||
messages=[
|
||||
{"role": "system", "content": prompt},
|
||||
{"role": "user", "content": f"Title: {article_title}\nContent: {content}"}
|
||||
],
|
||||
max_tokens=20,
|
||||
temperature=0.9 # Higher temperature for more creativity
|
||||
)
|
||||
share_prompt = response.choices[0].message.content.strip()
|
||||
logging.info(f"Generated viral share prompt: {share_prompt}")
|
||||
return share_prompt
|
||||
except Exception as e:
|
||||
logging.error(f"Viral share prompt generation failed: {e}")
|
||||
return "Love This? Share It"
|
||||
|
||||
def select_best_cta(title, content, post_url=None):
|
||||
cta_templates = [
|
||||
# Share-focused CTAs
|
||||
"Cant Get Enough Share This Now On <a href='https://x.com/intent/tweet?url={url}&text={text}'><i class='tsi tsi-twitter'></i></a>",
|
||||
"This Blew Your Mind Right Tweet It On <a href='https://x.com/intent/tweet?url={url}&text={text}'><i class='tsi tsi-twitter'></i></a>",
|
||||
"Ready to Spill the Tea Share On <a href='https://x.com/intent/tweet?url={url}&text={text}'><i class='tsi tsi-twitter'></i></a>",
|
||||
"Too Wild to Keep Quiet Post It On <a href='https://x.com/intent/tweet?url={url}&text={text}'><i class='tsi tsi-twitter'></i></a>",
|
||||
# Like-focused CTAs
|
||||
"Love This Foodie Find Hit That Like Button",
|
||||
"Think This Dish Is a Game Changer Show Some Love With a Like",
|
||||
@@ -44,12 +64,5 @@ def select_best_cta(title, content, post_url=None):
|
||||
"Dont Miss Out on Foodie Updates Follow Us Today"
|
||||
]
|
||||
|
||||
hook = get_dynamic_hook(title).strip()
|
||||
hook = urllib.parse.quote(hook)
|
||||
url = post_url if post_url else "https://insiderfoodie.com/placeholder"
|
||||
url = urllib.parse.quote(url)
|
||||
|
||||
cta = random.choice(cta_templates)
|
||||
if "https://x.com/intent/tweet" in cta:
|
||||
cta = cta.format(url=url, text=hook)
|
||||
return cta
|
||||
Reference in New Issue
Block a user