key_word_Fast_API / services /linkedin_analyzer.py
ihtesham0345's picture
feat: Add LinkedIn API posting + enhanced analyzer + schema
639b959
Raw
History Blame Contribute Delete
1.76 kB
from services.utils import run_analysis
SYSTEM_PROMPT = """You are a LinkedIn content strategist. Return ONLY a valid JSON object (not an array). Create high-engagement LinkedIn posts with industry insights."""
DEFAULTS = {
"post_drafts": [
{"headline": "Key Insights on This Topic", "body": "Here are my thoughts on this important subject. It's changing how we approach problems in 2026.", "hook": "Stop scrolling if you care about this", "post_type": "text", "call_to_action": "Share your thoughts below", "media_suggestion": "Infographic with key stats"}
],
"hashtags": ["#industry", "#leadership"],
"article_topics": ["The Future of This Industry"],
"thought_leadership_angles": ["Unique perspective on current trends"],
"engagement_prompts": ["What has your experience been with this topic?"],
"target_audience_tags": ["#TechLeaders", "#IndustryPros"],
"best_posting_time": "7-9 AM EST Tue-Thu",
"industry_insights": "This is a growing space with significant potential."
}
def analyze_linkedin(content: str) -> dict:
messages = [
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": f'Topic: "{content[:1000]}"\nReturn a JSON object (not an array) with these keys:\n- post_drafts (2 items, each with "headline" + "body" + "hook" + "post_type" ["text"|"article"|"poll"] + "call_to_action" + "media_suggestion")\n- hashtags (4 items)\n- article_topics (2 items)\n- thought_leadership_angles (2 items)\n- engagement_prompts (2 items, questions to spark discussion)\n- target_audience_tags (2 items, industry tags)\n- best_posting_time (string)\n- industry_insights (string)'}
]
return run_analysis(messages, defaults=DEFAULTS, temperature=0.35, max_new_tokens=1000)