
    `i9                     (   d Z dZddededefdZddededefdZed	k(  rgd
dl	Z	 e
d      5 Z e	j                  e      Zddd       ed   d
   Z ee      Z eed      Z eedd         ed        ed ee       d       yy# 1 sw Y   JxY w)ae  
Prompt C: Unclustered Raw Post Analysis

This prompt BYPASSES the clustering step entirely.
It receives a sample of raw Reddit posts and looks for viral hooks directly.

Hypothesis: Clustering may be abstracting away the specific details that make hooks work.
By looking at raw posts, we might find hooks that clustering would obscure into generic themes.
at  You are a viral content scout. Below are {post_count} raw Reddit posts from communities related to {topic_area}.

Your job: Find the SINGLE POST with the most viral potential and extract its hook.

I don't want themes. I don't want "people are interested in X." I want you to find the ONE specific post that contains something so surprising, counterintuitive, or emotionally charged that millions of people would click on it.

## THE RAW POSTS

{posts_text}

## WHAT YOU'RE LOOKING FOR

The best viral hooks come from:
1. **Personal confessions with numbers**: "I spent $50k on a financial advisor. Here's what I got."
2. **Counterintuitive outcomes**: "I followed all the advice and it made things worse"
3. **Revealed mechanisms**: "Why the thing you think helps is actually hurting you"
4. **Emotional recognition**: "That feeling when X happens" (if X is universal but unspoken)
5. **Surprising connections**: "Why your [A] is actually causing your [B]"

The best hooks are SPECIFIC (numbers, names, concrete details) not GENERAL (broad topics).

## YOUR TASK

1. Read every post
2. Identify which ONE post has the most viral potential
3. Extract the specific hook from that post
4. Turn it into a video concept

## RESPOND IN JSON:

{{
  "winning_post": {{
    "post_index": "Which post number (1-{post_count})",
    "why_this_one": "In 1-2 sentences, what makes this specific post viral-worthy?",
    "the_hook": "The specific surprising detail (quote the post if possible)"
  }},

  "video_concept": {{
    "title": "A specific, clickable title built from this hook",
    "the_question_it_answers": "What are viewers desperate to understand?",
    "the_revelation": "The surprising truth they'll learn",
    "why_share": "Why would someone send this to a friend?",
    "emotional_payoff": "How viewers feel after watching (validated/empowered/smarter/relieved/amused)"
  }},

  "hook_quality": {{
    "specificity": "1-5: Does it have concrete details (numbers, names, specific situations)?",
    "surprise_factor": "1-5: How much does it violate expectations?",
    "emotional_pull": "1-5: Does it make you feel something?",
    "universality": "1-5: Can many people relate to this?",
    "overall_score": "Average, 1 decimal"
  }},

  "runner_up_posts": [
    {{
      "post_index": "2nd best post number",
      "hook": "The hook from that post",
      "why_not_winner": "What's it missing vs the winner?"
    }},
    {{
      "post_index": "3rd best post number",
      "hook": "The hook from that post",
      "why_not_winner": "What's it missing?"
    }}
  ],

  "verdict": "MAKE_NOW / WORTH_MAKING / NEEDS_RESEARCH / SKIP",
  "verdict_reasoning": "One sentence"
}}

IMPORTANT:
- If NONE of the posts have genuine viral potential, say so. Verdict = SKIP.
- Don't force a hook where there isn't one.
- A good post in the data is worth more than a theoretically good topic.

Respond in JSON only. No markdown code blocks.	raw_posts
topic_areareturnc                 |   g }t        | dd d      D ]  \  }}|j                  dd      }|j                  dd      }|j                  dd      }|j                  dd	      }|j                  d
d	      }	|j                  d| d| d| d|	        |j                  d|        |r7|j                  d|dd         t        |      dkD  r#|j                  d       n|j                  d       |j                  d        dj	                  |      }
t        t        |       d      }t        j                  |||
      S )z/Format Prompt C with raw posts (no clustering).N      title selftext	subredditnum_comments    scorez
---
## POST z | r/z | z comments | score: z**Title:** 
i  z[truncated]z*[no body text]*)
post_countr   
posts_text)	enumerategetappendlenjoinminPROMPT_Cformat)r   r   posts_linesipostr   r
   r   r   r   r   r   s               F/home/sietch6/trending-topics-pipeline/sandbox/prompt_c_unclustered.pyformat_prompt_cr   Y   sM    KYs^Q/ 4"%88J+HH["-	xx2!$_QCuYKs<.Pcdicjkl[01HUdO#4568}t#""=1122!$ ;'JS^R(J??       cluster_datasample_sizec           
      j   | j                  dg       }|D cg c]#  }t        |j                  dd            dkD  s"|% }}|j                  d d       |d|d	z   }|D cg c]	  }||vs| }}d
dl}|j	                  |t        t        |      |t        |      z
              }||z   S c c}w c c}w )z8Extract raw posts from cluster for unclustered analysis.r   r
   r	   2   c                 &    | j                  dd      S )Nr   r   )r   )xs    r   <lambda>z.get_unclustered_posts_sample.<locals>.<lambda>   s    !%%*B r   T)keyreverseN   r   )r   r   sortrandomsampler   )	r    r!   postspposts_with_content	top_posts	remainingr+   random_samples	            r   get_unclustered_posts_sampler3   y   s     ["-E &+Nc!%%
B2G.H2.M!NN BDQ ##4K1$45I.Eq!92DEIEMM)SYsS\~A]-^_M}$$ O
 Fs   #B+B+!	B0+B0__main__r   Nztest_clusters.jsonclusterszcognitive psychology)r   i  z...z
Total prompt length: z chars)zpsychology and behavior)r   )__doc__r   liststrr   dictintr3   __name__jsonopenfloaddataclusterr-   promptprintr    r   r   <module>rE      s   K2\t  UX @%t %# %t %& z	"	# qtyy| :q!G(1EU/EFF	&$-	%L	#CK=
78  s   BB