from services.utils import run_analysis SYSTEM_PROMPT = """You are a YouTube SEO expert. Return ONLY a valid JSON object (not an array).""" DEFAULTS = { "video_titles": [{"title": "Topic Deep Dive: Complete Guide", "expected_ctr": "8-12%"}], "tags": ["tutorial", "guide", "tips"], "description_template": "In this video we explore this topic in depth.", "thumbnail_ideas": ["Expressive face with bold text overlay"], "best_posting_time": "2-4 PM EST weekdays", "engagement_strategies": ["Pin a question comment", "Use end screens"], "competition_gap_analysis": "Focus on underserved subtopics within this niche." } def analyze_youtube(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- video_titles (3 items, each with "title" + "expected_ctr")\n- tags (5 items)\n- description_template (string)\n- thumbnail_ideas (2 items)\n- best_posting_time (string)\n- engagement_strategies (2 items)\n- competition_gap_analysis (string)'} ] return run_analysis(messages, defaults=DEFAULTS, temperature=0.3, max_new_tokens=800)