MCPcopy Create free account
hub / github.com/pollinations/pollinations / generate_platform_post

Function generate_platform_post

social/scripts/common.py:709–745  ·  view source on GitHub ↗

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 = "",
)

Source from the content-addressed store, hash-verified

707
708
709def 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
748def build_linkedin_post_text(post_data: Dict) -> str:

Callers 7

generate_twitter_postFunction · 0.90
generate_linkedin_postFunction · 0.90
generate_instagram_postFunction · 0.90
generate_reddit_postFunction · 0.90
generate_twitter_postFunction · 0.90
generate_instagram_postFunction · 0.90
generate_reddit_postFunction · 0.90

Calls 5

load_promptFunction · 0.85
load_formatFunction · 0.85
call_pollinations_apiFunction · 0.85
parse_json_responseFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected