Spaces:
Sleeping
Sleeping
Create prompts.py
Browse files- prompts.py +51 -0
prompts.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import List, Optional
|
| 2 |
+
|
| 3 |
+
def build_post_prompt(topic: str,
|
| 4 |
+
language: str,
|
| 5 |
+
tone: str,
|
| 6 |
+
target_len: int,
|
| 7 |
+
purpose: str,
|
| 8 |
+
audience: str,
|
| 9 |
+
evidence: str,
|
| 10 |
+
keywords: List[str],
|
| 11 |
+
style_cues: List[str],
|
| 12 |
+
clarifier_notes: str,
|
| 13 |
+
chosen_hook: Optional[str]) -> str:
|
| 14 |
+
kw_block = ", ".join(keywords[:8]) if keywords else "N/A"
|
| 15 |
+
cues_block = "\n".join(f"- {c}" for c in style_cues[:4]) if style_cues else "- None"
|
| 16 |
+
hook_line = chosen_hook.strip() if chosen_hook else ""
|
| 17 |
+
|
| 18 |
+
return (
|
| 19 |
+
"You are a senior LinkedIn content strategist. "
|
| 20 |
+
"Write one viral, insightful LinkedIn post as plain text only (no section headers, no labels).\n\n"
|
| 21 |
+
f"Language: {language}\n"
|
| 22 |
+
f"Topic: \"{topic}\"\n"
|
| 23 |
+
f"Purpose: {purpose or 'awareness'}\n"
|
| 24 |
+
f"Audience: {audience or 'general professionals'}\n"
|
| 25 |
+
f"Tone: {tone}\n"
|
| 26 |
+
f"Approx length: ~{target_len} words\n"
|
| 27 |
+
f"Keywords to weave in naturally: {kw_block}\n"
|
| 28 |
+
"Style cues (apply silently):\n"
|
| 29 |
+
f"{cues_block}\n\n"
|
| 30 |
+
"User-provided detail (incorporate if relevant):\n"
|
| 31 |
+
f"{evidence or 'None'}\n\n"
|
| 32 |
+
"Additional notes from clarifier (apply silently):\n"
|
| 33 |
+
f"{(clarifier_notes or 'None').strip()}\n\n"
|
| 34 |
+
f"Preferred opening line (if provided): {hook_line or 'None'}\n\n"
|
| 35 |
+
"Rules (do not mention explicitly):\n"
|
| 36 |
+
"- Curiosity-driven first sentence.\n"
|
| 37 |
+
"- Short paragraphs; 3–5 concrete insights or examples.\n"
|
| 38 |
+
"- Max 2 emojis; 2–4 niche hashtags only at end (optional).\n"
|
| 39 |
+
"- No repeated sentences; avoid clichés.\n"
|
| 40 |
+
"- Return a single cohesive post in plain text only."
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
def transform_instruction(kind: str) -> str:
|
| 44 |
+
mapping = {
|
| 45 |
+
"shorter": "Shorten to ~120 words. Keep the opening intact. Plain text only.",
|
| 46 |
+
"punchier": "Make the opening more punchy and contrarian; keep length similar. Plain text only.",
|
| 47 |
+
"add_data": "Add one concrete metric or example supporting the main claim. Plain text only.",
|
| 48 |
+
"less_emoji": "Remove all emojis. Plain text only.",
|
| 49 |
+
"add_tags": "Append 2–4 niche hashtags at the end (new line). Plain text only."
|
| 50 |
+
}
|
| 51 |
+
return mapping[kind]
|