Spaces:
Sleeping
Sleeping
| from services.utils import run_analysis | |
| SYSTEM_PROMPT = """You are a Twitter/X content strategist. Return ONLY a valid JSON object (not an array).""" | |
| DEFAULTS = { | |
| "tweet_threads": [{"tweets": ["Tweet 1 about the topic", "Tweet 2 with more detail", "Tweet 3 with key insight"], "theme": "educational"}], | |
| "viral_hooks": ["This changes everything"], | |
| "hashtags": ["#topic"], | |
| "best_posting_time": "7-9 AM EST weekdays", | |
| "engagement_tactics": ["Reply to industry leaders", "Use polls"] | |
| } | |
| def analyze_twitter(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- tweet_threads (1 item, with "tweets" (3 items) + "theme")\n- viral_hooks (3 items, under 280 chars)\n- hashtags (2 items)\n- best_posting_time (string)\n- engagement_tactics (2 items)'} | |
| ] | |
| return run_analysis(messages, defaults=DEFAULTS, temperature=0.35, max_new_tokens=800) | |