LinkedInPostGenerator / prompts.py
Alpha108's picture
Create prompts.py
9a6b821 verified
raw
history blame
2.42 kB
from typing import List, Optional
def build_post_prompt(topic: str,
language: str,
tone: str,
target_len: int,
purpose: str,
audience: str,
evidence: str,
keywords: List[str],
style_cues: List[str],
clarifier_notes: str,
chosen_hook: Optional[str]) -> str:
kw_block = ", ".join(keywords[:8]) if keywords else "N/A"
cues_block = "\n".join(f"- {c}" for c in style_cues[:4]) if style_cues else "- None"
hook_line = chosen_hook.strip() if chosen_hook else ""
return (
"You are a senior LinkedIn content strategist. "
"Write one viral, insightful LinkedIn post as plain text only (no section headers, no labels).\n\n"
f"Language: {language}\n"
f"Topic: \"{topic}\"\n"
f"Purpose: {purpose or 'awareness'}\n"
f"Audience: {audience or 'general professionals'}\n"
f"Tone: {tone}\n"
f"Approx length: ~{target_len} words\n"
f"Keywords to weave in naturally: {kw_block}\n"
"Style cues (apply silently):\n"
f"{cues_block}\n\n"
"User-provided detail (incorporate if relevant):\n"
f"{evidence or 'None'}\n\n"
"Additional notes from clarifier (apply silently):\n"
f"{(clarifier_notes or 'None').strip()}\n\n"
f"Preferred opening line (if provided): {hook_line or 'None'}\n\n"
"Rules (do not mention explicitly):\n"
"- Curiosity-driven first sentence.\n"
"- Short paragraphs; 3–5 concrete insights or examples.\n"
"- Max 2 emojis; 2–4 niche hashtags only at end (optional).\n"
"- No repeated sentences; avoid clichés.\n"
"- Return a single cohesive post in plain text only."
)
def transform_instruction(kind: str) -> str:
mapping = {
"shorter": "Shorten to ~120 words. Keep the opening intact. Plain text only.",
"punchier": "Make the opening more punchy and contrarian; keep length similar. Plain text only.",
"add_data": "Add one concrete metric or example supporting the main claim. Plain text only.",
"less_emoji": "Remove all emojis. Plain text only.",
"add_tags": "Append 2–4 niche hashtags at the end (new line). Plain text only."
}
return mapping[kind]