Generate a platform post from a summary/digest. Args: platform: 'twitter', 'instagram', 'reddit', 'linkedin', 'discord' summary: The summary or digest dict (must have 'arcs' and optionally 'pr_summary', 'pr_count') token: Pollinations API token preamble: The open
(
platform: str,
summary: Dict,
token: str,
preamble: str,
temperature: float = 0.7,
extra_context: str = "",
)
| 707 | |
| 708 | |
| 709 | def generate_platform_post( |
| 710 | platform: str, |
| 711 | summary: Dict, |
| 712 | token: str, |
| 713 | preamble: str, |
| 714 | temperature: float = 0.7, |
| 715 | extra_context: str = "", |
| 716 | ) -> Optional[Dict]: |
| 717 | """Generate a platform post from a summary/digest. |
| 718 | |
| 719 | Args: |
| 720 | platform: 'twitter', 'instagram', 'reddit', 'linkedin', 'discord' |
| 721 | summary: The summary or digest dict (must have 'arcs' and optionally 'pr_summary', 'pr_count') |
| 722 | token: Pollinations API token |
| 723 | preamble: The opening instruction line (e.g. "Write a tweet about today's shipped work.") |
| 724 | temperature: Generation temperature |
| 725 | extra_context: Additional context appended to the task prompt |
| 726 | |
| 727 | Returns: |
| 728 | Parsed JSON dict or None on failure |
| 729 | """ |
| 730 | voice = load_prompt(f"tone/{platform}") |
| 731 | pr_summary = summary.get("pr_summary", "") |
| 732 | arc_titles = str([a["headline"] for a in summary.get("arcs", [])]) |
| 733 | pr_count = summary.get("pr_count", 0) |
| 734 | |
| 735 | task = f"{preamble}\n\n{pr_summary}\n\nMost impactful updates: {arc_titles}" |
| 736 | if pr_count: |
| 737 | task += f"\nTotal PRs merged: {pr_count}" |
| 738 | task += "\n\n" + load_format(platform) |
| 739 | if extra_context: |
| 740 | task += extra_context |
| 741 | |
| 742 | response = call_pollinations_api(voice, task, token, temperature=temperature) |
| 743 | if not response: |
| 744 | return None |
| 745 | return parse_json_response(response) |
| 746 | |
| 747 | |
| 748 | def build_linkedin_post_text(post_data: Dict) -> str: |
no test coverage detected